-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
243 lines (229 loc) · 7.93 KB
/
eslint.config.js
File metadata and controls
243 lines (229 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactNativePlugin from 'eslint-plugin-react-native';
import importPlugin from 'eslint-plugin-import';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
export default [
js.configs.recommended,
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
// React Native / Expo globals
__DEV__: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
global: 'readonly',
// Web APIs that are available in React Native
fetch: 'readonly',
FormData: 'readonly',
Headers: 'readonly',
Request: 'readonly',
Response: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
WebSocket: 'readonly',
XMLHttpRequest: 'readonly',
// Timers
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
setImmediate: 'readonly',
clearImmediate: 'readonly',
// Expo specific
expo: 'readonly',
// Metro bundler
require: 'readonly',
module: 'readonly',
exports: 'readonly',
// React Native specific
navigator: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
// Testing globals
jest: 'readonly',
test: 'readonly',
it: 'readonly',
expect: 'readonly',
describe: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescript,
'react': reactPlugin,
'react-hooks': reactHooksPlugin,
'react-native': reactNativePlugin,
'import': importPlugin,
'jsx-a11y': jsxA11yPlugin,
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
},
},
},
rules: {
// TypeScript specific rules
'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
}],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
// React specific rules
'react/react-in-jsx-scope': 'off', // Not needed with React 17+
'react/prop-types': 'off', // Using TypeScript for prop validation
'react/display-name': 'warn',
'react/jsx-key': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-uses-react': 'off', // Not needed with React 17+
'react/jsx-uses-vars': 'error',
'react/no-children-prop': 'error',
'react/no-danger-with-children': 'error',
'react/no-deprecated': 'warn',
'react/no-direct-mutation-state': 'error',
'react/no-find-dom-node': 'error',
'react/no-is-mounted': 'error',
'react/no-render-return-value': 'error',
'react/no-string-refs': 'error',
'react/no-unescaped-entities': 'off', // Common in React Native text
'react/no-unknown-property': 'error',
'react/require-render-return': 'error',
'react/self-closing-comp': 'warn',
// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'off', // Often too strict in React Native
// React Native specific rules
'react-native/no-unused-styles': 'off', // Often incorrectly flags used styles
'react-native/split-platform-components': 'warn',
'react-native/no-inline-styles': 'off', // Often necessary in RN
'react-native/no-color-literals': 'off', // Too restrictive
'react-native/no-raw-text': 'off', // Can be useful but often too strict
'react-native/no-single-element-style-arrays': 'warn',
// Import rules (relaxed)
'import/order': 'off', // Too strict for React Native development
'import/no-unresolved': 'off', // TypeScript handles this
'import/named': 'off', // TypeScript handles this
'import/default': 'off', // TypeScript handles this
'import/no-duplicates': 'off', // Can be useful but often too strict
'import/first': 'off',
'import/newline-after-import': 'off',
// Accessibility rules (relaxed for mobile)
'jsx-a11y/accessible-emoji': 'off',
'jsx-a11y/alt-text': 'off', // Not applicable to React Native
'jsx-a11y/anchor-has-content': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/interactive-supports-focus': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
// General JavaScript/TypeScript rules
'no-console': 'off', // Common in React Native development
'prefer-const': 'warn',
'no-var': 'error',
'no-unused-vars': 'off', // Use TypeScript version instead
'no-undef': 'off', // TypeScript handles this
'no-case-declarations': 'off', // Allow declarations in case blocks
'no-duplicate-case': 'error',
'no-empty': 'warn',
'no-extra-boolean-cast': 'warn',
'no-extra-semi': 'warn',
'no-fallthrough': 'warn',
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-irregular-whitespace': 'warn',
'no-mixed-spaces-and-tabs': 'warn',
'no-redeclare': 'error',
'no-sparse-arrays': 'warn',
'no-unexpected-multiline': 'warn',
'no-unreachable': 'warn',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
// Style rules (disabled for development convenience)
'array-bracket-spacing': 'off',
'brace-style': 'off',
'comma-dangle': 'off',
'comma-spacing': 'off',
'comma-style': 'off',
'computed-property-spacing': 'off',
'eol-last': 'off',
'func-call-spacing': 'off',
'indent': 'off',
'key-spacing': 'off',
'keyword-spacing': 'off',
'no-trailing-spaces': 'off',
'object-curly-spacing': 'off',
'quotes': 'off',
'semi': 'off',
'semi-spacing': 'off',
'space-before-blocks': 'off',
'space-before-function-paren': 'off',
'space-in-parens': 'off',
'space-infix-ops': 'off',
'space-unary-ops': 'off',
},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
}],
},
},
{
files: ['**/*.test.{js,jsx,ts,tsx}', '**/__tests__/**/*.{js,jsx,ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'react-native/no-inline-styles': 'off',
'no-console': 'off',
},
},
{
files: ['metro.config.js', 'babel.config.js', 'jest.config.js'],
languageOptions: {
globals: {
module: 'readonly',
require: 'readonly',
__dirname: 'readonly',
process: 'readonly',
},
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
'import/no-commonjs': 'off',
},
},
];