website refactor
This commit is contained in:
35
adapters/eslint-rules/no-index-files.js
Normal file
35
adapters/eslint-rules/no-index-files.js
Normal 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 {};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user