38 lines
925 B
JavaScript
38 lines
925 B
JavaScript
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", "Factory" 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|Factory|Repository|Service|Entity|Mapper|Schema|Guard|Module|Controller)$/.test(name);
|
|
|
|
if (!isValidName) {
|
|
context.report({
|
|
node,
|
|
messageId: 'invalidNaming',
|
|
data: {
|
|
name,
|
|
},
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|