website refactor
This commit is contained in:
39
core/eslint-rules/no-framework-imports.js
Normal file
39
core/eslint-rules/no-framework-imports.js
Normal 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,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user