website refactor

This commit is contained in:
2026-01-16 11:51:12 +01:00
parent 63dfa58bcb
commit 0208334c59
49 changed files with 525 additions and 89 deletions

View File

@@ -0,0 +1,46 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Enforce that API services do not use repositories directly',
category: 'Architecture',
recommended: true,
},
fixable: null,
schema: [],
messages: {
forbiddenRepository: 'API Services should not use repositories directly. Use Cases should handle data access. Forbidden use of "{{name}}".',
},
},
create(context) {
return {
ClassDeclaration(node) {
const isService = node.id.name.endsWith('Service');
if (!isService) return;
// Check constructor for injected repositories
const constructor = node.body.body.find(m => m.kind === 'constructor');
if (constructor) {
constructor.value.params.forEach(param => {
if (param.type === 'TSParameterProperty') {
const typeAnnotation = param.parameter.typeAnnotation;
if (typeAnnotation && typeAnnotation.typeAnnotation.type === 'TSTypeReference') {
const typeName = typeAnnotation.typeAnnotation.typeName.name;
if (typeName.endsWith('Repository')) {
context.report({
node: param,
messageId: 'forbiddenRepository',
data: {
name: typeName,
},
});
}
}
}
});
}
},
};
},
};