|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + extends: ['@react-native', 'prettier'], |
| 4 | + parser: '@typescript-eslint/parser', |
| 5 | + parserOptions: { |
| 6 | + ecmaFeatures: { |
| 7 | + jsx: true, |
| 8 | + }, |
| 9 | + ecmaVersion: 2022, |
| 10 | + sourceType: 'module', |
| 11 | + }, |
| 12 | + plugins: [ |
| 13 | + '@typescript-eslint', |
| 14 | + 'react', |
| 15 | + 'react-hooks', |
| 16 | + 'react-native', |
| 17 | + 'prettier', |
| 18 | + ], |
| 19 | + env: { |
| 20 | + 'react-native/react-native': true, |
| 21 | + 'es2022': true, |
| 22 | + 'node': true, |
| 23 | + 'jest': true, |
| 24 | + }, |
| 25 | + rules: { |
| 26 | + // Prettier integration |
| 27 | + 'prettier/prettier': [ |
| 28 | + 'error', |
| 29 | + { |
| 30 | + quoteProps: 'consistent', |
| 31 | + singleQuote: true, |
| 32 | + tabWidth: 2, |
| 33 | + trailingComma: 'es5', |
| 34 | + useTabs: false, |
| 35 | + printWidth: 80, |
| 36 | + semi: true, |
| 37 | + bracketSpacing: true, |
| 38 | + arrowParens: 'avoid', |
| 39 | + endOfLine: 'lf', |
| 40 | + }, |
| 41 | + ], |
| 42 | + |
| 43 | + // React rules |
| 44 | + 'react/react-in-jsx-scope': 'off', |
| 45 | + 'react/prop-types': 'off', |
| 46 | + 'react/display-name': 'off', |
| 47 | + 'react-hooks/rules-of-hooks': 'error', |
| 48 | + 'react-hooks/exhaustive-deps': 'warn', |
| 49 | + |
| 50 | + // TypeScript rules |
| 51 | + '@typescript-eslint/no-unused-vars': [ |
| 52 | + 'error', |
| 53 | + { |
| 54 | + argsIgnorePattern: '^_', |
| 55 | + varsIgnorePattern: '^_', |
| 56 | + caughtErrorsIgnorePattern: '^_', |
| 57 | + }, |
| 58 | + ], |
| 59 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 60 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 61 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 62 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 63 | + |
| 64 | + // General code quality rules |
| 65 | + 'no-console': 'warn', |
| 66 | + 'no-debugger': 'error', |
| 67 | + 'no-var': 'error', |
| 68 | + 'prefer-const': 'error', |
| 69 | + 'prefer-template': 'error', |
| 70 | + 'object-shorthand': 'error', |
| 71 | + 'no-duplicate-imports': 'error', |
| 72 | + 'no-useless-rename': 'error', |
| 73 | + 'no-useless-computed-key': 'error', |
| 74 | + 'no-unneeded-ternary': 'error', |
| 75 | + 'yoda': 'error', |
| 76 | + |
| 77 | + // React Native specific rules |
| 78 | + 'react-native/no-unused-styles': 'error', |
| 79 | + 'react-native/split-platform-components': 'error', |
| 80 | + 'react-native/no-inline-styles': 'warn', |
| 81 | + 'react-native/no-color-literals': 'warn', |
| 82 | + 'react-native/no-raw-text': 'off', // Can be too restrictive for libraries |
| 83 | + }, |
| 84 | + overrides: [ |
| 85 | + { |
| 86 | + files: ['**/__tests__/**/*', '**/*.test.*', '**/*.spec.*'], |
| 87 | + env: { |
| 88 | + jest: true, |
| 89 | + }, |
| 90 | + rules: { |
| 91 | + '@typescript-eslint/no-explicit-any': 'off', |
| 92 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 93 | + 'no-console': 'off', |
| 94 | + }, |
| 95 | + }, |
| 96 | + { |
| 97 | + files: ['**/*.js', '**/*.jsx'], |
| 98 | + rules: { |
| 99 | + '@typescript-eslint/no-var-requires': 'off', |
| 100 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 101 | + }, |
| 102 | + }, |
| 103 | + { |
| 104 | + files: ['example/**/*'], |
| 105 | + rules: { |
| 106 | + 'react-native/no-color-literals': 'off', |
| 107 | + 'react-native/no-unused-styles': 'off', |
| 108 | + 'react-native/no-inline-styles': 'off', |
| 109 | + 'no-duplicate-imports': 'off', |
| 110 | + '@typescript-eslint/no-shadow': 'off', |
| 111 | + '@typescript-eslint/no-unused-vars': 'off', |
| 112 | + '@typescript-eslint/no-explicit-any': 'off', |
| 113 | + 'no-console': 'off', |
| 114 | + }, |
| 115 | + }, |
| 116 | + ], |
| 117 | + settings: { |
| 118 | + react: { |
| 119 | + version: 'detect', |
| 120 | + }, |
| 121 | + }, |
| 122 | + ignorePatterns: [ |
| 123 | + 'node_modules/', |
| 124 | + 'lib/', |
| 125 | + 'android/build/', |
| 126 | + 'ios/build/', |
| 127 | + 'android/generated/', |
| 128 | + 'ios/generated/', |
| 129 | + '*.tgz', |
| 130 | + 'coverage/', |
| 131 | + ], |
| 132 | +}; |
0 commit comments