Files
gridpilot.gg/adapters/eslint-rules/no-index-files.js
2026-01-16 11:51:12 +01:00

36 lines
900 B
JavaScript

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 {};
},
};