website refactor
This commit is contained in:
37
adapters/eslint-rules/adapter-naming.js
Normal file
37
adapters/eslint-rules/adapter-naming.js
Normal file
@@ -0,0 +1,37 @@
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Enforce adapter naming conventions',
|
||||
category: 'Architecture',
|
||||
recommended: true,
|
||||
},
|
||||
fixable: null,
|
||||
schema: [],
|
||||
messages: {
|
||||
invalidNaming: 'Adapter classes should end with "Adapter", "Repository", "Service", or "Entity". Found: {{name}}',
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
ClassDeclaration(node) {
|
||||
const filename = context.getFilename();
|
||||
if (!filename.includes('adapters/')) return;
|
||||
|
||||
const name = node.id.name;
|
||||
const isValidName = /(.+)(Adapter|Repository|Service|Entity|Mapper|Schema|Guard|Module|Controller)$/.test(name);
|
||||
|
||||
if (!isValidName) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'invalidNaming',
|
||||
data: {
|
||||
name,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user