-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.js
82 lines (78 loc) · 2.04 KB
/
eslint.config.js
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
import js from '@eslint/js';
import globals from 'globals';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
export default [
{
ignores: ['dist/**', 'coverage/**', 'node_modules/**'],
},
js.configs.recommended,
{
files: ['**/*.{js,jsx}'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'react-refresh': reactRefreshPlugin,
},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
// React rules
'react/prop-types': 'error',
'react/jsx-no-target-blank': 'error',
// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// React Refresh rules
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
// General rules
'no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^(React|[A-Z][a-zA-Z]*|[A-Z][a-zA-Z]*Component)$' // Ignore React and component imports
}],
'no-console': process.env.NODE_ENV === 'production'
? ['warn', { allow: ['warn', 'error'] }]
: 'off',
'prefer-const': 'error',
},
},
{
files: ['**/*.test.{js,jsx}', '**/*.spec.{js,jsx}'],
rules: {
'react/prop-types': 'off',
'no-unused-vars': 'off', // Disable unused vars check in test files
},
languageOptions: {
globals: {
...globals.jest,
describe: 'readonly',
it: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
vi: 'readonly',
},
},
},
];