-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
302 lines (301 loc) · 10.8 KB
/
eslint.config.js
File metadata and controls
302 lines (301 loc) · 10.8 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
import globals from "globals";
// import tseslint from 'typescript-eslint'; // No longer need the combined import
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import eslintPluginN from "eslint-plugin-n";
import eslintPluginUnicorn from "eslint-plugin-unicorn";
import eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginPrettier from "eslint-plugin-prettier";
import eslint from "@eslint/js"; // Import base eslint config
import vitest from '@vitest/eslint-plugin'
import eslintPluginReact from "eslint-plugin-react"
import eslintPluginReactHooks from "eslint-plugin-react-hooks"
import { fixupPluginRules } from "@eslint/compat"
export default [
{
// Globally ignores files
ignores: [
"**/dist/**",
"**/lib/**",
"**/node_modules/**",
"**/coverage/**",
"*.config.js",
"examples/**", // Ignore all files in examples directory
"docs/workplans/resources/**", // Ignore resource TSX used for documentation
"oclif.manifest.json",
"**/tmp/**",
"**/.nyc_output/**",
"**/tsconfig.tsbuildinfo",
"**/*.d.ts",
"scripts/postinstall-welcome.ts",
"node_modules/xterm/**",
"packages/react-web-cli/dist/index.js",
"packages/react-web-cli/dist/index.mjs",
"bin/", // Added from .eslintrc.cjs
"playwright-report/**", // Ignore Playwright report files
"**/vitest.config.ts",
".claude/worktrees/**",
".claude/skills/**"
], // Updated to match all ignorePatterns from .eslintrc.json
},
{
// Base configuration for all JS/TS files
files: ["**/*.{js,mjs,cjs,ts,tsx}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.node, // Use Node.js globals
// Add NodeJS global for scripts that might need it (though prefer importing types)
NodeJS: "readonly",
},
},
plugins: {
n: eslintPluginN,
unicorn: eslintPluginUnicorn,
prettier: eslintPluginPrettier,
},
rules: {
// Base ESLint recommended rules
...eslint.configs.recommended.rules,
// Node plugin recommended rules
...eslintPluginN.configs["flat/recommended-module"].rules,
// Unicorn plugin recommended rules
...eslintPluginUnicorn.configs.recommended.rules,
// Disable noisy stylistic rules for now
"unicorn/no-null": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-for-loop": "off",
"unicorn/prefer-string-raw": "off",
"unicorn/no-object-as-default-parameter": "off",
"unicorn/import-style": "off",
"unicorn/prefer-ternary": "off",
// Rules from .eslintrc.json
"unicorn/no-process-exit": "off",
"n/no-process-exit": "off",
"n/no-unsupported-features/node-builtins": "off",
// Prettier
"prettier/prettier": "error",
},
},
{
// Configuration specific to TypeScript files
files: ["**/*.ts"],
plugins: {
"@typescript-eslint": tsPlugin, // Use the imported plugin object
},
languageOptions: {
parser: tsParser, // Use the imported parser object
parserOptions: {
project: "./tsconfig.eslint.json",
},
},
rules: {
// Use type-checked rules — requires parserOptions.project above
...tsPlugin.configs["recommended-type-checked"].rules,
// Your custom rules from .eslintrc.json
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// no-unsafe-* and no-base-to-string: enabled in src/, disabled in test/ (mock typing)
// Cherry-picked from strict-type-checked
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-deprecated": "warn",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/unified-signatures": "error",
"@typescript-eslint/return-await": "error",
// Add other TS specific rules or overrides here
"unicorn/prefer-module": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/numeric-separators-style": "off",
},
},
{
// Configuration for React Web CLI package - TSX files
files: ["packages/react-web-cli/**/*.{ts,tsx}"],
plugins: {
react: fixupPluginRules(eslintPluginReact),
"react-hooks": fixupPluginRules(eslintPluginReactHooks),
"@typescript-eslint": tsPlugin,
},
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.browser,
},
},
settings: {
react: {
version: "detect",
},
},
rules: {
// React recommended rules
...eslintPluginReact.configs.recommended.rules,
...eslintPluginReact.configs["jsx-runtime"].rules,
// TypeScript rules (type-checked for full safety)
...tsPlugin.configs["recommended-type-checked"].rules,
// React hooks rules
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
// Custom overrides for this package
"unicorn/prefer-module": "off",
"unicorn/filename-case": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/no-array-reduce": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-deprecated": "warn",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/unified-signatures": "error",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/consistent-type-imports": "error",
"no-console": ["error", { allow: ["warn", "error"] }],
"no-control-regex": "off", // Terminal escape sequences use control chars
"n/no-missing-import": "off", // TSX imports are handled by TypeScript
"react/prop-types": "off", // Using TypeScript for prop validation
"react/react-in-jsx-scope": "off", // Not needed in React 17+
},
},
{
// Configuration specific to test files
files: ["test/**/*.test.ts"],
plugins: {
vitest: vitest,
},
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
},
rules: {
// Apply recommended vitest rules
...vitest.configs.recommended.rules,
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-expressions": "off",
// Tests legitimately use `any` for mocking — disable no-unsafe-* family
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
"vitest/no-focused-tests": "error", // Equivalent to mocha/no-exclusive-tests
"vitest/no-disabled-tests": "warn", // Equivalent to mocha/no-skipped-tests
},
},
{
// Configuration specific to test files
files: ["packages/react-web-cli/**/*.test.ts", "packages/react-web-cli/**/*.test.tsx"],
plugins: {
vitest: vitest,
},
languageOptions: {
globals: {
...vitest.environments.env.globals,
...globals.browser,
},
},
rules: {
// Apply recommended vitest rules
...vitest.configs.recommended.rules,
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
// Tests legitimately use `any` for mocking
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-base-to-string": "off",
"no-console": "off",
"vitest/no-focused-tests": "error", // Equivalent to mocha/no-exclusive-tests
"vitest/no-disabled-tests": "warn", // Equivalent to mocha/no-skipped-tests
},
},
{
// Configuration specific to server test files
files: ["server/tests/**/*.test.ts"],
plugins: {
vitest: vitest,
},
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
},
rules: {
// Apply recommended vitest rules
...vitest.configs.recommended.rules,
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-expressions": "off",
"vitest/no-focused-tests": "error", // Equivalent to mocha/no-exclusive-tests
"vitest/no-disabled-tests": "warn", // Equivalent to mocha/no-skipped-tests
"unicorn/prefer-optional-catch-binding": "off", // Allow catch (error) in tests
"n/no-unpublished-import": "off", // Allow dev dependencies like chai in tests
},
},
// Prettier config must be last
eslintConfigPrettier,
{
// All test and test-helper files: disable no-unsafe-* rules (tests legitimately use `any` for mocking)
files: ["test/**/*.ts"],
rules: {
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
},
},
{
// Playwright browser E2E tests – allow browser globals and silence node-specific rules
files: ["test/e2e/**/*.ts"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
"unicorn/prefer-global-this": "off",
"no-undef": "off",
"unicorn/prefer-optional-catch-binding": "off",
"unicorn/catch-error-name": "off",
"n/no-missing-import": "off",
},
},
];