website refactor

This commit is contained in:
2026-01-13 12:49:23 +01:00
parent 187d2476e8
commit 87572f5b1f
3 changed files with 107 additions and 4 deletions

View File

@@ -148,6 +148,9 @@ module.exports = {
// Route Configuration Rules
'no-hardcoded-routes': require('./no-hardcoded-routes'),
'no-hardcoded-search-params': require('./no-hardcoded-search-params'),
// Architecture Rules
'no-index-files': require('./no-index-files'),
},
// Configurations for different use cases

View File

@@ -0,0 +1,45 @@
/**
* @file no-index-files.js
* Bans index.ts/index.tsx files - they hide dependencies and make code harder to navigate
*/
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Ban index.ts/index.tsx files - use explicit imports instead',
category: 'Best Practices',
recommended: true,
},
fixable: null,
schema: [],
messages: {
indexFile: 'Index files are banned. Use explicit imports and barrel exports. Example: Instead of "import { foo } from "./", use "import { foo } from "./foo" and export from "./foo" explicitly.',
},
},
create(context) {
const filename = context.getFilename();
// Check if file is named index.ts or index.tsx
const isIndexFile = /(^|\/|\\)index\.(ts|tsx)$/.test(filename);
// Allow index files in root directories that are required by framework
const allowedPaths = [
'apps/website/app/index.ts', // Next.js app router entry
'apps/website/pages/index.tsx', // Next.js pages router entry
'apps/website/src/index.ts', // Common entry point
'apps/website/index.ts', // Root entry
];
if (isIndexFile && !allowedPaths.some(path => filename.endsWith(path))) {
context.report({
node: null, // Report on the file level
loc: { line: 1, column: 0 },
messageId: 'indexFile',
});
}
return {};
},
};