-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheslint.config.js
More file actions
213 lines (200 loc) · 5.6 KB
/
eslint.config.js
File metadata and controls
213 lines (200 loc) · 5.6 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
const path = require('path');
const babelParser = require('@babel/eslint-parser');
const js = require('@eslint/js');
const prettierConfig = require('eslint-config-prettier');
const importPlugin = require('eslint-plugin-import');
const jest = require('eslint-plugin-jest');
const jestDom = require('eslint-plugin-jest-dom');
const prettier = require('eslint-plugin-prettier');
const react = require('eslint-plugin-react');
const reactHooks = require('eslint-plugin-react-hooks');
const testingLibrary = require('eslint-plugin-testing-library');
const globals = require('globals');
module.exports = [
// ESLint recommended
js.configs.recommended,
// Prettier config (disables conflicting rules)
prettierConfig,
// Ignore ESLint config files and Jest setup
{
ignores: ['jest.config.js'],
},
/* PLOP_INJECT_PWA_ESLINT_CONFIG */
// Main configuration
{
files: ['**/*.{js,jsx}'],
languageOptions: {
parser: babelParser,
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
modules: true,
arrowFunctions: true,
restParams: true,
experimentalObjectRestSpread: true,
},
babelOptions: {
configFile: path.join(__dirname, 'babel.config.js'),
},
},
globals: {
...globals.browser,
...globals.node,
...globals.commonjs,
...globals.jest,
...globals.es2015,
// Additional Jest globals
it: 'readonly',
jest: 'readonly',
test: 'readonly',
expect: 'readonly',
describe: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
},
},
plugins: {
react: react,
'react-hooks': reactHooks,
jest: jest,
'testing-library': testingLibrary,
'jest-dom': jestDom,
prettier: prettier,
import: importPlugin,
},
rules: {
// React recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
// React Hooks recommended
...reactHooks.configs.recommended.rules,
// Jest recommended
...jest.configs.recommended.rules,
// Testing Library React
...testingLibrary.configs.react.rules,
// Jest DOM recommended
...jestDom.configs.recommended.rules,
// Import sorting and organization
'import/order': [
'error',
{
groups: [
'builtin', // Node.js built-in modules
'external', // External packages
'internal', // Internal modules (@ prefixed)
'parent', // Parent imports (../)
'sibling', // Sibling imports (./)
'index', // Index imports (./)
],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before',
},
{
pattern: 'react-**',
group: 'external',
position: 'before',
},
{
pattern: '@/jest/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/store/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/services/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/hooks/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/managers/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/routing/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/pages/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/components/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/constants/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/scss/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/assets/**',
group: 'internal',
position: 'before',
},
{
pattern: '@/public/**',
group: 'internal',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'import/no-unresolved': 'error',
'import/named': 'error',
'import/default': 'error',
'import/export': 'error',
// Custom overrides
'prettier/prettier': 'error',
'no-unused-vars': 'warn',
'no-empty': 'warn',
'react/prop-types': 'off',
'react/no-unescaped-entities': 'off',
// Ensure React hooks rules are active
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
settings: {
'import/resolver': {
webpack: {
config: path.join(__dirname, 'buildTools/webpack.common.js'),
},
node: true,
},
'import/internal-regex': '^@/',
react: {
version: 'detect',
},
},
},
];