|
| 1 | +import typescriptEslint from '@typescript-eslint/eslint-plugin' |
| 2 | +import tsParser from '@typescript-eslint/parser' |
| 3 | +import path from 'node:path' |
| 4 | +import { fileURLToPath } from 'node:url' |
| 5 | + |
| 6 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat' |
| 7 | +import { FlatCompat } from '@eslint/eslintrc' |
| 8 | +import js from '@eslint/js' |
| 9 | +import _import from 'eslint-plugin-import' |
| 10 | +import jest from 'eslint-plugin-jest' |
| 11 | +import react from 'eslint-plugin-react' |
| 12 | +import reactHooks from 'eslint-plugin-react-hooks' |
| 13 | +import globals from 'globals' |
| 14 | + |
| 15 | +const __filename = fileURLToPath(import.meta.url) |
| 16 | +const __dirname = path.dirname(__filename) |
| 17 | +const compat = new FlatCompat({ |
| 18 | + baseDirectory: __dirname, |
| 19 | + recommendedConfig: js.configs.recommended, |
| 20 | + allConfig: js.configs.all, |
| 21 | +}) |
| 22 | + |
| 23 | +export default [ |
| 24 | + { ignores: ['apps/*/build/', 'packages/*/dist/'] }, |
| 25 | + ...fixupConfigRules( |
| 26 | + compat.extends( |
| 27 | + 'eslint:recommended', |
| 28 | + 'plugin:react/recommended', |
| 29 | + 'plugin:@typescript-eslint/recommended', |
| 30 | + 'plugin:jest/recommended', |
| 31 | + 'plugin:jest/style', |
| 32 | + 'plugin:react/jsx-runtime', |
| 33 | + 'plugin:react-hooks/recommended', |
| 34 | + 'prettier', |
| 35 | + ), |
| 36 | + ), |
| 37 | + { |
| 38 | + plugins: { |
| 39 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 40 | + import: fixupPluginRules(_import), |
| 41 | + jest: fixupPluginRules(jest), |
| 42 | + react: fixupPluginRules(react), |
| 43 | + 'react-hooks': fixupPluginRules(reactHooks), |
| 44 | + }, |
| 45 | + |
| 46 | + languageOptions: { |
| 47 | + globals: { ...globals.browser }, |
| 48 | + |
| 49 | + parser: tsParser, |
| 50 | + ecmaVersion: 2021, |
| 51 | + sourceType: 'module', |
| 52 | + |
| 53 | + parserOptions: { ecmaFeatures: { jsx: true } }, |
| 54 | + }, |
| 55 | + |
| 56 | + settings: { react: { version: 'detect' } }, |
| 57 | + |
| 58 | + rules: { |
| 59 | + 'no-unused-vars': 'off', |
| 60 | + '@typescript-eslint/no-empty-function': 'off', |
| 61 | + '@typescript-eslint/no-empty-interface': 'warn', |
| 62 | + |
| 63 | + '@typescript-eslint/no-unused-vars': [ |
| 64 | + 'warn', |
| 65 | + { argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
| 66 | + ], |
| 67 | + |
| 68 | + 'arrow-body-style': ['warn', 'as-needed'], |
| 69 | + curly: ['warn', 'all'], |
| 70 | + eqeqeq: ['warn', 'always'], |
| 71 | + |
| 72 | + 'import/order': [ |
| 73 | + 'warn', |
| 74 | + { |
| 75 | + groups: [ |
| 76 | + ['builtin', 'external'], |
| 77 | + ['internal'], |
| 78 | + ['parent'], |
| 79 | + ['sibling', 'index'], |
| 80 | + ['object', 'type'], |
| 81 | + ['unknown'], |
| 82 | + ], |
| 83 | + |
| 84 | + 'newlines-between': 'always', |
| 85 | + warnOnUnassignedImports: true, |
| 86 | + |
| 87 | + alphabetize: { order: 'asc' }, |
| 88 | + |
| 89 | + pathGroups: [ |
| 90 | + { |
| 91 | + pattern: '?(react|react-dom|react-dom/client)', |
| 92 | + group: 'builtin', |
| 93 | + position: 'before', |
| 94 | + }, |
| 95 | + { pattern: './*.css', group: 'unknown', position: 'after' }, |
| 96 | + ], |
| 97 | + |
| 98 | + pathGroupsExcludedImportTypes: ['react', 'react-dom'], |
| 99 | + }, |
| 100 | + ], |
| 101 | + |
| 102 | + 'jest/no-disabled-tests': 'warn', |
| 103 | + 'jest/no-focused-tests': 'warn', |
| 104 | + 'jest/no-identical-title': 'warn', |
| 105 | + 'jest/prefer-to-have-length': 'warn', |
| 106 | + 'jest/valid-expect': 'warn', |
| 107 | + 'react/display-name': 'off', |
| 108 | + 'react/no-unescaped-entities': 'off', |
| 109 | + |
| 110 | + 'sort-imports': ['warn', { ignoreDeclarationSort: true }], |
| 111 | + }, |
| 112 | + }, |
| 113 | +] |
0 commit comments