@oxlint/migrate 1.32.0 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/oxlint-migrate.d.mts +1 -0
- package/dist/bin/oxlint-migrate.mjs +330 -78
- package/dist/src/index.d.mts +46 -0
- package/dist/src/index.mjs +3 -80
- package/dist/src-MX2M8fZn.mjs +1494 -0
- package/package.json +37 -38
- package/dist/bin/config-loader.mjs +0 -46
- package/dist/bin/project-loader.mjs +0 -16
- package/dist/package.json.mjs +0 -8
- package/dist/src/cleanup.d.ts +0 -2
- package/dist/src/cleanup.mjs +0 -154
- package/dist/src/cleanup.test.d.ts +0 -1
- package/dist/src/constants.d.ts +0 -3
- package/dist/src/constants.mjs +0 -104
- package/dist/src/env_globals.d.ts +0 -16
- package/dist/src/env_globals.mjs +0 -233
- package/dist/src/generated/rules.d.ts +0 -7
- package/dist/src/generated/rules.mjs +0 -697
- package/dist/src/ignorePatterns.d.ts +0 -3
- package/dist/src/ignorePatterns.mjs +0 -20
- package/dist/src/index.d.ts +0 -4
- package/dist/src/jsPlugins.d.ts +0 -3
- package/dist/src/jsPlugins.mjs +0 -52
- package/dist/src/js_plugin_fixes.d.ts +0 -5
- package/dist/src/js_plugin_fixes.mjs +0 -39
- package/dist/src/overrides.d.ts +0 -2
- package/dist/src/overrides.mjs +0 -16
- package/dist/src/plugins_rules.d.ts +0 -13
- package/dist/src/plugins_rules.mjs +0 -251
- package/dist/src/reporter.d.ts +0 -10
- package/dist/src/reporter.mjs +0 -12
- package/dist/src/types.d.ts +0 -39
- package/dist/src/utilities.d.ts +0 -1
- package/dist/src/utilities.mjs +0 -12
- package/dist/src/walker/comments/index.d.ts +0 -2
- package/dist/src/walker/comments/index.mjs +0 -20
- package/dist/src/walker/comments/replaceRuleDirectiveComment.d.ts +0 -2
- package/dist/src/walker/comments/replaceRuleDirectiveComment.mjs +0 -59
- package/dist/src/walker/index.d.ts +0 -10
- package/dist/src/walker/index.mjs +0 -19
- package/dist/src/walker/partialSourceTextLoader.d.ts +0 -10
- package/dist/src/walker/partialSourceTextLoader.mjs +0 -167
- package/dist/src/walker/replaceCommentsInFile.d.ts +0 -2
- package/dist/src/walker/replaceCommentsInFile.mjs +0 -60
|
@@ -0,0 +1,1494 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __export = (all, symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) {
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (symbols) {
|
|
14
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/env_globals.ts
|
|
21
|
+
const ES_VERSIONS = [
|
|
22
|
+
6,
|
|
23
|
+
2016,
|
|
24
|
+
2017,
|
|
25
|
+
2018,
|
|
26
|
+
2019,
|
|
27
|
+
2020,
|
|
28
|
+
2021,
|
|
29
|
+
2022,
|
|
30
|
+
2023,
|
|
31
|
+
2024,
|
|
32
|
+
2025,
|
|
33
|
+
2026
|
|
34
|
+
];
|
|
35
|
+
const OTHER_SUPPORTED_ENVS = [
|
|
36
|
+
"browser",
|
|
37
|
+
"node",
|
|
38
|
+
"shared-node-browser",
|
|
39
|
+
"worker",
|
|
40
|
+
"serviceworker",
|
|
41
|
+
"amd",
|
|
42
|
+
"applescript",
|
|
43
|
+
"astro",
|
|
44
|
+
"atomtest",
|
|
45
|
+
"commonjs",
|
|
46
|
+
"embertest",
|
|
47
|
+
"greasemonkey",
|
|
48
|
+
"jasmine",
|
|
49
|
+
"jest",
|
|
50
|
+
"jquery",
|
|
51
|
+
"meteor",
|
|
52
|
+
"mocha",
|
|
53
|
+
"mongo",
|
|
54
|
+
"nashorn",
|
|
55
|
+
"protractor",
|
|
56
|
+
"prototypejs",
|
|
57
|
+
"phantomjs",
|
|
58
|
+
"shelljs",
|
|
59
|
+
"svelte",
|
|
60
|
+
"webextensions",
|
|
61
|
+
"qunit",
|
|
62
|
+
"vitest",
|
|
63
|
+
"vue"
|
|
64
|
+
];
|
|
65
|
+
const SUPPORTED_ESLINT_PARSERS = ["typescript-eslint/parser"];
|
|
66
|
+
const normalizeGlobValue = (value) => {
|
|
67
|
+
if (value === "readable" || value === "readonly" || value === false) return false;
|
|
68
|
+
if (value === "off") return;
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
71
|
+
const removeGlobalsWithAreCoveredByEnv = (config) => {
|
|
72
|
+
if (config.globals === void 0 || config.env === void 0) return;
|
|
73
|
+
for (const [env, entries] of Object.entries(globals)) if (config.env[env] === true) {
|
|
74
|
+
for (const entry of Object.keys(entries)) if (normalizeGlobValue(config.globals[entry]) === entries[entry]) delete config.globals[entry];
|
|
75
|
+
}
|
|
76
|
+
if (Object.keys(config.globals).length === 0) delete config.globals;
|
|
77
|
+
};
|
|
78
|
+
const transformBoolGlobalToString = (config) => {
|
|
79
|
+
if (config.globals === void 0) return;
|
|
80
|
+
for (const [entry, value] of Object.entries(config.globals)) if (value === false || value === "readable") config.globals[entry] = "readonly";
|
|
81
|
+
else if (value === true || value === "writeable") config.globals[entry] = "writable";
|
|
82
|
+
};
|
|
83
|
+
const THRESHOLD_ENVS = [
|
|
84
|
+
"browser",
|
|
85
|
+
"node",
|
|
86
|
+
"serviceworker",
|
|
87
|
+
"worker"
|
|
88
|
+
];
|
|
89
|
+
const detectEnvironmentByGlobals = (config) => {
|
|
90
|
+
if (config.globals === void 0) return;
|
|
91
|
+
for (const [env, entries] of Object.entries(globals)) {
|
|
92
|
+
if (!env.startsWith("es") && !OTHER_SUPPORTED_ENVS.includes(env)) continue;
|
|
93
|
+
if (env.startsWith("es") && !ES_VERSIONS.includes(parseInt(env.replace(/^es/, "")))) continue;
|
|
94
|
+
let search = Object.keys(entries);
|
|
95
|
+
let matches = search.filter((entry) => entry in config.globals && normalizeGlobValue(config.globals[entry]) === entries[entry]);
|
|
96
|
+
const useThreshold = THRESHOLD_ENVS.includes(env);
|
|
97
|
+
if (useThreshold && matches.length / search.length >= .97 || !useThreshold && matches.length === search.length) {
|
|
98
|
+
if (config.env === void 0) config.env = {};
|
|
99
|
+
config.env[env] = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const transformEnvAndGlobals = (eslintConfig, targetConfig, options) => {
|
|
104
|
+
if (eslintConfig.languageOptions?.parser !== void 0 && eslintConfig.languageOptions?.parser !== null && typeof eslintConfig.languageOptions.parser === "object" && "meta" in eslintConfig.languageOptions.parser && !SUPPORTED_ESLINT_PARSERS.includes(eslintConfig.languageOptions.parser.meta?.name)) options?.reporter?.report("special parser detected: " + eslintConfig.languageOptions.parser.meta?.name);
|
|
105
|
+
if (eslintConfig.languageOptions?.globals !== void 0 && eslintConfig.languageOptions?.globals !== null) {
|
|
106
|
+
if (targetConfig.globals === void 0) targetConfig.globals = {};
|
|
107
|
+
if (options?.merge) {
|
|
108
|
+
for (const [global, globalSetting] of Object.entries(eslintConfig.languageOptions.globals)) if (!(global in targetConfig.globals)) targetConfig.globals[global] = globalSetting;
|
|
109
|
+
} else Object.assign(targetConfig.globals, eslintConfig.languageOptions.globals);
|
|
110
|
+
}
|
|
111
|
+
if (eslintConfig.languageOptions?.ecmaVersion !== void 0) {
|
|
112
|
+
if (eslintConfig.languageOptions.ecmaVersion === "latest") {
|
|
113
|
+
if (targetConfig.env === void 0) targetConfig.env = {};
|
|
114
|
+
const latestVersion = `es${ES_VERSIONS[ES_VERSIONS.length - 1]}`;
|
|
115
|
+
if (!(latestVersion in targetConfig.env)) targetConfig.env[latestVersion] = true;
|
|
116
|
+
} else if (typeof eslintConfig.languageOptions.ecmaVersion === "number" && ES_VERSIONS.includes(eslintConfig.languageOptions.ecmaVersion)) {
|
|
117
|
+
if (targetConfig.env === void 0) targetConfig.env = {};
|
|
118
|
+
const targetVersion = `es${eslintConfig.languageOptions.ecmaVersion}`;
|
|
119
|
+
if (!(targetVersion in targetConfig.env)) targetConfig.env[targetVersion] = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const cleanUpUselessOverridesEnv = (config) => {
|
|
124
|
+
if (config.env === void 0 || config.overrides === void 0) return;
|
|
125
|
+
for (const override of config.overrides) {
|
|
126
|
+
if (override.env === void 0) continue;
|
|
127
|
+
for (const [overrideEnv, overrideEnvConfig] of Object.entries(override.env)) if (overrideEnv in config.env && config.env[overrideEnv] === overrideEnvConfig) delete override.env[overrideEnv];
|
|
128
|
+
if (Object.keys(override.env).length === 0) delete override.env;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const SUPERSET_ENVS = {
|
|
132
|
+
node: [
|
|
133
|
+
"nodeBuiltin",
|
|
134
|
+
"shared-node-browser",
|
|
135
|
+
"commonjs"
|
|
136
|
+
],
|
|
137
|
+
browser: ["shared-node-browser"]
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Cleans up superset environments in the config and its overrides.
|
|
141
|
+
* If a superset environment is present, its subset environments are removed, e.g. all globals from `shared-node-browser` are also in `browser` and `node`.
|
|
142
|
+
*
|
|
143
|
+
* This also applies for overrides, where if a superset env is defined in the override or main config,
|
|
144
|
+
* the subset envs can be removed from the override if the override has the same value as the superset.
|
|
145
|
+
*/
|
|
146
|
+
const cleanUpSupersetEnvs = (config) => {
|
|
147
|
+
if (config.env !== void 0) for (const [supersetEnv, subsetEnvs] of Object.entries(SUPERSET_ENVS)) {
|
|
148
|
+
if (!(supersetEnv in config.env)) continue;
|
|
149
|
+
for (const subsetEnv of subsetEnvs) if (config.env[subsetEnv] === config.env[supersetEnv]) delete config.env[subsetEnv];
|
|
150
|
+
}
|
|
151
|
+
if (config.overrides !== void 0) for (const override of config.overrides) {
|
|
152
|
+
if (override.env === void 0) continue;
|
|
153
|
+
for (const [supersetEnv, subsetEnvs] of Object.entries(SUPERSET_ENVS)) {
|
|
154
|
+
const supersetInOverride = supersetEnv in override.env;
|
|
155
|
+
const supersetInMain = config.env !== void 0 && supersetEnv in config.env;
|
|
156
|
+
for (const subsetEnv of subsetEnvs) {
|
|
157
|
+
if (!(subsetEnv in override.env)) continue;
|
|
158
|
+
if (supersetInOverride && override.env[subsetEnv] === override.env[supersetEnv]) {
|
|
159
|
+
delete override.env[subsetEnv];
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (supersetInMain && !supersetInOverride && config.env[supersetEnv] === override.env[subsetEnv]) delete override.env[subsetEnv];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (Object.keys(override.env).length === 0) delete override.env;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/generated/rules.ts
|
|
171
|
+
var rules_exports = /* @__PURE__ */ __export({
|
|
172
|
+
correctnessRules: () => correctnessRules,
|
|
173
|
+
nurseryRules: () => nurseryRules,
|
|
174
|
+
pedanticRules: () => pedanticRules,
|
|
175
|
+
perfRules: () => perfRules,
|
|
176
|
+
restrictionRules: () => restrictionRules,
|
|
177
|
+
styleRules: () => styleRules,
|
|
178
|
+
suspiciousRules: () => suspiciousRules
|
|
179
|
+
});
|
|
180
|
+
const pedanticRules = [
|
|
181
|
+
"accessor-pairs",
|
|
182
|
+
"array-callback-return",
|
|
183
|
+
"eqeqeq",
|
|
184
|
+
"max-classes-per-file",
|
|
185
|
+
"max-depth",
|
|
186
|
+
"max-lines-per-function",
|
|
187
|
+
"max-lines",
|
|
188
|
+
"max-nested-callbacks",
|
|
189
|
+
"no-inline-comments",
|
|
190
|
+
"no-loop-func",
|
|
191
|
+
"no-array-constructor",
|
|
192
|
+
"no-case-declarations",
|
|
193
|
+
"no-lonely-if",
|
|
194
|
+
"no-object-constructor",
|
|
195
|
+
"no-constructor-return",
|
|
196
|
+
"no-else-return",
|
|
197
|
+
"no-fallthrough",
|
|
198
|
+
"no-inner-declarations",
|
|
199
|
+
"no-negated-condition",
|
|
200
|
+
"no-new-wrappers",
|
|
201
|
+
"no-promise-executor-return",
|
|
202
|
+
"no-prototype-builtins",
|
|
203
|
+
"no-redeclare",
|
|
204
|
+
"no-self-compare",
|
|
205
|
+
"no-throw-literal",
|
|
206
|
+
"no-useless-return",
|
|
207
|
+
"no-warning-comments",
|
|
208
|
+
"radix",
|
|
209
|
+
"require-await",
|
|
210
|
+
"sort-vars",
|
|
211
|
+
"symbol-description",
|
|
212
|
+
"import/max-dependencies",
|
|
213
|
+
"jest/no-conditional-in-test",
|
|
214
|
+
"jsdoc/require-param",
|
|
215
|
+
"jsdoc/require-param-description",
|
|
216
|
+
"jsdoc/require-param-name",
|
|
217
|
+
"jsdoc/require-param-type",
|
|
218
|
+
"jsdoc/require-returns",
|
|
219
|
+
"jsdoc/require-returns-description",
|
|
220
|
+
"jsdoc/require-returns-type",
|
|
221
|
+
"react/checked-requires-onchange-or-readonly",
|
|
222
|
+
"react/jsx-no-target-blank",
|
|
223
|
+
"react/jsx-no-useless-fragment",
|
|
224
|
+
"react/no-unescaped-entities",
|
|
225
|
+
"react-hooks/rules-of-hooks",
|
|
226
|
+
"@typescript-eslint/ban-ts-comment",
|
|
227
|
+
"@typescript-eslint/ban-types",
|
|
228
|
+
"@typescript-eslint/no-misused-promises",
|
|
229
|
+
"@typescript-eslint/no-confusing-void-expression",
|
|
230
|
+
"@typescript-eslint/no-deprecated",
|
|
231
|
+
"@typescript-eslint/no-mixed-enums",
|
|
232
|
+
"@typescript-eslint/no-unsafe-argument",
|
|
233
|
+
"@typescript-eslint/no-unsafe-assignment",
|
|
234
|
+
"@typescript-eslint/no-unsafe-call",
|
|
235
|
+
"@typescript-eslint/no-unsafe-function-type",
|
|
236
|
+
"@typescript-eslint/no-unsafe-member-access",
|
|
237
|
+
"@typescript-eslint/no-unsafe-return",
|
|
238
|
+
"@typescript-eslint/only-throw-error",
|
|
239
|
+
"@typescript-eslint/prefer-enum-initializers",
|
|
240
|
+
"@typescript-eslint/prefer-includes",
|
|
241
|
+
"@typescript-eslint/prefer-nullish-coalescing",
|
|
242
|
+
"@typescript-eslint/prefer-promise-reject-errors",
|
|
243
|
+
"@typescript-eslint/prefer-ts-expect-error",
|
|
244
|
+
"@typescript-eslint/related-getter-setter-pairs",
|
|
245
|
+
"@typescript-eslint/require-await",
|
|
246
|
+
"@typescript-eslint/restrict-plus-operands",
|
|
247
|
+
"@typescript-eslint/return-await",
|
|
248
|
+
"@typescript-eslint/strict-boolean-expressions",
|
|
249
|
+
"@typescript-eslint/switch-exhaustiveness-check",
|
|
250
|
+
"unicorn/consistent-assert",
|
|
251
|
+
"unicorn/consistent-empty-array-spread",
|
|
252
|
+
"unicorn/escape-case",
|
|
253
|
+
"unicorn/explicit-length-check",
|
|
254
|
+
"unicorn/new-for-builtins",
|
|
255
|
+
"unicorn/no-unnecessary-array-splice-count",
|
|
256
|
+
"unicorn/no-array-callback-reference",
|
|
257
|
+
"unicorn/no-unnecessary-array-flat-depth",
|
|
258
|
+
"unicorn/no-unnecessary-slice-end",
|
|
259
|
+
"unicorn/no-hex-escape",
|
|
260
|
+
"unicorn/no-instanceof-array",
|
|
261
|
+
"unicorn/no-lonely-if",
|
|
262
|
+
"unicorn/no-negation-in-equality-check",
|
|
263
|
+
"unicorn/no-new-buffer",
|
|
264
|
+
"unicorn/no-object-as-default-parameter",
|
|
265
|
+
"unicorn/no-static-only-class",
|
|
266
|
+
"unicorn/no-this-assignment",
|
|
267
|
+
"unicorn/no-typeof-undefined",
|
|
268
|
+
"unicorn/no-unreadable-iife",
|
|
269
|
+
"unicorn/no-useless-promise-resolve-reject",
|
|
270
|
+
"unicorn/no-useless-switch-case",
|
|
271
|
+
"unicorn/no-useless-undefined",
|
|
272
|
+
"unicorn/prefer-top-level-await",
|
|
273
|
+
"unicorn/prefer-at",
|
|
274
|
+
"unicorn/prefer-array-flat",
|
|
275
|
+
"unicorn/prefer-array-some",
|
|
276
|
+
"unicorn/prefer-blob-reading-methods",
|
|
277
|
+
"unicorn/prefer-code-point",
|
|
278
|
+
"unicorn/prefer-date-now",
|
|
279
|
+
"unicorn/prefer-dom-node-append",
|
|
280
|
+
"unicorn/prefer-dom-node-dataset",
|
|
281
|
+
"unicorn/prefer-dom-node-remove",
|
|
282
|
+
"unicorn/prefer-event-target",
|
|
283
|
+
"unicorn/prefer-math-min-max",
|
|
284
|
+
"unicorn/prefer-math-trunc",
|
|
285
|
+
"unicorn/prefer-native-coercion-functions",
|
|
286
|
+
"unicorn/prefer-prototype-methods",
|
|
287
|
+
"unicorn/prefer-query-selector",
|
|
288
|
+
"unicorn/prefer-regexp-test",
|
|
289
|
+
"unicorn/prefer-string-replace-all",
|
|
290
|
+
"unicorn/prefer-string-slice",
|
|
291
|
+
"unicorn/prefer-type-error",
|
|
292
|
+
"unicorn/require-number-to-fixed-digits-argument",
|
|
293
|
+
"@typescript-eslint/no-loop-func",
|
|
294
|
+
"@typescript-eslint/no-array-constructor",
|
|
295
|
+
"unicorn/no-negated-condition",
|
|
296
|
+
"@typescript-eslint/no-redeclare",
|
|
297
|
+
"import-x/max-dependencies",
|
|
298
|
+
"vitest/no-conditional-in-test"
|
|
299
|
+
];
|
|
300
|
+
const styleRules = [
|
|
301
|
+
"arrow-body-style",
|
|
302
|
+
"capitalized-comments",
|
|
303
|
+
"curly",
|
|
304
|
+
"default-case-last",
|
|
305
|
+
"default-param-last",
|
|
306
|
+
"func-style",
|
|
307
|
+
"func-names",
|
|
308
|
+
"grouped-accessor-pairs",
|
|
309
|
+
"guard-for-in",
|
|
310
|
+
"id-length",
|
|
311
|
+
"init-declarations",
|
|
312
|
+
"max-params",
|
|
313
|
+
"new-cap",
|
|
314
|
+
"no-implicit-coercion",
|
|
315
|
+
"no-useless-computed-key",
|
|
316
|
+
"no-duplicate-imports",
|
|
317
|
+
"no-extra-label",
|
|
318
|
+
"no-labels",
|
|
319
|
+
"no-lone-blocks",
|
|
320
|
+
"no-multi-assign",
|
|
321
|
+
"no-nested-ternary",
|
|
322
|
+
"no-continue",
|
|
323
|
+
"no-label-var",
|
|
324
|
+
"no-magic-numbers",
|
|
325
|
+
"no-multi-str",
|
|
326
|
+
"no-new-func",
|
|
327
|
+
"no-return-assign",
|
|
328
|
+
"no-script-url",
|
|
329
|
+
"no-template-curly-in-string",
|
|
330
|
+
"no-ternary",
|
|
331
|
+
"operator-assignment",
|
|
332
|
+
"prefer-template",
|
|
333
|
+
"prefer-destructuring",
|
|
334
|
+
"prefer-promise-reject-errors",
|
|
335
|
+
"prefer-exponentiation-operator",
|
|
336
|
+
"prefer-numeric-literals",
|
|
337
|
+
"prefer-object-has-own",
|
|
338
|
+
"prefer-object-spread",
|
|
339
|
+
"prefer-rest-params",
|
|
340
|
+
"prefer-spread",
|
|
341
|
+
"sort-imports",
|
|
342
|
+
"sort-keys",
|
|
343
|
+
"vars-on-top",
|
|
344
|
+
"yoda",
|
|
345
|
+
"import/consistent-type-specifier-style",
|
|
346
|
+
"import/exports-last",
|
|
347
|
+
"import/first",
|
|
348
|
+
"import/group-exports",
|
|
349
|
+
"import/no-named-export",
|
|
350
|
+
"import/no-anonymous-default-export",
|
|
351
|
+
"import/no-mutable-exports",
|
|
352
|
+
"import/no-named-default",
|
|
353
|
+
"import/no-namespace",
|
|
354
|
+
"import/no-duplicates",
|
|
355
|
+
"import/prefer-default-export",
|
|
356
|
+
"jest/consistent-test-it",
|
|
357
|
+
"jest/max-expects",
|
|
358
|
+
"jest/max-nested-describe",
|
|
359
|
+
"jest/no-alias-methods",
|
|
360
|
+
"jest/no-confusing-set-timeout",
|
|
361
|
+
"jest/no-deprecated-functions",
|
|
362
|
+
"jest/no-done-callback",
|
|
363
|
+
"jest/no-duplicate-hooks",
|
|
364
|
+
"jest/no-hooks",
|
|
365
|
+
"jest/no-identical-title",
|
|
366
|
+
"jest/no-interpolation-in-snapshots",
|
|
367
|
+
"jest/no-jasmine-globals",
|
|
368
|
+
"jest/no-large-snapshots",
|
|
369
|
+
"jest/no-mocks-import",
|
|
370
|
+
"jest/no-restricted-jest-methods",
|
|
371
|
+
"jest/no-restricted-matchers",
|
|
372
|
+
"jest/no-test-prefixes",
|
|
373
|
+
"jest/no-test-return-statement",
|
|
374
|
+
"jest/no-untyped-mock-factory",
|
|
375
|
+
"jest/padding-around-test-blocks",
|
|
376
|
+
"jest/prefer-each",
|
|
377
|
+
"jest/prefer-called-with",
|
|
378
|
+
"jest/prefer-comparison-matcher",
|
|
379
|
+
"jest/prefer-equality-matcher",
|
|
380
|
+
"jest/prefer-expect-resolves",
|
|
381
|
+
"jest/prefer-hooks-in-order",
|
|
382
|
+
"jest/prefer-hooks-on-top",
|
|
383
|
+
"jest/prefer-jest-mocked",
|
|
384
|
+
"jest/prefer-lowercase-title",
|
|
385
|
+
"jest/prefer-mock-promise-shorthand",
|
|
386
|
+
"jest/prefer-spy-on",
|
|
387
|
+
"jest/prefer-strict-equal",
|
|
388
|
+
"jest/prefer-to-be",
|
|
389
|
+
"jest/prefer-to-contain",
|
|
390
|
+
"jest/prefer-to-have-been-called",
|
|
391
|
+
"jest/prefer-to-have-been-called-times",
|
|
392
|
+
"jest/prefer-to-have-length",
|
|
393
|
+
"jest/prefer-todo",
|
|
394
|
+
"jest/require-hook",
|
|
395
|
+
"jest/require-top-level-describe",
|
|
396
|
+
"node/no-exports-assign",
|
|
397
|
+
"promise/avoid-new",
|
|
398
|
+
"promise/no-return-wrap",
|
|
399
|
+
"promise/no-nesting",
|
|
400
|
+
"promise/param-names",
|
|
401
|
+
"promise/prefer-catch",
|
|
402
|
+
"promise/prefer-await-to-callbacks",
|
|
403
|
+
"promise/prefer-await-to-then",
|
|
404
|
+
"react/jsx-pascal-case",
|
|
405
|
+
"react/jsx-fragments",
|
|
406
|
+
"react/jsx-boolean-value",
|
|
407
|
+
"react/jsx-curly-brace-presence",
|
|
408
|
+
"react/jsx-handler-names",
|
|
409
|
+
"react/jsx-props-no-spreading",
|
|
410
|
+
"react/no-redundant-should-component-update",
|
|
411
|
+
"react/no-set-state",
|
|
412
|
+
"react/prefer-es6-class",
|
|
413
|
+
"react/self-closing-comp",
|
|
414
|
+
"react/state-in-constructor",
|
|
415
|
+
"@typescript-eslint/adjacent-overload-signatures",
|
|
416
|
+
"@typescript-eslint/array-type",
|
|
417
|
+
"@typescript-eslint/ban-tslint-comment",
|
|
418
|
+
"@typescript-eslint/consistent-generic-constructors",
|
|
419
|
+
"@typescript-eslint/consistent-indexed-object-style",
|
|
420
|
+
"@typescript-eslint/consistent-type-definitions",
|
|
421
|
+
"@typescript-eslint/consistent-type-imports",
|
|
422
|
+
"@typescript-eslint/no-inferrable-types",
|
|
423
|
+
"@typescript-eslint/no-empty-interface",
|
|
424
|
+
"@typescript-eslint/prefer-for-of",
|
|
425
|
+
"@typescript-eslint/prefer-function-type",
|
|
426
|
+
"@typescript-eslint/prefer-namespace-keyword",
|
|
427
|
+
"@typescript-eslint/prefer-reduce-type-parameter",
|
|
428
|
+
"@typescript-eslint/prefer-return-this-type",
|
|
429
|
+
"unicorn/catch-error-name",
|
|
430
|
+
"unicorn/consistent-date-clone",
|
|
431
|
+
"unicorn/consistent-existence-index-check",
|
|
432
|
+
"unicorn/empty-brace-spaces",
|
|
433
|
+
"unicorn/error-message",
|
|
434
|
+
"unicorn/filename-case",
|
|
435
|
+
"unicorn/no-useless-collection-argument",
|
|
436
|
+
"unicorn/no-array-method-this-argument",
|
|
437
|
+
"unicorn/no-await-expression-member",
|
|
438
|
+
"unicorn/no-console-spaces",
|
|
439
|
+
"unicorn/no-nested-ternary",
|
|
440
|
+
"unicorn/no-null",
|
|
441
|
+
"unicorn/no-unreadable-array-destructuring",
|
|
442
|
+
"unicorn/no-zero-fractions",
|
|
443
|
+
"unicorn/number-literal-case",
|
|
444
|
+
"unicorn/numeric-separators-style",
|
|
445
|
+
"unicorn/prefer-classlist-toggle",
|
|
446
|
+
"unicorn/prefer-class-fields",
|
|
447
|
+
"unicorn/prefer-bigint-literals",
|
|
448
|
+
"unicorn/prefer-default-parameters",
|
|
449
|
+
"unicorn/prefer-response-static-json",
|
|
450
|
+
"unicorn/prefer-global-this",
|
|
451
|
+
"unicorn/prefer-keyboard-event-key",
|
|
452
|
+
"unicorn/prefer-object-from-entries",
|
|
453
|
+
"unicorn/prefer-array-index-of",
|
|
454
|
+
"unicorn/prefer-spread",
|
|
455
|
+
"unicorn/prefer-dom-node-text-content",
|
|
456
|
+
"unicorn/prefer-includes",
|
|
457
|
+
"unicorn/prefer-logical-operator-over-ternary",
|
|
458
|
+
"unicorn/prefer-modern-dom-apis",
|
|
459
|
+
"unicorn/prefer-negative-index",
|
|
460
|
+
"unicorn/prefer-optional-catch-binding",
|
|
461
|
+
"unicorn/prefer-reflect-apply",
|
|
462
|
+
"unicorn/prefer-string-raw",
|
|
463
|
+
"unicorn/prefer-string-trim-start-end",
|
|
464
|
+
"unicorn/prefer-structured-clone",
|
|
465
|
+
"unicorn/require-array-join-separator",
|
|
466
|
+
"unicorn/switch-case-braces",
|
|
467
|
+
"unicorn/text-encoding-identifier-case",
|
|
468
|
+
"unicorn/throw-new-error",
|
|
469
|
+
"vitest/no-import-node-test",
|
|
470
|
+
"vitest/prefer-to-be-falsy",
|
|
471
|
+
"vitest/prefer-to-be-object",
|
|
472
|
+
"vitest/prefer-to-be-truthy",
|
|
473
|
+
"vue/define-emits-declaration",
|
|
474
|
+
"vue/define-props-declaration",
|
|
475
|
+
"vue/define-props-destructuring",
|
|
476
|
+
"vue/require-typed-ref",
|
|
477
|
+
"@typescript-eslint/default-param-last",
|
|
478
|
+
"@typescript-eslint/init-declarations",
|
|
479
|
+
"@typescript-eslint/max-params",
|
|
480
|
+
"@typescript-eslint/no-magic-numbers",
|
|
481
|
+
"import-x/consistent-type-specifier-style",
|
|
482
|
+
"import-x/exports-last",
|
|
483
|
+
"import-x/first",
|
|
484
|
+
"import-x/group-exports",
|
|
485
|
+
"import-x/no-named-export",
|
|
486
|
+
"import-x/no-anonymous-default-export",
|
|
487
|
+
"import-x/no-mutable-exports",
|
|
488
|
+
"import-x/no-named-default",
|
|
489
|
+
"import-x/no-namespace",
|
|
490
|
+
"import-x/no-duplicates",
|
|
491
|
+
"import-x/prefer-default-export",
|
|
492
|
+
"vitest/consistent-test-it",
|
|
493
|
+
"vitest/max-expects",
|
|
494
|
+
"vitest/max-nested-describe",
|
|
495
|
+
"vitest/no-alias-methods",
|
|
496
|
+
"vitest/no-duplicate-hooks",
|
|
497
|
+
"vitest/no-hooks",
|
|
498
|
+
"vitest/no-identical-title",
|
|
499
|
+
"vitest/no-interpolation-in-snapshots",
|
|
500
|
+
"vitest/no-large-snapshots",
|
|
501
|
+
"vitest/no-mocks-import",
|
|
502
|
+
"vitest/no-restricted-jest-methods",
|
|
503
|
+
"vitest/no-restricted-matchers",
|
|
504
|
+
"vitest/no-test-prefixes",
|
|
505
|
+
"vitest/no-test-return-statement",
|
|
506
|
+
"vitest/prefer-each",
|
|
507
|
+
"vitest/prefer-called-with",
|
|
508
|
+
"vitest/prefer-comparison-matcher",
|
|
509
|
+
"vitest/prefer-equality-matcher",
|
|
510
|
+
"vitest/prefer-expect-resolves",
|
|
511
|
+
"vitest/prefer-hooks-in-order",
|
|
512
|
+
"vitest/prefer-hooks-on-top",
|
|
513
|
+
"vitest/prefer-lowercase-title",
|
|
514
|
+
"vitest/prefer-mock-promise-shorthand",
|
|
515
|
+
"vitest/prefer-spy-on",
|
|
516
|
+
"vitest/prefer-strict-equal",
|
|
517
|
+
"vitest/prefer-to-be",
|
|
518
|
+
"vitest/prefer-to-contain",
|
|
519
|
+
"vitest/prefer-to-have-length",
|
|
520
|
+
"vitest/prefer-todo",
|
|
521
|
+
"vitest/require-hook",
|
|
522
|
+
"vitest/require-top-level-describe"
|
|
523
|
+
];
|
|
524
|
+
const suspiciousRules = [
|
|
525
|
+
"block-scoped-var",
|
|
526
|
+
"no-extra-bind",
|
|
527
|
+
"no-unneeded-ternary",
|
|
528
|
+
"no-extend-native",
|
|
529
|
+
"no-new",
|
|
530
|
+
"no-unexpected-multiline",
|
|
531
|
+
"no-useless-concat",
|
|
532
|
+
"no-useless-constructor",
|
|
533
|
+
"preserve-caught-error",
|
|
534
|
+
"import/no-unassigned-import",
|
|
535
|
+
"import/no-empty-named-blocks",
|
|
536
|
+
"import/no-absolute-path",
|
|
537
|
+
"import/no-named-as-default",
|
|
538
|
+
"import/no-named-as-default-member",
|
|
539
|
+
"import/no-self-import",
|
|
540
|
+
"jest/no-commented-out-tests",
|
|
541
|
+
"promise/always-return",
|
|
542
|
+
"promise/no-promise-in-callback",
|
|
543
|
+
"promise/no-multiple-resolved",
|
|
544
|
+
"react/iframe-missing-sandbox",
|
|
545
|
+
"react/jsx-no-comment-textnodes",
|
|
546
|
+
"react/jsx-no-script-url",
|
|
547
|
+
"react/no-namespace",
|
|
548
|
+
"react/react-in-jsx-scope",
|
|
549
|
+
"react/style-prop-object",
|
|
550
|
+
"@typescript-eslint/no-confusing-non-null-assertion",
|
|
551
|
+
"@typescript-eslint/no-extraneous-class",
|
|
552
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare",
|
|
553
|
+
"@typescript-eslint/no-unnecessary-template-expression",
|
|
554
|
+
"@typescript-eslint/no-unnecessary-type-arguments",
|
|
555
|
+
"@typescript-eslint/no-unnecessary-type-assertion",
|
|
556
|
+
"@typescript-eslint/no-unnecessary-type-constraint",
|
|
557
|
+
"@typescript-eslint/no-unsafe-enum-comparison",
|
|
558
|
+
"@typescript-eslint/no-unsafe-type-assertion",
|
|
559
|
+
"unicorn/consistent-function-scoping",
|
|
560
|
+
"unicorn/no-array-sort",
|
|
561
|
+
"unicorn/no-array-reverse",
|
|
562
|
+
"unicorn/no-instanceof-builtins",
|
|
563
|
+
"unicorn/no-accessor-recursion",
|
|
564
|
+
"unicorn/prefer-add-event-listener",
|
|
565
|
+
"unicorn/require-module-specifiers",
|
|
566
|
+
"unicorn/require-post-message-target-origin",
|
|
567
|
+
"vue/no-required-prop-with-default",
|
|
568
|
+
"vue/require-default-export",
|
|
569
|
+
"@typescript-eslint/no-useless-constructor",
|
|
570
|
+
"import-x/no-unassigned-import",
|
|
571
|
+
"import-x/no-empty-named-blocks",
|
|
572
|
+
"import-x/no-absolute-path",
|
|
573
|
+
"import-x/no-named-as-default",
|
|
574
|
+
"import-x/no-named-as-default-member",
|
|
575
|
+
"import-x/no-self-import",
|
|
576
|
+
"vitest/no-commented-out-tests"
|
|
577
|
+
];
|
|
578
|
+
const restrictionRules = [
|
|
579
|
+
"class-methods-use-this",
|
|
580
|
+
"default-case",
|
|
581
|
+
"no-alert",
|
|
582
|
+
"no-bitwise",
|
|
583
|
+
"no-param-reassign",
|
|
584
|
+
"no-restricted-imports",
|
|
585
|
+
"no-console",
|
|
586
|
+
"no-div-regex",
|
|
587
|
+
"no-empty-function",
|
|
588
|
+
"no-empty",
|
|
589
|
+
"no-eq-null",
|
|
590
|
+
"no-iterator",
|
|
591
|
+
"no-plusplus",
|
|
592
|
+
"no-proto",
|
|
593
|
+
"no-regex-spaces",
|
|
594
|
+
"no-restricted-globals",
|
|
595
|
+
"no-sequences",
|
|
596
|
+
"no-undefined",
|
|
597
|
+
"no-var",
|
|
598
|
+
"no-void",
|
|
599
|
+
"unicode-bom",
|
|
600
|
+
"import/extensions",
|
|
601
|
+
"import/no-amd",
|
|
602
|
+
"import/no-commonjs",
|
|
603
|
+
"import/no-cycle",
|
|
604
|
+
"import/no-default-export",
|
|
605
|
+
"import/no-dynamic-require",
|
|
606
|
+
"import/no-webpack-loader-syntax",
|
|
607
|
+
"import/unambiguous",
|
|
608
|
+
"jsdoc/check-access",
|
|
609
|
+
"jsdoc/empty-tags",
|
|
610
|
+
"jsx-a11y/anchor-ambiguous-text",
|
|
611
|
+
"node/no-process-env",
|
|
612
|
+
"node/no-new-require",
|
|
613
|
+
"promise/catch-or-return",
|
|
614
|
+
"promise/spec-only",
|
|
615
|
+
"react/button-has-type",
|
|
616
|
+
"react/forbid-dom-props",
|
|
617
|
+
"react/forbid-elements",
|
|
618
|
+
"react/jsx-filename-extension",
|
|
619
|
+
"react/no-danger",
|
|
620
|
+
"react/no-unknown-property",
|
|
621
|
+
"react/only-export-components",
|
|
622
|
+
"@typescript-eslint/explicit-module-boundary-types",
|
|
623
|
+
"@typescript-eslint/explicit-function-return-type",
|
|
624
|
+
"@typescript-eslint/no-dynamic-delete",
|
|
625
|
+
"@typescript-eslint/no-empty-object-type",
|
|
626
|
+
"@typescript-eslint/no-explicit-any",
|
|
627
|
+
"@typescript-eslint/no-import-type-side-effects",
|
|
628
|
+
"@typescript-eslint/no-namespace",
|
|
629
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing",
|
|
630
|
+
"@typescript-eslint/no-non-null-assertion",
|
|
631
|
+
"@typescript-eslint/no-require-imports",
|
|
632
|
+
"@typescript-eslint/no-restricted-types",
|
|
633
|
+
"@typescript-eslint/no-var-requires",
|
|
634
|
+
"@typescript-eslint/non-nullable-type-assertion-style",
|
|
635
|
+
"@typescript-eslint/prefer-literal-enum-member",
|
|
636
|
+
"@typescript-eslint/promise-function-async",
|
|
637
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable",
|
|
638
|
+
"unicorn/no-useless-error-capture-stack-trace",
|
|
639
|
+
"unicorn/no-abusive-eslint-disable",
|
|
640
|
+
"unicorn/no-anonymous-default-export",
|
|
641
|
+
"unicorn/no-array-for-each",
|
|
642
|
+
"unicorn/no-array-reduce",
|
|
643
|
+
"unicorn/no-document-cookie",
|
|
644
|
+
"unicorn/no-length-as-slice-end",
|
|
645
|
+
"unicorn/no-magic-array-flat-depth",
|
|
646
|
+
"unicorn/no-process-exit",
|
|
647
|
+
"unicorn/prefer-modern-math-apis",
|
|
648
|
+
"unicorn/prefer-node-protocol",
|
|
649
|
+
"unicorn/prefer-number-properties",
|
|
650
|
+
"vue/max-props",
|
|
651
|
+
"vue/no-import-compiler-macros",
|
|
652
|
+
"vue/no-multiple-slot-args",
|
|
653
|
+
"@typescript-eslint/class-methods-use-this",
|
|
654
|
+
"@typescript-eslint/no-restricted-imports",
|
|
655
|
+
"@typescript-eslint/no-empty-function",
|
|
656
|
+
"import-x/extensions",
|
|
657
|
+
"import-x/no-amd",
|
|
658
|
+
"import-x/no-commonjs",
|
|
659
|
+
"import-x/no-cycle",
|
|
660
|
+
"import-x/no-default-export",
|
|
661
|
+
"import-x/no-dynamic-require",
|
|
662
|
+
"import-x/no-webpack-loader-syntax",
|
|
663
|
+
"import-x/unambiguous"
|
|
664
|
+
];
|
|
665
|
+
const correctnessRules = [
|
|
666
|
+
"constructor-super",
|
|
667
|
+
"for-direction",
|
|
668
|
+
"no-unassigned-vars",
|
|
669
|
+
"no-async-promise-executor",
|
|
670
|
+
"no-caller",
|
|
671
|
+
"no-class-assign",
|
|
672
|
+
"no-useless-backreference",
|
|
673
|
+
"no-compare-neg-zero",
|
|
674
|
+
"no-cond-assign",
|
|
675
|
+
"no-const-assign",
|
|
676
|
+
"no-constant-binary-expression",
|
|
677
|
+
"no-constant-condition",
|
|
678
|
+
"no-control-regex",
|
|
679
|
+
"no-debugger",
|
|
680
|
+
"no-delete-var",
|
|
681
|
+
"no-dupe-class-members",
|
|
682
|
+
"no-dupe-else-if",
|
|
683
|
+
"no-dupe-keys",
|
|
684
|
+
"no-duplicate-case",
|
|
685
|
+
"no-empty-character-class",
|
|
686
|
+
"no-empty-pattern",
|
|
687
|
+
"no-empty-static-block",
|
|
688
|
+
"no-eval",
|
|
689
|
+
"no-ex-assign",
|
|
690
|
+
"no-extra-boolean-cast",
|
|
691
|
+
"no-func-assign",
|
|
692
|
+
"no-global-assign",
|
|
693
|
+
"no-import-assign",
|
|
694
|
+
"no-invalid-regexp",
|
|
695
|
+
"no-irregular-whitespace",
|
|
696
|
+
"no-loss-of-precision",
|
|
697
|
+
"no-new-native-nonconstructor",
|
|
698
|
+
"no-nonoctal-decimal-escape",
|
|
699
|
+
"no-obj-calls",
|
|
700
|
+
"no-self-assign",
|
|
701
|
+
"no-setter-return",
|
|
702
|
+
"no-shadow-restricted-names",
|
|
703
|
+
"no-sparse-arrays",
|
|
704
|
+
"no-this-before-super",
|
|
705
|
+
"no-unsafe-finally",
|
|
706
|
+
"no-unsafe-negation",
|
|
707
|
+
"no-unsafe-optional-chaining",
|
|
708
|
+
"no-unused-expressions",
|
|
709
|
+
"no-unused-labels",
|
|
710
|
+
"no-unused-private-class-members",
|
|
711
|
+
"no-unused-vars",
|
|
712
|
+
"no-useless-catch",
|
|
713
|
+
"no-useless-escape",
|
|
714
|
+
"no-useless-rename",
|
|
715
|
+
"no-with",
|
|
716
|
+
"require-yield",
|
|
717
|
+
"use-isnan",
|
|
718
|
+
"valid-typeof",
|
|
719
|
+
"import/default",
|
|
720
|
+
"import/namespace",
|
|
721
|
+
"jest/expect-expect",
|
|
722
|
+
"jest/no-conditional-expect",
|
|
723
|
+
"jest/no-disabled-tests",
|
|
724
|
+
"jest/no-export",
|
|
725
|
+
"jest/no-focused-tests",
|
|
726
|
+
"jest/no-standalone-expect",
|
|
727
|
+
"jest/require-to-throw-message",
|
|
728
|
+
"jest/valid-describe-callback",
|
|
729
|
+
"jest/valid-expect",
|
|
730
|
+
"jest/valid-title",
|
|
731
|
+
"jsdoc/check-property-names",
|
|
732
|
+
"jsdoc/check-tag-names",
|
|
733
|
+
"jsdoc/implements-on-classes",
|
|
734
|
+
"jsdoc/no-defaults",
|
|
735
|
+
"jsdoc/require-property",
|
|
736
|
+
"jsdoc/require-property-description",
|
|
737
|
+
"jsdoc/require-property-name",
|
|
738
|
+
"jsdoc/require-property-type",
|
|
739
|
+
"jsdoc/require-yields",
|
|
740
|
+
"jsx-a11y/alt-text",
|
|
741
|
+
"jsx-a11y/anchor-has-content",
|
|
742
|
+
"jsx-a11y/anchor-is-valid",
|
|
743
|
+
"jsx-a11y/aria-activedescendant-has-tabindex",
|
|
744
|
+
"jsx-a11y/aria-props",
|
|
745
|
+
"jsx-a11y/aria-role",
|
|
746
|
+
"jsx-a11y/aria-unsupported-elements",
|
|
747
|
+
"jsx-a11y/autocomplete-valid",
|
|
748
|
+
"jsx-a11y/click-events-have-key-events",
|
|
749
|
+
"jsx-a11y/heading-has-content",
|
|
750
|
+
"jsx-a11y/html-has-lang",
|
|
751
|
+
"jsx-a11y/iframe-has-title",
|
|
752
|
+
"jsx-a11y/img-redundant-alt",
|
|
753
|
+
"jsx-a11y/label-has-associated-control",
|
|
754
|
+
"jsx-a11y/lang",
|
|
755
|
+
"jsx-a11y/media-has-caption",
|
|
756
|
+
"jsx-a11y/mouse-events-have-key-events",
|
|
757
|
+
"jsx-a11y/no-noninteractive-tabindex",
|
|
758
|
+
"jsx-a11y/no-access-key",
|
|
759
|
+
"jsx-a11y/no-aria-hidden-on-focusable",
|
|
760
|
+
"jsx-a11y/no-autofocus",
|
|
761
|
+
"jsx-a11y/no-distracting-elements",
|
|
762
|
+
"jsx-a11y/no-redundant-roles",
|
|
763
|
+
"jsx-a11y/prefer-tag-over-role",
|
|
764
|
+
"jsx-a11y/role-has-required-aria-props",
|
|
765
|
+
"jsx-a11y/role-supports-aria-props",
|
|
766
|
+
"jsx-a11y/scope",
|
|
767
|
+
"jsx-a11y/tabindex-no-positive",
|
|
768
|
+
"@next/next/google-font-display",
|
|
769
|
+
"@next/next/google-font-preconnect",
|
|
770
|
+
"@next/next/inline-script-id",
|
|
771
|
+
"@next/next/next-script-for-ga",
|
|
772
|
+
"@next/next/no-assign-module-variable",
|
|
773
|
+
"@next/next/no-async-client-component",
|
|
774
|
+
"@next/next/no-before-interactive-script-outside-document",
|
|
775
|
+
"@next/next/no-css-tags",
|
|
776
|
+
"@next/next/no-document-import-in-page",
|
|
777
|
+
"@next/next/no-duplicate-head",
|
|
778
|
+
"@next/next/no-head-element",
|
|
779
|
+
"@next/next/no-head-import-in-document",
|
|
780
|
+
"@next/next/no-img-element",
|
|
781
|
+
"@next/next/no-page-custom-font",
|
|
782
|
+
"@next/next/no-script-component-in-head",
|
|
783
|
+
"@next/next/no-styled-jsx-in-document",
|
|
784
|
+
"@next/next/no-sync-scripts",
|
|
785
|
+
"@next/next/no-title-in-document-head",
|
|
786
|
+
"@next/next/no-typos",
|
|
787
|
+
"@next/next/no-unwanted-polyfillio",
|
|
788
|
+
"@next/next/no-html-link-for-pages",
|
|
789
|
+
"promise/no-callback-in-promise",
|
|
790
|
+
"promise/no-new-statics",
|
|
791
|
+
"promise/valid-params",
|
|
792
|
+
"react-hooks/exhaustive-deps",
|
|
793
|
+
"react/forward-ref-uses-ref",
|
|
794
|
+
"react/jsx-key",
|
|
795
|
+
"react/jsx-no-duplicate-props",
|
|
796
|
+
"react/jsx-no-undef",
|
|
797
|
+
"react/jsx-props-no-spread-multi",
|
|
798
|
+
"react/no-children-prop",
|
|
799
|
+
"react/no-danger-with-children",
|
|
800
|
+
"react/no-direct-mutation-state",
|
|
801
|
+
"react/no-find-dom-node",
|
|
802
|
+
"react/no-is-mounted",
|
|
803
|
+
"react/no-render-return-value",
|
|
804
|
+
"react/no-string-refs",
|
|
805
|
+
"react/void-dom-elements-no-children",
|
|
806
|
+
"@typescript-eslint/await-thenable",
|
|
807
|
+
"@typescript-eslint/no-floating-promises",
|
|
808
|
+
"@typescript-eslint/no-array-delete",
|
|
809
|
+
"@typescript-eslint/no-base-to-string",
|
|
810
|
+
"@typescript-eslint/no-duplicate-enum-values",
|
|
811
|
+
"@typescript-eslint/no-duplicate-type-constituents",
|
|
812
|
+
"@typescript-eslint/no-extra-non-null-assertion",
|
|
813
|
+
"@typescript-eslint/no-for-in-array",
|
|
814
|
+
"@typescript-eslint/no-implied-eval",
|
|
815
|
+
"@typescript-eslint/no-meaningless-void-operator",
|
|
816
|
+
"@typescript-eslint/no-misused-new",
|
|
817
|
+
"@typescript-eslint/no-misused-spread",
|
|
818
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain",
|
|
819
|
+
"@typescript-eslint/no-redundant-type-constituents",
|
|
820
|
+
"@typescript-eslint/no-this-alias",
|
|
821
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment",
|
|
822
|
+
"@typescript-eslint/no-unsafe-declaration-merging",
|
|
823
|
+
"@typescript-eslint/no-unsafe-unary-minus",
|
|
824
|
+
"@typescript-eslint/no-useless-empty-export",
|
|
825
|
+
"@typescript-eslint/no-wrapper-object-types",
|
|
826
|
+
"@typescript-eslint/prefer-as-const",
|
|
827
|
+
"@typescript-eslint/require-array-sort-compare",
|
|
828
|
+
"@typescript-eslint/restrict-template-expressions",
|
|
829
|
+
"@typescript-eslint/triple-slash-reference",
|
|
830
|
+
"@typescript-eslint/unbound-method",
|
|
831
|
+
"unicorn/no-invalid-fetch-options",
|
|
832
|
+
"unicorn/no-await-in-promise-methods",
|
|
833
|
+
"unicorn/no-empty-file",
|
|
834
|
+
"unicorn/no-invalid-remove-event-listener",
|
|
835
|
+
"unicorn/no-new-array",
|
|
836
|
+
"unicorn/no-single-promise-in-promise-methods",
|
|
837
|
+
"unicorn/no-thenable",
|
|
838
|
+
"unicorn/no-unnecessary-await",
|
|
839
|
+
"unicorn/no-useless-fallback-in-spread",
|
|
840
|
+
"unicorn/no-useless-length-check",
|
|
841
|
+
"unicorn/no-useless-spread",
|
|
842
|
+
"unicorn/prefer-set-size",
|
|
843
|
+
"unicorn/prefer-string-starts-ends-with",
|
|
844
|
+
"vitest/no-conditional-tests",
|
|
845
|
+
"vitest/require-local-test-context-for-concurrent-snapshots",
|
|
846
|
+
"vue/no-export-in-script-setup",
|
|
847
|
+
"vue/prefer-import-from-vue",
|
|
848
|
+
"vue/valid-define-emits",
|
|
849
|
+
"vue/valid-define-props",
|
|
850
|
+
"@typescript-eslint/no-dupe-class-members",
|
|
851
|
+
"@typescript-eslint/no-loss-of-precision",
|
|
852
|
+
"@typescript-eslint/no-unused-expressions",
|
|
853
|
+
"@typescript-eslint/no-unused-vars",
|
|
854
|
+
"import-x/default",
|
|
855
|
+
"import-x/namespace",
|
|
856
|
+
"vitest/expect-expect",
|
|
857
|
+
"vitest/no-conditional-expect",
|
|
858
|
+
"vitest/no-disabled-tests",
|
|
859
|
+
"vitest/no-focused-tests",
|
|
860
|
+
"vitest/no-standalone-expect",
|
|
861
|
+
"vitest/require-to-throw-message",
|
|
862
|
+
"vitest/valid-describe-callback",
|
|
863
|
+
"vitest/valid-expect"
|
|
864
|
+
];
|
|
865
|
+
const nurseryRules = [
|
|
866
|
+
"getter-return",
|
|
867
|
+
"no-misleading-character-class",
|
|
868
|
+
"no-undef",
|
|
869
|
+
"no-unreachable",
|
|
870
|
+
"import/export",
|
|
871
|
+
"import/named",
|
|
872
|
+
"promise/no-return-in-finally",
|
|
873
|
+
"react/require-render-return",
|
|
874
|
+
"import-x/export",
|
|
875
|
+
"import-x/named"
|
|
876
|
+
];
|
|
877
|
+
const perfRules = [
|
|
878
|
+
"no-await-in-loop",
|
|
879
|
+
"no-useless-call",
|
|
880
|
+
"react/no-array-index-key",
|
|
881
|
+
"react-perf/jsx-no-jsx-as-prop",
|
|
882
|
+
"react-perf/jsx-no-new-array-as-prop",
|
|
883
|
+
"react-perf/jsx-no-new-function-as-prop",
|
|
884
|
+
"react-perf/jsx-no-new-object-as-prop",
|
|
885
|
+
"unicorn/prefer-array-find",
|
|
886
|
+
"unicorn/prefer-array-flat-map",
|
|
887
|
+
"unicorn/prefer-set-has"
|
|
888
|
+
];
|
|
889
|
+
|
|
890
|
+
//#endregion
|
|
891
|
+
//#region src/constants.ts
|
|
892
|
+
const rulesPrefixesForPlugins = {
|
|
893
|
+
import: "import",
|
|
894
|
+
"import-x": "import",
|
|
895
|
+
jest: "jest",
|
|
896
|
+
jsdoc: "jsdoc",
|
|
897
|
+
"jsx-a11y": "jsx-a11y",
|
|
898
|
+
"@next/next": "nextjs",
|
|
899
|
+
node: "node",
|
|
900
|
+
n: "node",
|
|
901
|
+
promise: "promise",
|
|
902
|
+
react: "react",
|
|
903
|
+
"react-perf": "react-perf",
|
|
904
|
+
"react-hooks": "react",
|
|
905
|
+
"@typescript-eslint": "typescript",
|
|
906
|
+
unicorn: "unicorn",
|
|
907
|
+
vitest: "vitest",
|
|
908
|
+
vue: "vue"
|
|
909
|
+
};
|
|
910
|
+
const typescriptRulesExtendEslintRules = [
|
|
911
|
+
"class-methods-use-this",
|
|
912
|
+
"default-param-last",
|
|
913
|
+
"init-declarations",
|
|
914
|
+
"max-params",
|
|
915
|
+
"no-array-constructor",
|
|
916
|
+
"no-dupe-class-members",
|
|
917
|
+
"no-empty-function",
|
|
918
|
+
"no-invalid-this",
|
|
919
|
+
"no-loop-func",
|
|
920
|
+
"no-loss-of-precision",
|
|
921
|
+
"no-magic-numbers",
|
|
922
|
+
"no-redeclare",
|
|
923
|
+
"no-restricted-imports",
|
|
924
|
+
"no-shadow",
|
|
925
|
+
"no-unused-expressions",
|
|
926
|
+
"no-unused-vars",
|
|
927
|
+
"no-use-before-define",
|
|
928
|
+
"no-useless-constructor"
|
|
929
|
+
];
|
|
930
|
+
const typescriptTypeAwareRules = [
|
|
931
|
+
"@typescript-eslint/await-thenable",
|
|
932
|
+
"@typescript-eslint/consistent-return",
|
|
933
|
+
"@typescript-eslint/consistent-type-exports",
|
|
934
|
+
"@typescript-eslint/dot-notation",
|
|
935
|
+
"@typescript-eslint/naming-convention",
|
|
936
|
+
"@typescript-eslint/no-array-delete",
|
|
937
|
+
"@typescript-eslint/no-base-to-string",
|
|
938
|
+
"@typescript-eslint/no-confusing-void-expression",
|
|
939
|
+
"@typescript-eslint/no-deprecated",
|
|
940
|
+
"@typescript-eslint/no-duplicate-type-constituents",
|
|
941
|
+
"@typescript-eslint/no-floating-promises",
|
|
942
|
+
"@typescript-eslint/no-for-in-array",
|
|
943
|
+
"@typescript-eslint/no-implied-eval",
|
|
944
|
+
"@typescript-eslint/no-meaningless-void-operator",
|
|
945
|
+
"@typescript-eslint/no-misused-promises",
|
|
946
|
+
"@typescript-eslint/no-misused-spread",
|
|
947
|
+
"@typescript-eslint/no-mixed-enums",
|
|
948
|
+
"@typescript-eslint/no-redundant-type-constituents",
|
|
949
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare",
|
|
950
|
+
"@typescript-eslint/no-unnecessary-condition",
|
|
951
|
+
"@typescript-eslint/no-unnecessary-qualifier",
|
|
952
|
+
"@typescript-eslint/no-unnecessary-template-expression",
|
|
953
|
+
"@typescript-eslint/no-unnecessary-type-arguments",
|
|
954
|
+
"@typescript-eslint/no-unnecessary-type-assertion",
|
|
955
|
+
"@typescript-eslint/no-unnecessary-type-conversion",
|
|
956
|
+
"@typescript-eslint/no-unnecessary-type-parameters",
|
|
957
|
+
"@typescript-eslint/no-unsafe-argument",
|
|
958
|
+
"@typescript-eslint/no-unsafe-assignment",
|
|
959
|
+
"@typescript-eslint/no-unsafe-call",
|
|
960
|
+
"@typescript-eslint/no-unsafe-enum-comparison",
|
|
961
|
+
"@typescript-eslint/no-unsafe-member-access",
|
|
962
|
+
"@typescript-eslint/no-unsafe-return",
|
|
963
|
+
"@typescript-eslint/no-unsafe-type-assertion",
|
|
964
|
+
"@typescript-eslint/no-unsafe-unary-minus",
|
|
965
|
+
"@typescript-eslint/non-nullable-type-assertion-style",
|
|
966
|
+
"@typescript-eslint/only-throw-error",
|
|
967
|
+
"@typescript-eslint/prefer-destructuring",
|
|
968
|
+
"@typescript-eslint/prefer-find",
|
|
969
|
+
"@typescript-eslint/prefer-includes",
|
|
970
|
+
"@typescript-eslint/prefer-nullish-coalescing",
|
|
971
|
+
"@typescript-eslint/prefer-optional-chain",
|
|
972
|
+
"@typescript-eslint/prefer-promise-reject-errors",
|
|
973
|
+
"@typescript-eslint/prefer-readonly",
|
|
974
|
+
"@typescript-eslint/prefer-readonly-parameter-types",
|
|
975
|
+
"@typescript-eslint/prefer-reduce-type-parameter",
|
|
976
|
+
"@typescript-eslint/prefer-regexp-exec",
|
|
977
|
+
"@typescript-eslint/prefer-return-this-type",
|
|
978
|
+
"@typescript-eslint/prefer-string-starts-ends-with",
|
|
979
|
+
"@typescript-eslint/promise-function-async",
|
|
980
|
+
"@typescript-eslint/related-getter-setter-pairs",
|
|
981
|
+
"@typescript-eslint/require-array-sort-compare",
|
|
982
|
+
"@typescript-eslint/require-await",
|
|
983
|
+
"@typescript-eslint/restrict-plus-operands",
|
|
984
|
+
"@typescript-eslint/restrict-template-expressions",
|
|
985
|
+
"@typescript-eslint/return-await",
|
|
986
|
+
"@typescript-eslint/strict-boolean-expressions",
|
|
987
|
+
"@typescript-eslint/switch-exhaustiveness-check",
|
|
988
|
+
"@typescript-eslint/unbound-method",
|
|
989
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable"
|
|
990
|
+
];
|
|
991
|
+
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region src/jsPlugins.ts
|
|
994
|
+
const ignorePlugins = new Set([
|
|
995
|
+
...Object.keys(rulesPrefixesForPlugins),
|
|
996
|
+
...Object.values(rulesPrefixesForPlugins),
|
|
997
|
+
"local"
|
|
998
|
+
]);
|
|
999
|
+
const guessEslintPluginName = (pluginName) => {
|
|
1000
|
+
if (pluginName.startsWith("@")) {
|
|
1001
|
+
const [scope, maybeSub] = pluginName.split("/");
|
|
1002
|
+
if (maybeSub) return `${scope}/eslint-plugin-${maybeSub}`;
|
|
1003
|
+
return `${scope}/eslint-plugin`;
|
|
1004
|
+
}
|
|
1005
|
+
return `eslint-plugin-${pluginName}`;
|
|
1006
|
+
};
|
|
1007
|
+
const extractPluginId = (ruleId) => {
|
|
1008
|
+
const firstSlash = ruleId.indexOf("/");
|
|
1009
|
+
if (firstSlash === -1) return;
|
|
1010
|
+
if (ruleId.startsWith("@")) {
|
|
1011
|
+
const secondSlash = ruleId.indexOf("/", firstSlash + 1);
|
|
1012
|
+
if (secondSlash !== -1) return ruleId.substring(0, secondSlash);
|
|
1013
|
+
}
|
|
1014
|
+
return ruleId.substring(0, firstSlash);
|
|
1015
|
+
};
|
|
1016
|
+
const isIgnoredPluginRule = (ruleId) => {
|
|
1017
|
+
const pluginName = extractPluginId(ruleId);
|
|
1018
|
+
if (pluginName === void 0) return true;
|
|
1019
|
+
return ignorePlugins.has(pluginName);
|
|
1020
|
+
};
|
|
1021
|
+
const enableJsPluginRule = (targetConfig, rule, ruleEntry) => {
|
|
1022
|
+
const pluginName = extractPluginId(rule);
|
|
1023
|
+
if (pluginName === void 0) return false;
|
|
1024
|
+
if (ignorePlugins.has(pluginName)) return false;
|
|
1025
|
+
if (targetConfig.jsPlugins === void 0) targetConfig.jsPlugins = [];
|
|
1026
|
+
const eslintPluginName = guessEslintPluginName(pluginName);
|
|
1027
|
+
if (!targetConfig.jsPlugins.includes(eslintPluginName)) targetConfig.jsPlugins.push(eslintPluginName);
|
|
1028
|
+
targetConfig.rules = targetConfig.rules || {};
|
|
1029
|
+
targetConfig.rules[rule] = ruleEntry;
|
|
1030
|
+
return true;
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
//#endregion
|
|
1034
|
+
//#region src/plugins_rules.ts
|
|
1035
|
+
const allRules = Object.values(rules_exports).flat();
|
|
1036
|
+
/**
|
|
1037
|
+
* checks if value is validSet, or if validSet is an array, check if value is first value of it
|
|
1038
|
+
*/
|
|
1039
|
+
const isValueInSet = (value, validSet) => validSet.includes(value) || Array.isArray(value) && validSet.includes(value[0]);
|
|
1040
|
+
/**
|
|
1041
|
+
* check if the value is "error", "warn", 1, 2, ["error", ...], ["warn", ...], [1, ...], or [2, ...]
|
|
1042
|
+
*/
|
|
1043
|
+
const isActiveValue = (value) => isValueInSet(value, [
|
|
1044
|
+
"error",
|
|
1045
|
+
"warn",
|
|
1046
|
+
1,
|
|
1047
|
+
2
|
|
1048
|
+
]);
|
|
1049
|
+
const isOffValue = (value) => isValueInSet(value, ["off", 0]);
|
|
1050
|
+
const isWarnValue = (value) => isValueInSet(value, ["warn", 1]);
|
|
1051
|
+
const isErrorValue = (value) => isValueInSet(value, ["error", 2]);
|
|
1052
|
+
const normalizeSeverityValue = (value) => {
|
|
1053
|
+
if (value === void 0) return value;
|
|
1054
|
+
if (isWarnValue(value)) {
|
|
1055
|
+
if (Array.isArray(value)) {
|
|
1056
|
+
value[0] = "warn";
|
|
1057
|
+
return value;
|
|
1058
|
+
}
|
|
1059
|
+
return "warn";
|
|
1060
|
+
} else if (isErrorValue(value)) {
|
|
1061
|
+
if (Array.isArray(value)) {
|
|
1062
|
+
value[0] = "error";
|
|
1063
|
+
return value;
|
|
1064
|
+
}
|
|
1065
|
+
return "error";
|
|
1066
|
+
}
|
|
1067
|
+
if (isOffValue(value)) {
|
|
1068
|
+
if (Array.isArray(value)) {
|
|
1069
|
+
value[0] = "off";
|
|
1070
|
+
return value;
|
|
1071
|
+
}
|
|
1072
|
+
return "off";
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
const transformRuleEntry = (eslintConfig, targetConfig, options) => {
|
|
1076
|
+
if (eslintConfig.rules === void 0) return;
|
|
1077
|
+
if (targetConfig.rules === void 0) targetConfig.rules = {};
|
|
1078
|
+
for (const [rule, config] of Object.entries(eslintConfig.rules)) {
|
|
1079
|
+
const normalizedConfig = normalizeSeverityValue(config);
|
|
1080
|
+
const unsupportedRuleMessage = `unsupported rule: ${rule}`;
|
|
1081
|
+
if (allRules.includes(rule)) {
|
|
1082
|
+
if (!options?.withNursery && nurseryRules.includes(rule)) {
|
|
1083
|
+
options?.reporter?.report(`unsupported rule, but available as a nursery rule: ${rule}`);
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
if (!options?.typeAware && typescriptTypeAwareRules.includes(rule)) {
|
|
1087
|
+
options?.reporter?.report(`type-aware rule detected, but \`--type-aware\` is not enabled: ${rule}`);
|
|
1088
|
+
continue;
|
|
1089
|
+
}
|
|
1090
|
+
if (options?.merge) {
|
|
1091
|
+
if (!(rule in targetConfig.rules)) targetConfig.rules[rule] = normalizedConfig;
|
|
1092
|
+
} else targetConfig.rules[rule] = normalizedConfig;
|
|
1093
|
+
} else {
|
|
1094
|
+
if (options?.jsPlugins) {
|
|
1095
|
+
if (isOffValue(normalizedConfig)) {
|
|
1096
|
+
if (eslintConfig.files === void 0) delete targetConfig.rules[rule];
|
|
1097
|
+
else if (!isIgnoredPluginRule(rule)) targetConfig.rules[rule] = normalizedConfig;
|
|
1098
|
+
if (eslintConfig.files === void 0) options.reporter?.remove(unsupportedRuleMessage);
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1101
|
+
if (enableJsPluginRule(targetConfig, rule, normalizedConfig)) continue;
|
|
1102
|
+
}
|
|
1103
|
+
if (!isActiveValue(normalizedConfig)) {
|
|
1104
|
+
if (isOffValue(normalizedConfig)) delete targetConfig.rules[rule];
|
|
1105
|
+
if (eslintConfig.files === void 0) options?.reporter?.remove(unsupportedRuleMessage);
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
options?.reporter?.report(unsupportedRuleMessage);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
const detectNeededRulesPlugins = (targetConfig) => {
|
|
1113
|
+
if (targetConfig.rules === void 0) return;
|
|
1114
|
+
if (targetConfig.plugins === void 0) targetConfig.plugins = [];
|
|
1115
|
+
for (const rule of Object.keys(targetConfig.rules)) {
|
|
1116
|
+
if (!rule.includes("/")) continue;
|
|
1117
|
+
for (const [prefix, plugin] of Object.entries(rulesPrefixesForPlugins)) if (rule.startsWith(`${prefix}/`) && !targetConfig.plugins.includes(plugin)) targetConfig.plugins.push(plugin);
|
|
1118
|
+
}
|
|
1119
|
+
if ("files" in targetConfig && targetConfig.plugins.length === 0) delete targetConfig.plugins;
|
|
1120
|
+
};
|
|
1121
|
+
const cleanUpUselessOverridesPlugins = (config) => {
|
|
1122
|
+
if (config.overrides === void 0) return;
|
|
1123
|
+
if (config.plugins !== void 0) for (const override of config.overrides) {
|
|
1124
|
+
if (override.plugins === void 0) continue;
|
|
1125
|
+
override.plugins = override.plugins.filter((overridePlugin) => !config.plugins.includes(overridePlugin));
|
|
1126
|
+
if (override.plugins.length === 0) delete override.plugins;
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
const cleanUpUselessOverridesRules = (config) => {
|
|
1130
|
+
if (config.rules === void 0 || config.overrides === void 0) return;
|
|
1131
|
+
const filesPatternMap = /* @__PURE__ */ new Map();
|
|
1132
|
+
for (const [i, override] of config.overrides.entries()) {
|
|
1133
|
+
if (override.files === void 0) continue;
|
|
1134
|
+
const filesKey = JSON.stringify(override.files);
|
|
1135
|
+
let entry = filesPatternMap.get(filesKey);
|
|
1136
|
+
if (!entry) {
|
|
1137
|
+
entry = {
|
|
1138
|
+
firstIndex: i,
|
|
1139
|
+
finalRules: {},
|
|
1140
|
+
indicesToRemove: []
|
|
1141
|
+
};
|
|
1142
|
+
filesPatternMap.set(filesKey, entry);
|
|
1143
|
+
} else entry.indicesToRemove.push(i);
|
|
1144
|
+
if (override.rules) Object.assign(entry.finalRules, override.rules);
|
|
1145
|
+
}
|
|
1146
|
+
for (const entry of filesPatternMap.values()) {
|
|
1147
|
+
const firstOverride = config.overrides[entry.firstIndex];
|
|
1148
|
+
firstOverride.rules = entry.finalRules;
|
|
1149
|
+
if (firstOverride.rules) {
|
|
1150
|
+
for (const [rule, settings] of Object.entries(firstOverride.rules)) if (config.rules[rule] === settings) delete firstOverride.rules[rule];
|
|
1151
|
+
if (Object.keys(firstOverride.rules).length === 0) delete firstOverride.rules;
|
|
1152
|
+
}
|
|
1153
|
+
for (const indexToRemove of entry.indicesToRemove) delete config.overrides[indexToRemove].rules;
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
const cleanUpRulesWhichAreCoveredByCategory = (config) => {
|
|
1157
|
+
if (config.rules === void 0 || config.categories === void 0) return;
|
|
1158
|
+
const enabledCategories = Object.entries(config.categories).filter(([, severity]) => severity === "warn" || severity === "error").map(([category]) => category);
|
|
1159
|
+
for (const [rule, settings] of Object.entries(config.rules)) for (const category of enabledCategories) if (`${category}Rules` in rules_exports && rules_exports[`${category}Rules`].includes(rule)) {
|
|
1160
|
+
if (settings === config.categories[category] || Array.isArray(settings) && settings.length === 1 && settings[0] === config.categories[category]) delete config.rules[rule];
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
const getEnabledCategories = (config) => {
|
|
1164
|
+
if (config.categories === void 0) return ["correctness"];
|
|
1165
|
+
const categories = Object.entries(config.categories).filter(([, severity]) => severity === "warn" || severity === "error").map(([category]) => category);
|
|
1166
|
+
if (Object.keys(config.categories).includes("correctness")) return categories;
|
|
1167
|
+
return [...categories, "correctness"];
|
|
1168
|
+
};
|
|
1169
|
+
const isRuleInEnabledCategory = (rule, enabledCategories) => {
|
|
1170
|
+
for (const category of enabledCategories) if (`${category}Rules` in rules_exports && rules_exports[`${category}Rules`].includes(rule)) return true;
|
|
1171
|
+
return false;
|
|
1172
|
+
};
|
|
1173
|
+
const cleanUpDisabledRootRules = (config) => {
|
|
1174
|
+
if (config.rules === void 0) return;
|
|
1175
|
+
const enabledCategories = getEnabledCategories(config);
|
|
1176
|
+
for (const [rule, settings] of Object.entries(config.rules)) if (isOffValue(settings) && !isRuleInEnabledCategory(rule, enabledCategories)) delete config.rules[rule];
|
|
1177
|
+
};
|
|
1178
|
+
const replaceTypescriptAliasRules = (config) => {
|
|
1179
|
+
if (config.rules === void 0) return;
|
|
1180
|
+
for (const rule of Object.keys(config.rules)) {
|
|
1181
|
+
if (!rule.startsWith("@typescript-eslint/")) continue;
|
|
1182
|
+
const eslintRule = rule.slice(19);
|
|
1183
|
+
if (!typescriptRulesExtendEslintRules.includes(eslintRule)) continue;
|
|
1184
|
+
config.rules[eslintRule] = config.rules[rule];
|
|
1185
|
+
delete config.rules[rule];
|
|
1186
|
+
}
|
|
1187
|
+
if (Object.keys(config.rules).length === 0) delete config.rules;
|
|
1188
|
+
};
|
|
1189
|
+
/**
|
|
1190
|
+
* Oxlint support them only under the node plugin name
|
|
1191
|
+
*/
|
|
1192
|
+
const replaceNodePluginName = (config) => {
|
|
1193
|
+
if (config.rules === void 0) return;
|
|
1194
|
+
for (const rule of Object.keys(config.rules)) {
|
|
1195
|
+
if (!rule.startsWith("n/")) continue;
|
|
1196
|
+
const nodeRule = `node/${rule.slice(2)}`;
|
|
1197
|
+
config.rules[nodeRule] = config.rules[rule];
|
|
1198
|
+
delete config.rules[rule];
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
//#endregion
|
|
1203
|
+
//#region src/utilities.ts
|
|
1204
|
+
const isEqualDeep = (a, b) => {
|
|
1205
|
+
if (a === b) return true;
|
|
1206
|
+
const bothAreObjects = a && b && typeof a === "object" && typeof b === "object";
|
|
1207
|
+
return Boolean(bothAreObjects && Object.keys(a).length === Object.keys(b).length && Object.entries(a).every(([k, v]) => isEqualDeep(v, b[k])));
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region src/cleanup.ts
|
|
1212
|
+
const TS_ESLINT_DEFAULT_OVERRIDE = {
|
|
1213
|
+
files: [
|
|
1214
|
+
"**/*.ts",
|
|
1215
|
+
"**/*.tsx",
|
|
1216
|
+
"**/*.mts",
|
|
1217
|
+
"**/*.cts"
|
|
1218
|
+
],
|
|
1219
|
+
rules: {
|
|
1220
|
+
"no-class-assign": "off",
|
|
1221
|
+
"no-const-assign": "off",
|
|
1222
|
+
"no-dupe-class-members": "off",
|
|
1223
|
+
"no-dupe-keys": "off",
|
|
1224
|
+
"no-func-assign": "off",
|
|
1225
|
+
"no-import-assign": "off",
|
|
1226
|
+
"no-new-native-nonconstructor": "off",
|
|
1227
|
+
"no-obj-calls": "off",
|
|
1228
|
+
"no-redeclare": "off",
|
|
1229
|
+
"no-setter-return": "off",
|
|
1230
|
+
"no-this-before-super": "off",
|
|
1231
|
+
"no-unsafe-negation": "off",
|
|
1232
|
+
"no-var": "error",
|
|
1233
|
+
"prefer-rest-params": "error",
|
|
1234
|
+
"prefer-spread": "error"
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
const cleanUpDefaultTypeScriptOverridesForEslint = (config) => {
|
|
1238
|
+
if (config.overrides === void 0) return;
|
|
1239
|
+
for (const [index, override] of config.overrides.entries()) if (isEqualDeep(override, TS_ESLINT_DEFAULT_OVERRIDE)) delete config.overrides[index];
|
|
1240
|
+
config.overrides = config.overrides.filter((overrides) => Object.keys(overrides).length > 0);
|
|
1241
|
+
if (Object.keys(config.overrides).length === 0) delete config.overrides;
|
|
1242
|
+
};
|
|
1243
|
+
const cleanUpUselessOverridesEntries = (config) => {
|
|
1244
|
+
cleanUpDefaultTypeScriptOverridesForEslint(config);
|
|
1245
|
+
cleanUpUselessOverridesRules(config);
|
|
1246
|
+
cleanUpUselessOverridesPlugins(config);
|
|
1247
|
+
cleanUpUselessOverridesEnv(config);
|
|
1248
|
+
cleanUpSupersetEnvs(config);
|
|
1249
|
+
if (config.overrides === void 0) return;
|
|
1250
|
+
for (const [overrideIndex, override] of config.overrides.entries()) if (Object.keys(override).length === 1) delete config.overrides[overrideIndex];
|
|
1251
|
+
config.overrides = config.overrides.filter((overrides) => Object.keys(overrides).length > 0);
|
|
1252
|
+
mergeConsecutiveIdenticalOverrides(config);
|
|
1253
|
+
mergeConsecutiveOverridesWithDifferingFiles(config);
|
|
1254
|
+
if (config.overrides.length === 0) delete config.overrides;
|
|
1255
|
+
};
|
|
1256
|
+
const cleanUpOxlintConfig = (config) => {
|
|
1257
|
+
removeGlobalsWithAreCoveredByEnv(config);
|
|
1258
|
+
transformBoolGlobalToString(config);
|
|
1259
|
+
replaceTypescriptAliasRules(config);
|
|
1260
|
+
replaceNodePluginName(config);
|
|
1261
|
+
cleanUpRulesWhichAreCoveredByCategory(config);
|
|
1262
|
+
if (config.globals !== void 0 && Object.keys(config.globals).length === 0) delete config.globals;
|
|
1263
|
+
if (config.env !== void 0) {
|
|
1264
|
+
delete config.env.es3;
|
|
1265
|
+
delete config.env.es5;
|
|
1266
|
+
delete config.env.es2015;
|
|
1267
|
+
let detected = false;
|
|
1268
|
+
for (const esVersion of [...ES_VERSIONS].reverse()) if (detected) delete config.env[`es${esVersion}`];
|
|
1269
|
+
else if (config.env[`es${esVersion}`] === true) detected = true;
|
|
1270
|
+
}
|
|
1271
|
+
if (!("files" in config)) {
|
|
1272
|
+
cleanUpUselessOverridesEntries(config);
|
|
1273
|
+
cleanUpDisabledRootRules(config);
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
/**
|
|
1277
|
+
* Merges consecutive identical overrides in the config's overrides array
|
|
1278
|
+
* Merges only if the overrides are directly next to each other
|
|
1279
|
+
* (otherwise they could be overriden in between one another).
|
|
1280
|
+
*
|
|
1281
|
+
* Example:
|
|
1282
|
+
*
|
|
1283
|
+
* ```json
|
|
1284
|
+
* overrides: [
|
|
1285
|
+
* {
|
|
1286
|
+
* "files": [
|
|
1287
|
+
* "*.ts",
|
|
1288
|
+
* "*.tsx",
|
|
1289
|
+
* ],
|
|
1290
|
+
* "plugins": [
|
|
1291
|
+
* "typescript",
|
|
1292
|
+
* ],
|
|
1293
|
+
* },
|
|
1294
|
+
* {
|
|
1295
|
+
* "files": [
|
|
1296
|
+
* "*.ts",
|
|
1297
|
+
* "*.tsx",
|
|
1298
|
+
* ],
|
|
1299
|
+
* "plugins": [
|
|
1300
|
+
* "typescript",
|
|
1301
|
+
* ],
|
|
1302
|
+
* },
|
|
1303
|
+
* ]
|
|
1304
|
+
* ```
|
|
1305
|
+
*/
|
|
1306
|
+
function mergeConsecutiveIdenticalOverrides(config) {
|
|
1307
|
+
if (config.overrides === void 0) return;
|
|
1308
|
+
if (config.overrides.length <= 1) return;
|
|
1309
|
+
const mergedOverrides = [];
|
|
1310
|
+
let i = 0;
|
|
1311
|
+
while (i < config.overrides.length) {
|
|
1312
|
+
const current = config.overrides[i];
|
|
1313
|
+
if (i + 1 < config.overrides.length && isEqualDeep(current, config.overrides[i + 1])) {
|
|
1314
|
+
mergedOverrides.push(current);
|
|
1315
|
+
while (i + 1 < config.overrides.length && isEqualDeep(current, config.overrides[i + 1])) i++;
|
|
1316
|
+
} else mergedOverrides.push(current);
|
|
1317
|
+
i++;
|
|
1318
|
+
}
|
|
1319
|
+
config.overrides = mergedOverrides;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Merge consecutive overrides that have differing files but everything else is identical.
|
|
1323
|
+
*
|
|
1324
|
+
* ```json
|
|
1325
|
+
* "overrides": [
|
|
1326
|
+
* {
|
|
1327
|
+
* "files": [
|
|
1328
|
+
* "*.ts",
|
|
1329
|
+
* ],
|
|
1330
|
+
* "rules": {
|
|
1331
|
+
* "arrow-body-style": "error",
|
|
1332
|
+
* },
|
|
1333
|
+
* },
|
|
1334
|
+
* {
|
|
1335
|
+
* "files": [
|
|
1336
|
+
* "*.mts",
|
|
1337
|
+
* "*.cts",
|
|
1338
|
+
* ],
|
|
1339
|
+
* "rules": {
|
|
1340
|
+
* "arrow-body-style": "error",
|
|
1341
|
+
* },
|
|
1342
|
+
* },
|
|
1343
|
+
* ],
|
|
1344
|
+
* ```
|
|
1345
|
+
*/
|
|
1346
|
+
function mergeConsecutiveOverridesWithDifferingFiles(config) {
|
|
1347
|
+
if (config.overrides === void 0) return;
|
|
1348
|
+
if (config.overrides.length <= 1) return;
|
|
1349
|
+
const mergedOverrides = [];
|
|
1350
|
+
let i = 0;
|
|
1351
|
+
while (i < config.overrides.length) {
|
|
1352
|
+
const current = config.overrides[i];
|
|
1353
|
+
const currentFiles = current.files;
|
|
1354
|
+
const { files: _, ...currentWithoutFiles } = current;
|
|
1355
|
+
let j = i + 1;
|
|
1356
|
+
const filesToMerge = [...currentFiles];
|
|
1357
|
+
while (j < config.overrides.length) {
|
|
1358
|
+
const next = config.overrides[j];
|
|
1359
|
+
const { files: __, ...nextWithoutFiles } = next;
|
|
1360
|
+
if (isEqualDeep(currentWithoutFiles, nextWithoutFiles)) {
|
|
1361
|
+
filesToMerge.push(...next.files);
|
|
1362
|
+
j++;
|
|
1363
|
+
} else break;
|
|
1364
|
+
}
|
|
1365
|
+
if (j > i + 1) {
|
|
1366
|
+
const uniqueFiles = [...new Set(filesToMerge)];
|
|
1367
|
+
mergedOverrides.push({
|
|
1368
|
+
...current,
|
|
1369
|
+
files: uniqueFiles
|
|
1370
|
+
});
|
|
1371
|
+
i = j;
|
|
1372
|
+
} else {
|
|
1373
|
+
mergedOverrides.push(current);
|
|
1374
|
+
i++;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
config.overrides = mergedOverrides;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
//#endregion
|
|
1381
|
+
//#region src/ignorePatterns.ts
|
|
1382
|
+
const transformIgnorePatterns = (eslintConfig, targetConfig, options) => {
|
|
1383
|
+
if (eslintConfig.ignores === void 0) return;
|
|
1384
|
+
if ("files" in targetConfig) {
|
|
1385
|
+
options?.reporter?.report("ignore list inside overrides is not supported");
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
if (targetConfig.ignorePatterns === void 0) targetConfig.ignorePatterns = [];
|
|
1389
|
+
for (const ignores of eslintConfig.ignores) if (!targetConfig.ignorePatterns.includes(ignores)) targetConfig.ignorePatterns.push(ignores);
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region src/overrides.ts
|
|
1394
|
+
const detectSameOverride = (config, override) => {
|
|
1395
|
+
if (config.overrides === void 0) return [true, override];
|
|
1396
|
+
const matchedOverride = config.overrides.find(({ files, categories }) => {
|
|
1397
|
+
return categories === void 0 && isEqualDeep(files, override.files);
|
|
1398
|
+
});
|
|
1399
|
+
if (matchedOverride !== void 0) return [false, matchedOverride];
|
|
1400
|
+
return [true, override];
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
//#endregion
|
|
1404
|
+
//#region src/js_plugin_fixes.ts
|
|
1405
|
+
/**
|
|
1406
|
+
* @link https://github.com/antfu/eslint-config?tab=readme-ov-file#plugins-renaming
|
|
1407
|
+
*/
|
|
1408
|
+
const fixForAntfuEslintConfig = (config) => {
|
|
1409
|
+
if ("renamePlugins" in config && typeof config.renamePlugins === "function") return config.renamePlugins({
|
|
1410
|
+
ts: "@typescript-eslint",
|
|
1411
|
+
test: "vitest",
|
|
1412
|
+
next: "@next/next",
|
|
1413
|
+
style: "@stylistic"
|
|
1414
|
+
});
|
|
1415
|
+
return config;
|
|
1416
|
+
};
|
|
1417
|
+
/**
|
|
1418
|
+
* @link https://github.com/oxc-project/oxlint-migrate/issues/160
|
|
1419
|
+
*/
|
|
1420
|
+
const fixForNextEslintConfig = async () => {
|
|
1421
|
+
if ("Deno" in globalThis || "Bun" in globalThis) return () => {};
|
|
1422
|
+
const Module = await import("module");
|
|
1423
|
+
const mod = Module.default || Module;
|
|
1424
|
+
const originalLoad = mod._load;
|
|
1425
|
+
mod._load = function(request, ...args) {
|
|
1426
|
+
if (request && request.includes("@rushstack/eslint-patch")) return {};
|
|
1427
|
+
return originalLoad.apply(mod, [request, ...args]);
|
|
1428
|
+
};
|
|
1429
|
+
return () => {
|
|
1430
|
+
mod._load = originalLoad;
|
|
1431
|
+
};
|
|
1432
|
+
};
|
|
1433
|
+
function fixForJsPlugins(configs) {
|
|
1434
|
+
return fixForAntfuEslintConfig(configs);
|
|
1435
|
+
}
|
|
1436
|
+
const preFixForJsPlugins = () => {
|
|
1437
|
+
return fixForNextEslintConfig();
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
//#endregion
|
|
1441
|
+
//#region src/index.ts
|
|
1442
|
+
const buildConfig = (configs, oxlintConfig, options) => {
|
|
1443
|
+
if (oxlintConfig === void 0) if (options?.merge) oxlintConfig = {
|
|
1444
|
+
plugins: [
|
|
1445
|
+
"oxc",
|
|
1446
|
+
"typescript",
|
|
1447
|
+
"unicorn",
|
|
1448
|
+
"react"
|
|
1449
|
+
],
|
|
1450
|
+
categories: { correctness: "warn" }
|
|
1451
|
+
};
|
|
1452
|
+
else oxlintConfig = {
|
|
1453
|
+
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
1454
|
+
plugins: [],
|
|
1455
|
+
categories: { correctness: "off" }
|
|
1456
|
+
};
|
|
1457
|
+
if (oxlintConfig.$schema === void 0 && options?.merge) oxlintConfig.$schema = "./node_modules/oxlint/configuration_schema.json";
|
|
1458
|
+
if (oxlintConfig.env?.builtin === void 0) {
|
|
1459
|
+
if (oxlintConfig.env === void 0) oxlintConfig.env = {};
|
|
1460
|
+
oxlintConfig.env.builtin = true;
|
|
1461
|
+
}
|
|
1462
|
+
const overrides = options?.merge ? oxlintConfig.overrides ?? [] : [];
|
|
1463
|
+
for (const config of configs) {
|
|
1464
|
+
if (config.name?.startsWith("oxlint/")) continue;
|
|
1465
|
+
let targetConfig;
|
|
1466
|
+
if (config.files === void 0) targetConfig = oxlintConfig;
|
|
1467
|
+
else {
|
|
1468
|
+
targetConfig = { files: Array.isArray(config.files) ? config.files : [config.files] };
|
|
1469
|
+
const [push, result] = detectSameOverride(oxlintConfig, targetConfig);
|
|
1470
|
+
if (push) overrides.push(result);
|
|
1471
|
+
}
|
|
1472
|
+
transformIgnorePatterns(config, targetConfig, options);
|
|
1473
|
+
transformRuleEntry(config, targetConfig, options);
|
|
1474
|
+
transformEnvAndGlobals(config, targetConfig, options);
|
|
1475
|
+
if ("files" in targetConfig) {
|
|
1476
|
+
detectNeededRulesPlugins(targetConfig);
|
|
1477
|
+
detectEnvironmentByGlobals(targetConfig);
|
|
1478
|
+
cleanUpOxlintConfig(targetConfig);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
oxlintConfig.overrides = overrides;
|
|
1482
|
+
detectNeededRulesPlugins(oxlintConfig);
|
|
1483
|
+
detectEnvironmentByGlobals(oxlintConfig);
|
|
1484
|
+
cleanUpOxlintConfig(oxlintConfig);
|
|
1485
|
+
return oxlintConfig;
|
|
1486
|
+
};
|
|
1487
|
+
const main = async (configs, oxlintConfig, options) => {
|
|
1488
|
+
const resolved = await Promise.resolve(fixForJsPlugins(configs));
|
|
1489
|
+
return buildConfig(Array.isArray(resolved) ? resolved : [resolved], oxlintConfig, options);
|
|
1490
|
+
};
|
|
1491
|
+
var src_default = main;
|
|
1492
|
+
|
|
1493
|
+
//#endregion
|
|
1494
|
+
export { rules_exports as i, preFixForJsPlugins as n, nurseryRules as r, src_default as t };
|