-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.js
More file actions
198 lines (182 loc) · 7.12 KB
/
Copy patheslint.config.js
File metadata and controls
198 lines (182 loc) · 7.12 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
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* Base ESLint config initially generated by `eslint-config-airbnb-extended` (v2.3.2)
* using the React + Prettier + TypeScript template, then manually adapted for our project.
* Source template:
* https://eslint-airbnb-extended.nishargshah.dev/cli/guide
* https://github.com/NishargShah/eslint-config-airbnb-extended/blob/v2.3.2/packages/create-airbnb-x-config/templates/react/prettier/ts/default/eslint.config.mjs
*/
import { configs, plugins } from 'eslint-config-airbnb-extended';
import { rules as prettierConfigRules } from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
import js from '@eslint/js';
const jsConfig = [
// ESLint Recommended Rules
{
name: 'js/config',
...js.configs.recommended,
},
// Stylistic Plugin
plugins.stylistic,
// Import X Plugin
plugins.importX,
// Airbnb Base Recommended Config
...configs.base.recommended,
];
const reactConfig = [
// React Plugin
plugins.react,
// React Hooks Plugin
plugins.reactHooks,
// React JSX A11y Plugin
plugins.reactA11y,
// Airbnb React Recommended Config
...configs.react.recommended,
];
const typescriptConfig = [
// TypeScript ESLint Plugin
plugins.typescriptEslint,
// Airbnb Base TypeScript Config
...configs.base.typescript,
// Airbnb React TypeScript Config
...configs.react.typescript,
];
const prettierConfig = [
// Prettier Plugin
{
name: 'prettier/plugin/config',
plugins: {
prettier: prettierPlugin,
},
},
// Prettier Config (disable conflicting rules)
{
name: 'prettier/config',
rules: {
...prettierConfigRules,
'prettier/prettier': 'warn',
},
},
];
const projectConfig = [
{
name: 'project/ignores',
ignores: ['dist', 'build', 'coverage'],
},
{
name: 'project/settings',
settings: {
react: {
version: 'detect',
},
// TypeScript import resolver settings
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import-x/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
},
// React Refresh Plugin
{
name: 'project/react-refresh',
files: ['**/*.{jsx,tsx}'],
plugins: {
'react-refresh': reactRefreshPlugin,
},
rules: {
'react-refresh/only-export-components': ['error', { allowConstantExport: true }],
},
},
// React JSX Runtime (prevents "React must be in scope" errors)
{
name: 'project/react-jsx-runtime',
files: ['**/*.{jsx,tsx}'],
rules: {
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off',
},
},
// Custom rules
{
name: 'project/rules',
rules: {
// Code style
curly: 'error',
'no-console': 'off',
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
// React rules
'react/jsx-props-no-spreading': 'off',
'react/require-default-props': 'off',
// Import rules
'import-x/prefer-default-export': 'off',
'import-x/extensions': 'off',
'import-x/no-unresolved': 'off',
'import-x/no-useless-path-segments': 'off',
'import-x/no-cycle': [
'error', // TODO: Re-enable and fix circular dependencies in the codebase
{
maxDepth: Infinity,
ignoreExternal: true,
},
],
'import-x/no-self-import': 'error',
'import-x/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'test/**', // tape, common npm pattern
'tests/**', // also common npm pattern
'spec/**', // mocha, rspec-like pattern
'**/__tests__/**', // jest pattern
'**/__mocks__/**', // jest pattern
'test.{js,jsx,ts,tsx}', // repos with a single test file
'test-*.{js,jsx,ts,tsx}', // repos with multiple top-level test files
'**/*{.,_}{test,spec}.{js,jsx,ts,tsx}', // tests where the extension or filename suffix denotes that it is a test
'**/jest.config.ts', // jest config
'**/jest.setup.ts', // jest setup
'**/prettier.config.js',
'**/vite.config.ts',
'**/eslint.config.js',
],
optionalDependencies: false,
},
],
// ============================================
// Rules disabled to match old .eslintrc.json behavior
// ============================================
// TypeScript rules
'@typescript-eslint/consistent-type-definitions': 'off', // Allow both type and interface
'@typescript-eslint/consistent-indexed-object-style': 'off', // Allow index signatures
'@typescript-eslint/no-unsafe-enum-comparison': 'off', // Allow enum comparisons
'@typescript-eslint/no-unnecessary-type-arguments': 'off', // Allow explicit type arguments
'@typescript-eslint/no-inferrable-types': 'off', // Allow explicit type annotations
'@typescript-eslint/no-unnecessary-type-assertion': 'off', // Allow type assertions
'@typescript-eslint/no-unnecessary-template-expression': 'off', // Allow template expressions
'@typescript-eslint/no-unsafe-function-type': 'off', // Allow Function type
'@typescript-eslint/no-empty-object-type': 'off', // Allow empty interfaces
'@typescript-eslint/array-type': 'off', // Allow both Array<T> and T[]
// Stylistic rules
'@stylistic/spaced-comment': 'off', // Allow comments without spacing
// Arrow function rules
'arrow-body-style': 'off', // Allow block statements in arrow functions
'prefer-arrow-callback': 'off', // Allow function expressions
// Import rules
'import-x/no-rename-default': 'off', // Allow renaming default imports
'import-x/no-duplicates': 'off', // Allow duplicate imports (will be fixed)
// Modern JavaScript rules
'prefer-object-has-own': 'off', // Allow Object.prototype.hasOwnProperty.call()
},
},
];
export default [...jsConfig, ...reactConfig, ...typescriptConfig, ...prettierConfig, ...projectConfig];