|
| 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 eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; |
| 8 | +import reactCompiler from 'eslint-plugin-react-compiler'; |
| 9 | +import simpleImportSort from 'eslint-plugin-simple-import-sort'; |
| 10 | +import tailwind from 'eslint-plugin-tailwindcss'; |
| 11 | +import testingLibrary from 'eslint-plugin-testing-library'; |
| 12 | +// eslint-disable-next-line import/no-named-as-default, import/no-named-as-default-member, import/namespace |
| 13 | +import eslintPluginUnicorn from 'eslint-plugin-unicorn'; |
| 14 | +import unusedImports from 'eslint-plugin-unused-imports'; |
| 15 | +import { configs, parser } from 'typescript-eslint'; |
| 16 | + |
| 17 | +const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 18 | + |
| 19 | +export default defineConfig([ |
| 20 | + globalIgnores([ |
| 21 | + 'dist/*', |
| 22 | + 'node_modules', |
| 23 | + '__tests__/', |
| 24 | + 'coverage', |
| 25 | + '.expo', |
| 26 | + '.expo-shared', |
| 27 | + 'android', |
| 28 | + 'ios', |
| 29 | + '.vscode', |
| 30 | + 'docs/', |
| 31 | + 'cli/', |
| 32 | + ]), |
| 33 | + expoConfig, |
| 34 | + eslintPluginPrettierRecommended, |
| 35 | + ...tailwind.configs['flat/recommended'], |
| 36 | + reactCompiler.configs.recommended, |
| 37 | + { |
| 38 | + plugins: { |
| 39 | + 'simple-import-sort': simpleImportSort, |
| 40 | + unicorn: eslintPluginUnicorn, |
| 41 | + 'unused-imports': unusedImports, |
| 42 | + }, |
| 43 | + rules: { |
| 44 | + 'max-params': ['error', 3], |
| 45 | + 'max-lines-per-function': ['error', 70], |
| 46 | + 'tailwindcss/classnames-order': [ |
| 47 | + 'warn', |
| 48 | + { |
| 49 | + officialSorting: true, |
| 50 | + }, |
| 51 | + ], |
| 52 | + 'tailwindcss/no-custom-classname': 'off', |
| 53 | + 'react/display-name': 'off', |
| 54 | + 'react/no-inline-styles': 'off', |
| 55 | + 'react/destructuring-assignment': 'off', |
| 56 | + 'react/require-default-props': 'off', |
| 57 | + 'unicorn/filename-case': [ |
| 58 | + 'error', |
| 59 | + { |
| 60 | + case: 'kebabCase', |
| 61 | + ignore: ['/android', '/ios'], |
| 62 | + }, |
| 63 | + ], |
| 64 | + 'simple-import-sort/imports': 'error', |
| 65 | + 'simple-import-sort/exports': 'error', |
| 66 | + 'unused-imports/no-unused-imports': 'error', |
| 67 | + 'unused-imports/no-unused-vars': [ |
| 68 | + 'error', |
| 69 | + { |
| 70 | + argsIgnorePattern: '^_', |
| 71 | + varsIgnorePattern: '^_', |
| 72 | + caughtErrorsIgnorePattern: '^_', |
| 73 | + }, |
| 74 | + ], |
| 75 | + 'import/prefer-default-export': 'off', |
| 76 | + 'import/no-cycle': ['error', { maxDepth: '∞' }], |
| 77 | + 'prettier/prettier': ['error', { ignores: ['expo-env.d.ts'] }], |
| 78 | + }, |
| 79 | + }, |
| 80 | + { |
| 81 | + files: ['**/*.ts', '**/*.tsx'], |
| 82 | + languageOptions: { |
| 83 | + parser: parser, |
| 84 | + parserOptions: { |
| 85 | + project: './tsconfig.json', |
| 86 | + sourceType: 'module', |
| 87 | + }, |
| 88 | + }, |
| 89 | + rules: { |
| 90 | + ...configs.recommended.rules, |
| 91 | + '@typescript-eslint/comma-dangle': 'off', |
| 92 | + '@typescript-eslint/consistent-type-imports': [ |
| 93 | + 'warn', |
| 94 | + { |
| 95 | + prefer: 'type-imports', |
| 96 | + fixStyle: 'inline-type-imports', |
| 97 | + disallowTypeAnnotations: true, |
| 98 | + }, |
| 99 | + ], |
| 100 | + }, |
| 101 | + }, |
| 102 | + { |
| 103 | + files: ['src/translations/*.json'], |
| 104 | + plugins: { 'i18n-json': i18nJsonPlugin }, |
| 105 | + processor: { |
| 106 | + meta: { name: '.json' }, |
| 107 | + ...i18nJsonPlugin.processors['.json'], |
| 108 | + }, |
| 109 | + rules: { |
| 110 | + ...i18nJsonPlugin.configs.recommended.rules, |
| 111 | + 'i18n-json/valid-message-syntax': [ |
| 112 | + 2, |
| 113 | + { |
| 114 | + syntax: path.resolve( |
| 115 | + __dirname, |
| 116 | + './scripts/i18next-syntax-validation.js' |
| 117 | + ), |
| 118 | + }, |
| 119 | + ], |
| 120 | + 'i18n-json/valid-json': 2, |
| 121 | + 'i18n-json/sorted-keys': [ |
| 122 | + 2, |
| 123 | + { |
| 124 | + order: 'asc', |
| 125 | + indentSpaces: 2, |
| 126 | + }, |
| 127 | + ], |
| 128 | + 'i18n-json/identical-keys': [ |
| 129 | + 2, |
| 130 | + { |
| 131 | + filePath: path.resolve(__dirname, './src/translations/en.json'), |
| 132 | + }, |
| 133 | + ], |
| 134 | + 'prettier/prettier': [ |
| 135 | + 0, |
| 136 | + { |
| 137 | + singleQuote: true, |
| 138 | + endOfLine: 'auto', |
| 139 | + }, |
| 140 | + ], |
| 141 | + }, |
| 142 | + }, |
| 143 | + { |
| 144 | + files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], |
| 145 | + plugins: { 'testing-library': testingLibrary }, |
| 146 | + rules: { |
| 147 | + ...testingLibrary.configs.react.rules, |
| 148 | + }, |
| 149 | + }, |
| 150 | +]); |
0 commit comments