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

13
adapters/.eslintrc.json Normal file
View File

@@ -0,0 +1,13 @@
{
"extends": [
"../.eslintrc.json",
"plugin:gridpilot-adapters-rules/recommended"
],
"plugins": [
"gridpilot-adapters-rules"
],
"rules": {
"gridpilot-adapters-rules/no-index-files": "error",
"gridpilot-adapters-rules/adapter-naming": "error"
}
}

View 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,
},
});
}
},
};
},
};

View File

@@ -0,0 +1,18 @@
const noIndexFiles = require('./no-index-files');
const adapterNaming = require('./adapter-naming');
module.exports = {
rules: {
'no-index-files': noIndexFiles,
'adapter-naming': adapterNaming,
},
configs: {
recommended: {
plugins: ['gridpilot-adapters-rules'],
rules: {
'gridpilot-adapters-rules/no-index-files': 'error',
'gridpilot-adapters-rules/adapter-naming': 'error',
},
},
},
};

View File

@@ -0,0 +1,35 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Ban index.ts files in Adapters - use explicit imports instead',
category: 'Best Practices',
recommended: true,
},
fixable: null,
schema: [],
messages: {
indexFile: 'Index files are banned in adapters. Use explicit imports. Example: Instead of "import { foo } from "./", use "import { foo } from "./foo".',
},
},
create(context) {
const filename = context.getFilename();
const isIndexFile = /(^|\/|\\)index\.ts$/.test(filename);
// Allow root index.ts if any
const allowedPaths = [
'adapters/index.ts',
];
if (isIndexFile && !allowedPaths.some(path => filename.endsWith(path))) {
context.report({
node: null,
loc: { line: 1, column: 0 },
messageId: 'indexFile',
});
}
return {};
},
};

View File

@@ -0,0 +1,8 @@
{
"name": "eslint-plugin-gridpilot-adapters-rules",
"version": "0.1.0",
"main": "index.js",
"peerDependencies": {
"eslint": ">=8.0.0"
}
}