|
| 1 | +import path from 'node:path'; |
| 2 | + |
| 3 | +import typescriptEslintPlugin from '@typescript-eslint/eslint-plugin'; |
| 4 | +import typescriptEslintParser from '@typescript-eslint/parser'; |
| 5 | +import eslintPluginI18nJson from 'eslint-plugin-i18n-json'; |
| 6 | +import jsonPlugin from 'eslint-plugin-json'; |
| 7 | +import reactPlugin from 'eslint-plugin-react'; |
| 8 | +import reactHooksPlugin from 'eslint-plugin-react-hooks'; |
| 9 | +import reactNativePlugin from 'eslint-plugin-react-native'; |
| 10 | +import simpleImportSort from 'eslint-plugin-simple-import-sort'; |
| 11 | +import testingLibraryPlugin from 'eslint-plugin-testing-library'; |
| 12 | +import unicorn from 'eslint-plugin-unicorn'; |
| 13 | +import unusedImports from 'eslint-plugin-unused-imports'; |
| 14 | + |
| 15 | +export default [ |
| 16 | + { |
| 17 | + files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'], |
| 18 | + ignores: ['.expo/**/*'], |
| 19 | + languageOptions: { |
| 20 | + ecmaVersion: 'latest', |
| 21 | + sourceType: 'module', |
| 22 | + parser: typescriptEslintParser, |
| 23 | + parserOptions: { |
| 24 | + ecmaFeatures: { jsx: true }, |
| 25 | + }, |
| 26 | + }, |
| 27 | + plugins: { |
| 28 | + react: reactPlugin, |
| 29 | + 'react-hooks': reactHooksPlugin, |
| 30 | + 'react-native': reactNativePlugin, |
| 31 | + '@typescript-eslint': typescriptEslintPlugin, |
| 32 | + 'unused-imports': unusedImports, |
| 33 | + 'simple-import-sort': simpleImportSort, |
| 34 | + unicorn, |
| 35 | + }, |
| 36 | + rules: { |
| 37 | + 'prettier/prettier': [ |
| 38 | + 0, |
| 39 | + { |
| 40 | + singleQuote: true, |
| 41 | + endOfLine: 'auto', |
| 42 | + }, |
| 43 | + ], |
| 44 | + |
| 45 | + // Core React rules |
| 46 | + 'react/jsx-uses-react': 'error', |
| 47 | + 'react/jsx-uses-vars': 'error', |
| 48 | + 'react/react-in-jsx-scope': 'off', |
| 49 | + |
| 50 | + // React Hooks |
| 51 | + 'react-hooks/rules-of-hooks': 'error', |
| 52 | + 'react-hooks/exhaustive-deps': 'warn', |
| 53 | + |
| 54 | + // React Native specific |
| 55 | + 'react-native/no-unused-styles': 'error', |
| 56 | + 'react-native/split-platform-components': 'warn', |
| 57 | + 'react-native/no-inline-styles': 'warn', |
| 58 | + 'react-native/no-color-literals': 'warn', |
| 59 | + |
| 60 | + // Import management |
| 61 | + 'unused-imports/no-unused-imports': 'error', |
| 62 | + 'simple-import-sort/imports': 'error', |
| 63 | + 'simple-import-sort/exports': 'error', |
| 64 | + |
| 65 | + // File naming convention |
| 66 | + 'unicorn/filename-case': [ |
| 67 | + 'error', |
| 68 | + { |
| 69 | + case: 'kebabCase', |
| 70 | + ignore: ['\\.(ios|android)\\.(js|ts)x?$'], // Ignore platform-specific files |
| 71 | + }, |
| 72 | + ], |
| 73 | + }, |
| 74 | + settings: { |
| 75 | + react: { |
| 76 | + version: 'detect', |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + { |
| 81 | + // JSON configuration |
| 82 | + files: ['**/*.json'], |
| 83 | + processor: jsonPlugin.processors['.json'], |
| 84 | + plugins: { |
| 85 | + json: jsonPlugin, |
| 86 | + 'i18n-json': eslintPluginI18nJson, |
| 87 | + }, |
| 88 | + rules: { |
| 89 | + ...jsonPlugin.configs.recommended.rules, |
| 90 | + 'i18n-json/valid-message-syntax': [ |
| 91 | + 2, |
| 92 | + { |
| 93 | + syntax: path.resolve('./scripts/i18next-syntax-validation.js'), |
| 94 | + }, |
| 95 | + ], |
| 96 | + 'i18n-json/valid-json': 2, |
| 97 | + 'i18n-json/sorted-keys': [ |
| 98 | + 2, |
| 99 | + { |
| 100 | + order: 'asc', |
| 101 | + indentSpaces: 2, |
| 102 | + }, |
| 103 | + ], |
| 104 | + 'i18n-json/identical-keys': [ |
| 105 | + 2, |
| 106 | + { |
| 107 | + filePath: path.resolve('./src/translations/en.json'), |
| 108 | + }, |
| 109 | + ], |
| 110 | + 'prettier/prettier': [ |
| 111 | + 0, |
| 112 | + { |
| 113 | + singleQuote: true, |
| 114 | + endOfLine: 'auto', |
| 115 | + }, |
| 116 | + ], |
| 117 | + }, |
| 118 | + }, |
| 119 | + // Testing Library configuration |
| 120 | + { |
| 121 | + files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], |
| 122 | + plugins: { |
| 123 | + 'testing-library': testingLibraryPlugin, |
| 124 | + }, |
| 125 | + rules: { |
| 126 | + ...testingLibraryPlugin.configs.react.rules, |
| 127 | + // Add any custom testing rules here |
| 128 | + }, |
| 129 | + }, |
| 130 | +]; |
0 commit comments