|
| 1 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; |
| 2 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 3 | +import js from '@eslint/js'; |
| 4 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 5 | +import tsParser from '@typescript-eslint/parser'; |
| 6 | +import prettier from 'eslint-plugin-prettier'; |
| 7 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 8 | +import globals from 'globals'; |
| 9 | +import path from 'node:path'; |
| 10 | +import { fileURLToPath } from 'node:url'; |
| 11 | + |
| 12 | +// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention |
| 13 | +const __filename = fileURLToPath(import.meta.url); |
| 14 | +// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention |
| 15 | +const __dirname = path.dirname(__filename); |
| 16 | +const compat = new FlatCompat({ |
| 17 | + baseDirectory: __dirname, |
| 18 | + recommendedConfig: js.configs.recommended, |
| 19 | + allConfig: js.configs.all, |
| 20 | +}); |
| 21 | + |
| 22 | +export default [ |
| 23 | + { |
| 24 | + ignores: ['.yarn', 'dist/*', '**/*.d.ts', 'coverage/*', '**/commitlint.config.js'], |
| 25 | + }, |
| 26 | + ...fixupConfigRules( |
| 27 | + compat.extends( |
| 28 | + 'airbnb', |
| 29 | + 'airbnb-typescript', |
| 30 | + 'plugin:import/typescript', |
| 31 | + 'prettier', |
| 32 | + 'plugin:react/recommended', |
| 33 | + 'plugin:react-hooks/recommended', |
| 34 | + 'plugin:@typescript-eslint/recommended', |
| 35 | + ), |
| 36 | + ), |
| 37 | + { |
| 38 | + plugins: { |
| 39 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 40 | + prettier, |
| 41 | + 'react-hooks': fixupPluginRules(reactHooks), |
| 42 | + }, |
| 43 | + |
| 44 | + languageOptions: { |
| 45 | + globals: { |
| 46 | + ...globals.browser, |
| 47 | + cy: true, |
| 48 | + Cypress: true, |
| 49 | + }, |
| 50 | + |
| 51 | + parser: tsParser, |
| 52 | + ecmaVersion: 'latest', |
| 53 | + sourceType: 'module', |
| 54 | + |
| 55 | + parserOptions: { |
| 56 | + project: './tsconfig.eslint.json', |
| 57 | + |
| 58 | + ecmaFeatures: { |
| 59 | + jsx: true, |
| 60 | + }, |
| 61 | + }, |
| 62 | + }, |
| 63 | + |
| 64 | + settings: { |
| 65 | + 'import/parsers': { |
| 66 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 67 | + }, |
| 68 | + |
| 69 | + 'import/resolver': { |
| 70 | + typescript: { |
| 71 | + alwaysTryTypes: true, |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + |
| 76 | + rules: { |
| 77 | + 'react/prop-types': 'off', |
| 78 | + 'react/no-array-index-key': 'off', |
| 79 | + 'react/jsx-props-no-spreading': 'off', |
| 80 | + 'react/destructuring-assignment': 'off', |
| 81 | + 'react/require-default-props': 'off', |
| 82 | + 'react/react-in-jsx-scope': 'off', |
| 83 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 84 | + 'import/no-import-module-exports': 'off', |
| 85 | + |
| 86 | + 'import/no-extraneous-dependencies': [ |
| 87 | + 'error', |
| 88 | + { |
| 89 | + devDependencies: true, |
| 90 | + }, |
| 91 | + ], |
| 92 | + |
| 93 | + 'no-console': [ |
| 94 | + 'warn', |
| 95 | + { |
| 96 | + allow: ['warn', 'error', 'debug', 'info'], |
| 97 | + }, |
| 98 | + ], |
| 99 | + |
| 100 | + 'import/prefer-default-export': 'off', |
| 101 | + 'prettier/prettier': 'error', |
| 102 | + |
| 103 | + 'import/extensions': [ |
| 104 | + 'error', |
| 105 | + 'ignorePackages', |
| 106 | + { |
| 107 | + ts: 'never', |
| 108 | + js: 'never', |
| 109 | + tsx: 'never', |
| 110 | + }, |
| 111 | + ], |
| 112 | + |
| 113 | + '@typescript-eslint/explicit-function-return-type': [ |
| 114 | + 'error', |
| 115 | + { |
| 116 | + allowExpressions: true, |
| 117 | + allowHigherOrderFunctions: true, |
| 118 | + allowTypedFunctionExpressions: true, |
| 119 | + }, |
| 120 | + ], |
| 121 | + |
| 122 | + 'react-hooks/rules-of-hooks': 'error', |
| 123 | + 'react-hooks/exhaustive-deps': 'warn', |
| 124 | + 'comma-dangle': 'off', |
| 125 | + '@typescript-eslint/comma-dangle': 'off', |
| 126 | + 'react/jsx-one-expression-per-line': 'off', |
| 127 | + |
| 128 | + 'react/jsx-filename-extension': [ |
| 129 | + 'warn', |
| 130 | + { |
| 131 | + extensions: ['.tsx'], |
| 132 | + }, |
| 133 | + ], |
| 134 | + |
| 135 | + 'react/function-component-definition': [ |
| 136 | + 'warn', |
| 137 | + { |
| 138 | + namedComponents: 'arrow-function', |
| 139 | + }, |
| 140 | + ], |
| 141 | + |
| 142 | + 'no-shadow': 'off', |
| 143 | + '@typescript-eslint/no-shadow': ['error'], |
| 144 | + |
| 145 | + '@typescript-eslint/no-unused-vars': [ |
| 146 | + 'warn', |
| 147 | + { |
| 148 | + argsIgnorePattern: '^_', |
| 149 | + varsIgnorePattern: '^_', |
| 150 | + caughtErrorsIgnorePattern: '^_', |
| 151 | + }, |
| 152 | + ], |
| 153 | + }, |
| 154 | + }, |
| 155 | + { |
| 156 | + files: ['**/*.ts', '**/*.tsx'], |
| 157 | + |
| 158 | + rules: { |
| 159 | + '@typescript-eslint/explicit-function-return-type': ['off'], |
| 160 | + }, |
| 161 | + }, |
| 162 | +]; |
0 commit comments