import { FlatCompat } from '@eslint/eslintrc'; import nxEslintPlugin from '@nx/eslint-plugin'; import reactHooks from 'eslint-plugin-react-hooks'; import js from '@eslint/js'; const compat = new FlatCompat({ baseDirectory: import.meta.dirname, recommendedConfig: js.configs.recommended, }); export default [ { plugins: { '@nx': nxEslintPlugin } }, { files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], rules: { '@nx/enforce-module-boundaries': [ 'error', { enforceBuildableLibDependency: true, allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'], depConstraints: [ { sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }, ], }, ], }, }, // Source files carry `eslint-disable-next-line react-hooks/exhaustive-deps` // comments, but the plugin was never registered — so every one of them was // an error ("Definition for rule ... was not found") rather than a // suppression, and no hook was ever actually checked. { files: ['**/*.tsx', '**/*.jsx'], plugins: { 'react-hooks': reactHooks }, rules: { 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', }, }, ...compat.config({ extends: ['plugin:@nx/typescript'], }).map((c) => ({ ...c, files: ['**/*.ts', '**/*.tsx'] })), ...compat.config({ extends: ['plugin:@nx/javascript'], }).map((c) => ({ ...c, files: ['**/*.js', '**/*.jsx'] })), { ignores: ['**/dist/**', '**/build/**', '**/.react-router/**'] }, ];