|
| 1 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; |
| 2 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 3 | +import _import from 'eslint-plugin-import'; |
| 4 | +import simpleImportSort from 'eslint-plugin-simple-import-sort'; |
| 5 | +import globals from 'globals'; |
| 6 | +import tsParser from '@typescript-eslint/parser'; |
| 7 | +import path from 'node:path'; |
| 8 | +import { fileURLToPath } from 'node:url'; |
| 9 | +import js from '@eslint/js'; |
| 10 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all, |
| 18 | +}); |
| 19 | + |
| 20 | +export default [ |
| 21 | + { |
| 22 | + ignores: [ |
| 23 | + './tsconfig.json', |
| 24 | + '**/build', |
| 25 | + '**/dist', |
| 26 | + '**/node_modules', |
| 27 | + '**/*.test.js', |
| 28 | + '**/vite.config.ts', |
| 29 | + '**/postcss.config.js', |
| 30 | + '**/tailwind.config.js', |
| 31 | + '**/i18n.ts', |
| 32 | + 'public/firebase-messaging-sw.js', |
| 33 | + 'src/components/ui/*', |
| 34 | + 'eslint.config.js', |
| 35 | + ], |
| 36 | + }, |
| 37 | + ...fixupConfigRules( |
| 38 | + compat.extends( |
| 39 | + 'eslint:recommended', |
| 40 | + 'plugin:@typescript-eslint/recommended', |
| 41 | + 'plugin:jsx-a11y/recommended', |
| 42 | + 'plugin:react/recommended', |
| 43 | + 'plugin:prettier/recommended', |
| 44 | + 'plugin:testing-library/react', |
| 45 | + 'plugin:react-hooks/recommended', |
| 46 | + 'plugin:prettier/recommended', |
| 47 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking' |
| 48 | + ) |
| 49 | + ), |
| 50 | + { |
| 51 | + plugins: { |
| 52 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 53 | + import: fixupPluginRules(_import), |
| 54 | + 'simple-import-sort': simpleImportSort, |
| 55 | + }, |
| 56 | + |
| 57 | + languageOptions: { |
| 58 | + globals: { |
| 59 | + ...globals.node, |
| 60 | + ...globals.browser, |
| 61 | + }, |
| 62 | + |
| 63 | + parser: tsParser, |
| 64 | + ecmaVersion: 'latest', |
| 65 | + sourceType: 'module', |
| 66 | + |
| 67 | + parserOptions: { |
| 68 | + project: ['./tsconfig.json', './.eslintrc.cjs'], |
| 69 | + tsconfigRootDir: '/Users/frx/Development/fullstack/docker-react-node-mysql-app/frontend', |
| 70 | + }, |
| 71 | + }, |
| 72 | + |
| 73 | + settings: { |
| 74 | + react: { |
| 75 | + version: 'detect', |
| 76 | + }, |
| 77 | + }, |
| 78 | + |
| 79 | + rules: { |
| 80 | + 'react-hooks/rules-of-hooks': 2, |
| 81 | + 'react-hooks/exhaustive-deps': 2, |
| 82 | + 'react/no-array-index-key': 'off', |
| 83 | + 'react/react-in-jsx-scope': 'off', |
| 84 | + 'react/prop-types': 'off', |
| 85 | + '@typescript-eslint/no-non-null-assertion': 0, |
| 86 | + 'no-unused-vars': 'off', |
| 87 | + '@typescript-eslint/no-misused-promises': 'off', |
| 88 | + '@typescript-eslint/no-explicit-any': 'off', |
| 89 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 90 | + // 'no-restricted-imports': 'off', |
| 91 | + 'jsx-a11y/no-autofocus': 'off', |
| 92 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 93 | + 'no-restricted-imports': 'off', |
| 94 | + 'no-console': 'off', |
| 95 | + 'no-constant-binary-expression': 'off', |
| 96 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 97 | + '@typescript-eslint/no-unsafe-argument': 'off', |
| 98 | + '@typescript-eslint/no-unused-vars': [ |
| 99 | + 2, |
| 100 | + { |
| 101 | + argsIgnorePattern: '^_', |
| 102 | + varsIgnorePattern: '^_', |
| 103 | + ignoreRestSiblings: true, |
| 104 | + }, |
| 105 | + ], |
| 106 | + |
| 107 | + 'prettier/prettier': [ |
| 108 | + 'off', |
| 109 | + { |
| 110 | + singleQuote: true, |
| 111 | + }, |
| 112 | + ], |
| 113 | + |
| 114 | + // 'no-restricted-imports': [ |
| 115 | + // 2, |
| 116 | + // { |
| 117 | + // patterns: ['@/features/*/*', '@/components/*', '@/hooks/*', '@/utils/*', '@/ts/*/*'], |
| 118 | + // }, |
| 119 | + // ], |
| 120 | + |
| 121 | + 'import/order': [ |
| 122 | + 'error', |
| 123 | + { |
| 124 | + groups: ['builtin', 'external', 'internal'], |
| 125 | + |
| 126 | + pathGroups: [ |
| 127 | + { |
| 128 | + pattern: 'react', |
| 129 | + group: 'external', |
| 130 | + position: 'before', |
| 131 | + }, |
| 132 | + ], |
| 133 | + |
| 134 | + pathGroupsExcludedImportTypes: ['react'], |
| 135 | + 'newlines-between': 'always', |
| 136 | + |
| 137 | + alphabetize: { |
| 138 | + order: 'asc', |
| 139 | + caseInsensitive: true, |
| 140 | + }, |
| 141 | + }, |
| 142 | + ], |
| 143 | + |
| 144 | + 'no-implied-eval': 'off', |
| 145 | + 'require-await': 'off', |
| 146 | + }, |
| 147 | + }, |
| 148 | + { |
| 149 | + files: ['**/.eslintrc.{js,cjs}'], |
| 150 | + |
| 151 | + languageOptions: { |
| 152 | + globals: { |
| 153 | + ...globals.node, |
| 154 | + }, |
| 155 | + |
| 156 | + ecmaVersion: 5, |
| 157 | + sourceType: 'commonjs', |
| 158 | + }, |
| 159 | + }, |
| 160 | +]; |
0 commit comments