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
core/.eslintrc.json Normal file
View File

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

View File

@@ -0,0 +1,37 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Enforce that Core Domain does not depend on Application layer',
category: 'Architecture',
recommended: true,
},
fixable: null,
schema: [],
messages: {
forbiddenImport: 'Domain layer should not depend on Application layer. Forbidden import from "{{source}}".',
},
},
create(context) {
const filename = context.getFilename();
const isDomainFile = filename.includes('/domain/');
if (!isDomainFile) return {};
return {
ImportDeclaration(node) {
const source = node.source.value;
if (source.includes('/application/')) {
context.report({
node,
messageId: 'forbiddenImport',
data: {
source,
},
});
}
},
};
},
};

View File

@@ -0,0 +1,21 @@
const noIndexFiles = require('./no-index-files');
const noFrameworkImports = require('./no-framework-imports');
const domainNoApplication = require('./domain-no-application');
module.exports = {
rules: {
'no-index-files': noIndexFiles,
'no-framework-imports': noFrameworkImports,
'domain-no-application': domainNoApplication,
},
configs: {
recommended: {
plugins: ['gridpilot-core-rules'],
rules: {
'gridpilot-core-rules/no-index-files': 'error',
'gridpilot-core-rules/no-framework-imports': 'error',
'gridpilot-core-rules/domain-no-application': 'error',
},
},
},
};

View File

@@ -0,0 +1,39 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Ban framework imports in Core',
category: 'Architecture',
recommended: true,
},
fixable: null,
schema: [],
messages: {
frameworkImport: 'Core must be framework-free. Forbidden import from "{{source}}".',
},
},
create(context) {
const forbiddenPatterns = [
/^@nestjs\//,
/^express/,
/^react/,
/^next\//,
];
return {
ImportDeclaration(node) {
const source = node.source.value;
if (forbiddenPatterns.some(pattern => pattern.test(source))) {
context.report({
node,
messageId: 'frameworkImport',
data: {
source,
},
});
}
},
};
},
};

View File

@@ -0,0 +1,35 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Ban index.ts files in Core - use explicit imports instead',
category: 'Best Practices',
recommended: true,
},
fixable: null,
schema: [],
messages: {
indexFile: 'Index files are banned in core. 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 = [
'core/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-core-rules",
"version": "0.1.0",
"main": "index.js",
"peerDependencies": {
"eslint": ">=8.0.0"
}
}