|
| 1 | +import react from 'eslint-plugin-react' |
| 2 | +import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths' |
| 3 | +import tsParser from '@typescript-eslint/parser' |
| 4 | +import path from 'node:path' |
| 5 | +import { fileURLToPath } from 'node:url' |
| 6 | +import js from '@eslint/js' |
| 7 | +import { FlatCompat } from '@eslint/eslintrc' |
| 8 | + |
| 9 | +const __filename = fileURLToPath(import.meta.url) |
| 10 | +const __dirname = path.dirname(__filename) |
| 11 | +const compat = new FlatCompat({ |
| 12 | + baseDirectory: __dirname, |
| 13 | + recommendedConfig: js.configs.recommended, |
| 14 | + allConfig: js.configs.all, |
| 15 | +}) |
| 16 | + |
| 17 | +export default [{ |
| 18 | + ignores: [ |
| 19 | + '**/node_modules/', |
| 20 | + '**/dist/', |
| 21 | + '**/.prettierrc', |
| 22 | + '**/*env*', |
| 23 | + '**/vite.config.ts', |
| 24 | + '**/generated/', |
| 25 | + '**/coverage/', |
| 26 | + ], |
| 27 | +}, ...compat.extends( |
| 28 | + 'eslint:recommended', |
| 29 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 30 | + 'plugin:@typescript-eslint/recommended', |
| 31 | + 'plugin:react/all', |
| 32 | + 'google', |
| 33 | +), { |
| 34 | + plugins: { |
| 35 | + react, |
| 36 | + 'no-relative-import-paths': noRelativeImportPaths, |
| 37 | + }, |
| 38 | + |
| 39 | + languageOptions: { |
| 40 | + parser: tsParser, |
| 41 | + ecmaVersion: 5, |
| 42 | + sourceType: 'module', |
| 43 | + parserOptions: { |
| 44 | + project: './tsconfig.json', |
| 45 | + }, |
| 46 | + }, |
| 47 | + |
| 48 | + settings: { |
| 49 | + react: { |
| 50 | + version: 'detect', |
| 51 | + }, |
| 52 | + |
| 53 | + 'import/resolver': { |
| 54 | + node: { |
| 55 | + paths: ['src'], |
| 56 | + extensions: ['.js', '.jsx', '.ts', '.tsx'], |
| 57 | + }, |
| 58 | + }, |
| 59 | + }, |
| 60 | + |
| 61 | + rules: { |
| 62 | + semi: ['error', 'never'], |
| 63 | + |
| 64 | + 'max-len': ['error', { |
| 65 | + code: 120, |
| 66 | + ignorePattern: '^import .*', |
| 67 | + }], |
| 68 | + |
| 69 | + 'space-infix-ops': 'error', |
| 70 | + eqeqeq: ['error', 'always'], |
| 71 | + 'object-curly-spacing': ['warn', 'always'], |
| 72 | + 'require-jsdoc': 'off', |
| 73 | + 'valid-jsdoc': 'off', |
| 74 | + 'no-unused-vars': 'off', |
| 75 | + 'react/jsx-no-comment-textnodes': 'off', |
| 76 | + 'react/prop-types': 'off', |
| 77 | + |
| 78 | + 'react/jsx-indent': [2, 2, { |
| 79 | + checkAttributes: true, |
| 80 | + indentLogicalExpressions: true, |
| 81 | + }], |
| 82 | + |
| 83 | + 'react/jsx-max-depth': [2, { |
| 84 | + max: 7, |
| 85 | + }], |
| 86 | + |
| 87 | + 'react/jsx-indent-props': [2, 2], |
| 88 | + 'react/require-default-props': 'off', |
| 89 | + |
| 90 | + 'react/jsx-max-props-per-line': [1, { |
| 91 | + when: 'multiline', |
| 92 | + }], |
| 93 | + |
| 94 | + 'react/jsx-filename-extension': ['error', { |
| 95 | + extensions: ['.tsx'], |
| 96 | + }], |
| 97 | + |
| 98 | + indent: ['error', 2, { |
| 99 | + SwitchCase: 1, |
| 100 | + offsetTernaryExpressions: false, |
| 101 | + }], |
| 102 | + |
| 103 | + 'quote-props': 'off', |
| 104 | + 'react/destructuring-assignment': 'off', |
| 105 | + 'react/react-in-jsx-scope': 'off', |
| 106 | + 'react/jsx-one-expression-per-line': 'off', |
| 107 | + 'react/jsx-props-no-spreading': 'off', |
| 108 | + 'react/forbid-component-props': 'off', |
| 109 | + 'react/jsx-no-literals': 'off', |
| 110 | + |
| 111 | + 'react/function-component-definition': [2, { |
| 112 | + namedComponents: 'arrow-function', |
| 113 | + unnamedComponents: 'arrow-function', |
| 114 | + }], |
| 115 | + |
| 116 | + 'react/no-multi-comp': [2, { |
| 117 | + ignoreStateless: true, |
| 118 | + }], |
| 119 | + |
| 120 | + 'react/jsx-no-bind': 'off', |
| 121 | + 'react/no-set-state': 'off', |
| 122 | + 'react/jsx-no-leaked-render': 'off', |
| 123 | + 'react/jsx-newline': 'off', |
| 124 | + 'arrow-parens': 'off', |
| 125 | + 'operator-linebreak': 'off', |
| 126 | + '@typescript-eslint/no-empty-function': 'off', |
| 127 | + '@typescript-eslint/no-unused-expressions': 'off', |
| 128 | + 'react/no-unstable-nested-components': 'off', |
| 129 | + |
| 130 | + '@typescript-eslint/no-unused-vars': ['error', { |
| 131 | + argsIgnorePattern: '^_', |
| 132 | + destructuredArrayIgnorePattern: '^_', |
| 133 | + varsIgnorePattern: '^_', |
| 134 | + }], |
| 135 | + |
| 136 | + 'comma-spacing': 'off', |
| 137 | + |
| 138 | + 'no-relative-import-paths/no-relative-import-paths': ['error', { |
| 139 | + allowSameFolder: true, |
| 140 | + rootDir: 'src', |
| 141 | + prefix: '', |
| 142 | + }], |
| 143 | + }, |
| 144 | +}] |
0 commit comments