Messenger/packages/web/eslint.config.mjs
Заид Омар Медхат | Zaid Omar Medhat 1fda5394c3 auth
2026-07-10 14:16:10 +05:00

51 lines
1.4 KiB
JavaScript

import { base } from '../../eslint.config.mjs';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
// Strict Feature-Sliced Design: a layer may import only from itself and the
// layers below it. Upward imports are build errors. Enforced with path-based
// no-restricted-imports (reliable across relative imports), one override per
// layer forbidding every higher layer.
const FSD_LAYERS = ['app', 'pages', 'widgets', 'features', 'entities', 'shared'];
const fsdLayerOverrides = FSD_LAYERS.flatMap((layer, index) => {
const higherLayers = FSD_LAYERS.slice(0, index);
if (higherLayers.length === 0) {
return [];
}
return [
{
files: [`src/${layer}/**/*.{ts,tsx}`],
rules: {
'no-restricted-imports': [
'error',
{
patterns: higherLayers.map((higher) => ({
group: [`**/${higher}`, `**/${higher}/**`],
message: `FSD violation: layer '${layer}' may not import from the higher layer '${higher}'.`,
})),
},
],
},
},
];
});
export default [
{ ignores: ['dist/**'] },
...base,
{
files: ['src/**/*.{ts,tsx}'],
languageOptions: {
globals: { ...globals.browser },
},
plugins: {
'react-hooks': reactHooks,
},
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
...fsdLayerOverrides,
];