-
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy patheslint.config.fast.js
More file actions
254 lines (237 loc) · 7.39 KB
/
eslint.config.fast.js
File metadata and controls
254 lines (237 loc) · 7.39 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
244
245
246
247
248
249
250
251
252
253
254
// Fast ESLint config for quick development feedback
// Skips type-aware rules that require TypeScript compilation
const { FlatCompat } = require("@eslint/eslintrc")
const js = require("@eslint/js")
const typescriptParser = require("@typescript-eslint/parser")
const typescriptPlugin = require("@typescript-eslint/eslint-plugin")
const jestPlugin = require("eslint-plugin-jest")
const prettierConfig = require("eslint-config-prettier")
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
})
module.exports = [
// Global ignores (replaces .eslintignore)
{
ignores: [
"lib/**", // Ruby files, not JavaScript
"**/node_modules/**", // Third-party dependencies
"vendor/**", // Vendored dependencies
"spec/**", // Ruby specs, not JavaScript
"package/**/*.js", // Generated/compiled JavaScript from TypeScript
"package/**/*.d.ts" // Generated TypeScript declaration files
]
},
// Global linter options
{
linterOptions: {
reportUnusedDisableDirectives: "error",
reportUnusedInlineConfigs: "error"
}
},
// Base config for all JS files
...compat.extends("airbnb"),
{
languageOptions: {
ecmaVersion: 2020,
sourceType: "module",
globals: {
// Browser globals
window: "readonly",
document: "readonly",
navigator: "readonly",
console: "readonly",
// Node globals
process: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
exports: "readonly",
global: "readonly",
Buffer: "readonly"
}
},
rules: {
// Webpack handles module resolution, not ESLint
"import/no-unresolved": "off",
// Allow importing devDependencies in config/test files
"import/no-extraneous-dependencies": "off",
// TypeScript handles extensions, not needed for JS imports
"import/extensions": "off",
indent: ["error", 2],
// Allow for...of loops - modern JS syntax
"no-restricted-syntax": "off",
// Allow console statements - used for debugging/logging throughout
"no-console": "off"
},
settings: {
react: {
// Suppress "react package not installed" warning
// This project doesn't use React but airbnb config requires react-plugin
version: "999.999.999"
}
}
},
// Jest test files
{
files: ["test/**"],
plugins: {
jest: jestPlugin
},
languageOptions: {
globals: {
...jestPlugin.environments.globals.globals
}
},
rules: {
...jestPlugin.configs.recommended.rules,
...jestPlugin.configs.style.rules,
"global-require": "off",
"jest/prefer-called-with": "error",
"jest/no-conditional-in-test": "error",
"jest/no-test-return-statement": "error",
"jest/prefer-expect-resolves": "error",
"jest/require-to-throw-message": "error",
"jest/require-top-level-describe": "error",
"jest/prefer-hooks-on-top": "error",
"jest/prefer-lowercase-title": [
"error",
{ ignoreTopLevelDescribe: true }
],
"jest/prefer-spy-on": "error",
"jest/prefer-strict-equal": "error",
"jest/prefer-todo": "error"
}
},
// TypeScript files - fast mode without type-aware linting
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: typescriptParser,
parserOptions: {
// No project specified - disables type-aware linting
ecmaVersion: 2020,
sourceType: "module"
}
},
plugins: {
"@typescript-eslint": typescriptPlugin
},
rules: {
...typescriptPlugin.configs.recommended.rules,
// Same rules as main config minus type-aware ones
"import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off",
"import/extensions": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" }
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-undef": "off"
}
},
// Global rule for all TypeScript files in package/
// Suppress require() imports - these are intentional for CommonJS compatibility
// Will be addressed in Phase 3 (breaking changes) - see #708
{
files: ["package/**/*.ts"],
rules: {
"@typescript-eslint/no-require-imports": "off",
"global-require": "off",
"import/no-import-module-exports": "off"
}
},
// Consolidated override for package/config.ts and package/babel/preset.ts
{
files: ["package/babel/preset.ts", "package/config.ts"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"import/order": "off",
"import/newline-after-import": "off",
"import/first": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-useless-escape": "off"
}
},
// configExporter module overrides
{
files: ["package/configExporter/**/*.ts"],
rules: {
"@typescript-eslint/no-use-before-define": "off",
"import/no-dynamic-require": "off",
"class-methods-use-this": "off",
"import/prefer-default-export": "off",
"no-underscore-dangle": "off",
"no-restricted-globals": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},
// Utils module overrides
{
files: [
"package/utils/inliningCss.ts",
"package/utils/errorCodes.ts",
"package/utils/errorHelpers.ts",
"package/utils/pathValidation.ts",
"package/utils/getStyleRule.ts",
"package/utils/helpers.ts",
"package/utils/validateDependencies.ts",
"package/webpackDevServerConfig.ts"
],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"no-useless-escape": "off"
}
},
// Plugins and optimization overrides
{
files: ["package/plugins/**/*.ts", "package/optimization/**/*.ts"],
rules: {
"import/prefer-default-export": "off"
}
},
// Rules, rspack, swc, esbuild, and other modules
{
files: [
"package/index.ts",
"package/rspack/index.ts",
"package/rules/**/*.ts",
"package/swc/index.ts",
"package/esbuild/index.ts",
"package/dev_server.ts",
"package/env.ts"
],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"import/prefer-default-export": "off",
"no-underscore-dangle": "off"
}
},
// Environments module overrides
{
files: ["package/environments/**/*.ts"],
rules: {
"import/prefer-default-export": "off",
"no-underscore-dangle": "off"
}
},
// Type tests are intentionally unused - they test type compatibility
{
files: ["package/**/__type-tests__/**/*.ts"],
rules: {
"@typescript-eslint/no-unused-vars": "off"
}
},
// Note: Type-aware rule overrides from main config (e.g., @typescript-eslint/no-unsafe-*,
// @typescript-eslint/restrict-template-expressions) are intentionally omitted here since
// fast mode doesn't enable type-aware linting (no parserOptions.project specified).
// This keeps fast mode performant while maintaining consistency for non-type-aware rules.
// Prettier config must be last to override other configs
prettierConfig
]