|
| 1 | +import path from 'node:path'; |
| 2 | +import { fileURLToPath } from 'node:url'; |
| 3 | + |
| 4 | +import { defineConfig, globalIgnores } from 'eslint/config'; |
| 5 | +import expoConfig from 'eslint-config-expo/flat.js'; |
| 6 | +import i18nJsonPlugin from 'eslint-plugin-i18n-json'; |
| 7 | +import pluginJest from 'eslint-plugin-jest'; |
| 8 | +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; |
| 9 | +import reactCompiler from 'eslint-plugin-react-compiler'; |
| 10 | +import simpleImportSort from 'eslint-plugin-simple-import-sort'; |
| 11 | +import sonarjs from 'eslint-plugin-sonarjs'; |
| 12 | +import tailwind from 'eslint-plugin-tailwindcss'; |
| 13 | +import testingLibrary from 'eslint-plugin-testing-library'; |
| 14 | +// eslint-disable-next-line import/no-named-as-default, import/no-named-as-default-member, import/namespace |
| 15 | +import eslintPluginUnicorn from 'eslint-plugin-unicorn'; |
| 16 | +import unusedImports from 'eslint-plugin-unused-imports'; |
| 17 | +import { configs, parser } from 'typescript-eslint'; |
| 18 | + |
| 19 | +const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 20 | + |
| 21 | +export default defineConfig([ |
| 22 | + globalIgnores([ |
| 23 | + 'dist/*', |
| 24 | + 'node_modules', |
| 25 | + '__tests__/', |
| 26 | + 'coverage', |
| 27 | + '.expo', |
| 28 | + '.expo-shared', |
| 29 | + 'android', |
| 30 | + 'ios', |
| 31 | + '.vscode', |
| 32 | + 'docs/', |
| 33 | + 'cli/', |
| 34 | + '*.config.js', |
| 35 | + 'lint-staged.config.js', |
| 36 | + 'i18next-syntax-validation.js', |
| 37 | + 'env.js', |
| 38 | + ]), |
| 39 | + expoConfig, |
| 40 | + eslintPluginPrettierRecommended, |
| 41 | + ...tailwind.configs['flat/recommended'], |
| 42 | + reactCompiler.configs.recommended, |
| 43 | + { |
| 44 | + plugins: { |
| 45 | + 'simple-import-sort': simpleImportSort, |
| 46 | + unicorn: eslintPluginUnicorn, |
| 47 | + 'unused-imports': unusedImports, |
| 48 | + sonarjs, |
| 49 | + jest: pluginJest, |
| 50 | + }, |
| 51 | + rules: { |
| 52 | + 'import/no-duplicates': 'error', |
| 53 | + 'max-params': ['error', 3], |
| 54 | + 'max-lines-per-function': ['error', 70], |
| 55 | + 'tailwindcss/classnames-order': [ |
| 56 | + 'warn', |
| 57 | + { |
| 58 | + officialSorting: true, |
| 59 | + }, |
| 60 | + ], |
| 61 | + 'tailwindcss/no-custom-classname': 'off', |
| 62 | + 'react/display-name': 'off', |
| 63 | + 'react/no-inline-styles': 'off', |
| 64 | + 'react/destructuring-assignment': 'off', |
| 65 | + 'react/require-default-props': 'off', |
| 66 | + 'react/jsx-fragments': ['error', 'syntax'], |
| 67 | + 'react/jsx-no-useless-fragment': 'error', |
| 68 | + 'react/no-children-prop': ['error', { allowFunctions: true }], |
| 69 | + 'no-nested-ternary': 'error', |
| 70 | + 'no-unneeded-ternary': 'error', |
| 71 | + 'prefer-template': 'error', |
| 72 | + 'unicorn/filename-case': [ |
| 73 | + 'error', |
| 74 | + { |
| 75 | + case: 'kebabCase', |
| 76 | + ignore: ['/android', '/ios'], |
| 77 | + }, |
| 78 | + ], |
| 79 | + 'simple-import-sort/imports': 'error', |
| 80 | + 'simple-import-sort/exports': 'error', |
| 81 | + 'unused-imports/no-unused-imports': 'error', |
| 82 | + 'unused-imports/no-unused-vars': [ |
| 83 | + 'error', |
| 84 | + { |
| 85 | + argsIgnorePattern: '^_', |
| 86 | + varsIgnorePattern: '^_', |
| 87 | + caughtErrorsIgnorePattern: '^_', |
| 88 | + }, |
| 89 | + ], |
| 90 | + curly: [2, 'all'], |
| 91 | + 'object-shorthand': 'error', |
| 92 | + 'arrow-body-style': ['error', 'as-needed'], |
| 93 | + 'no-console': ['error', { allow: ['error'] }], |
| 94 | + 'guard-for-in': 'error', |
| 95 | + |
| 96 | + 'import/prefer-default-export': 'off', |
| 97 | + 'import/no-cycle': ['error', { maxDepth: '∞' }], |
| 98 | + 'prettier/prettier': ['error', { ignores: ['expo-env.d.ts'] }], |
| 99 | + }, |
| 100 | + }, |
| 101 | + { |
| 102 | + files: ['**/__mocks__/**'], |
| 103 | + rules: { |
| 104 | + '@typescript-eslint/no-require-imports': 'off', |
| 105 | + }, |
| 106 | + }, |
| 107 | + { |
| 108 | + files: ['**/*.ts', '**/*.tsx'], |
| 109 | + languageOptions: { |
| 110 | + parser, |
| 111 | + parserOptions: { |
| 112 | + project: './tsconfig.json', |
| 113 | + sourceType: 'module', |
| 114 | + }, |
| 115 | + globals: pluginJest.environments.globals.globals, |
| 116 | + }, |
| 117 | + rules: { |
| 118 | + ...configs.recommended.rules, |
| 119 | + '@typescript-eslint/no-explicit-any': 'error', |
| 120 | + '@typescript-eslint/comma-dangle': 'off', |
| 121 | + '@typescript-eslint/no-magic-numbers': [ |
| 122 | + 'error', |
| 123 | + { ignoreArrayIndexes: true, ignoreEnums: true, ignore: [-1, 0, 1] }, |
| 124 | + ], |
| 125 | + '@typescript-eslint/prefer-nullish-coalescing': 'error', |
| 126 | + '@typescript-eslint/array-type': [ |
| 127 | + 'error', |
| 128 | + { |
| 129 | + default: 'generic', |
| 130 | + }, |
| 131 | + ], |
| 132 | + '@typescript-eslint/consistent-type-imports': [ |
| 133 | + 'error', |
| 134 | + { |
| 135 | + prefer: 'type-imports', |
| 136 | + fixStyle: 'inline-type-imports', |
| 137 | + disallowTypeAnnotations: true, |
| 138 | + }, |
| 139 | + ], |
| 140 | + }, |
| 141 | + }, |
| 142 | + { |
| 143 | + files: ['src/translations/*.json'], |
| 144 | + plugins: { 'i18n-json': i18nJsonPlugin }, |
| 145 | + processor: { |
| 146 | + meta: { name: '.json' }, |
| 147 | + ...i18nJsonPlugin.processors['.json'], |
| 148 | + }, |
| 149 | + rules: { |
| 150 | + ...i18nJsonPlugin.configs.recommended.rules, |
| 151 | + '@typescript-eslint/ban-types': 'off', |
| 152 | + 'i18n-json/valid-message-syntax': [ |
| 153 | + 2, |
| 154 | + { |
| 155 | + syntax: path.resolve( |
| 156 | + __dirname, |
| 157 | + './scripts/i18next-syntax-validation.js', |
| 158 | + ), |
| 159 | + }, |
| 160 | + ], |
| 161 | + 'i18n-json/valid-json': 2, |
| 162 | + 'i18n-json/sorted-keys': [ |
| 163 | + 2, |
| 164 | + { |
| 165 | + order: 'asc', |
| 166 | + indentSpaces: 2, |
| 167 | + }, |
| 168 | + ], |
| 169 | + 'i18n-json/identical-keys': [ |
| 170 | + 2, |
| 171 | + { |
| 172 | + filePath: path.resolve(__dirname, './src/translations/en.json'), |
| 173 | + }, |
| 174 | + ], |
| 175 | + 'prettier/prettier': [ |
| 176 | + 0, |
| 177 | + { |
| 178 | + singleQuote: true, |
| 179 | + endOfLine: 'auto', |
| 180 | + }, |
| 181 | + ], |
| 182 | + }, |
| 183 | + }, |
| 184 | + { |
| 185 | + files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], |
| 186 | + plugins: { 'testing-library': testingLibrary }, |
| 187 | + rules: { |
| 188 | + ...testingLibrary.configs.react.rules, |
| 189 | + }, |
| 190 | + }, |
| 191 | +]); |
0 commit comments