44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import { base } from '../../eslint.config.mjs';
|
|
import boundaries from 'eslint-plugin-boundaries';
|
|
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 (e.g. shared → features) are build errors.
|
|
const FSD_LAYERS = ['app', 'pages', 'widgets', 'features', 'entities', 'shared'];
|
|
|
|
const fsdPolicies = FSD_LAYERS.map((layer, index) => ({
|
|
from: { element: { types: layer } },
|
|
allow: { to: { element: { types: { anyOf: FSD_LAYERS.slice(index) } } } },
|
|
}));
|
|
|
|
export default [
|
|
{ ignores: ['dist/**'] },
|
|
...base,
|
|
{
|
|
files: ['src/**/*.{ts,tsx}'],
|
|
languageOptions: {
|
|
globals: { ...globals.browser },
|
|
},
|
|
plugins: {
|
|
boundaries,
|
|
'react-hooks': reactHooks,
|
|
},
|
|
settings: {
|
|
'boundaries/include': ['src/**/*'],
|
|
'boundaries/elements': [
|
|
{ type: 'app', pattern: 'src/app/*' },
|
|
{ type: 'pages', pattern: 'src/pages/*' },
|
|
{ type: 'widgets', pattern: 'src/widgets/*' },
|
|
{ type: 'features', pattern: 'src/features/*' },
|
|
{ type: 'entities', pattern: 'src/entities/*' },
|
|
{ type: 'shared', pattern: 'src/shared/*' },
|
|
],
|
|
},
|
|
rules: {
|
|
'react-hooks/rules-of-hooks': 'error',
|
|
'react-hooks/exhaustive-deps': 'warn',
|
|
'boundaries/dependencies': ['error', { default: 'disallow', policies: fsdPolicies }],
|
|
},
|
|
},
|
|
];
|