@oxlint/migrate 1.55.0 → 1.57.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/README.md +1 -5
- package/dist/bin/oxlint-migrate.mjs +2 -2
- package/dist/src/index.d.mts +699 -32
- package/dist/src/index.mjs +1 -1
- package/dist/{src-DJ9UxHkF.mjs → src-DEzNNXJD.mjs} +45 -18
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -114,8 +114,4 @@ Depending on how this is implemented by the given config, these behaviors may no
|
|
|
114
114
|
|
|
115
115
|
The JS Plugins API supports almost all ESLint v9+ plugins for linting JS/TS/JSX/TSX files, but there are still some minor holes in support. See the [JS Plugins documentation](https://oxc.rs/docs/guide/usage/linter/js-plugins.html) for specifics.
|
|
116
116
|
|
|
117
|
-
For example, if you currently use `eslint-plugin-
|
|
118
|
-
|
|
119
|
-
You could also consider [replacing Prettier with Oxfmt](https://oxc.rs/docs/guide/usage/formatter/migrate-from-prettier.html).
|
|
120
|
-
|
|
121
|
-
Note that `eslint-config-prettier` is different from the prettier plugin, and _will_ be migrated fine, as it's just a config to disable formatting-related ESLint rules, not an actual plugin.
|
|
117
|
+
For example, if you currently use `eslint-plugin-svelte`, only some of its rules will work via JS Plugin, as Oxlint does not yet fully support custom file formats like `.svelte`. This means that Oxlint will only be able to lint the script blocks in your `.svelte` files, and not the template blocks where many of the `eslint-plugin-svelte` rules apply.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as nurseryRules, i as buildUnsupportedRuleExplanations, n as preFixForJsPlugins, o as rules_exports, r as isOffValue, t as main } from "../src-
|
|
2
|
+
import { a as nurseryRules, i as buildUnsupportedRuleExplanations, n as preFixForJsPlugins, o as rules_exports, r as isOffValue, t as main } from "../src-DEzNNXJD.mjs";
|
|
3
3
|
import { program } from "commander";
|
|
4
4
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -30,7 +30,7 @@ const loadESLintConfig = async (filePath) => {
|
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region package.json
|
|
33
|
-
var version = "1.
|
|
33
|
+
var version = "1.57.0";
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/walker/comments/replaceRuleDirectiveComment.ts
|
|
36
36
|
const allRules = Object.values(rules_exports).flat();
|
package/dist/src/index.d.mts
CHANGED
|
@@ -1,3 +1,698 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/oxlint@1.57.0_oxlint-tsgolint@0.17.1/node_modules/oxlint/dist/index.d.ts
|
|
2
|
+
//#region src-js/package/config.generated.d.ts
|
|
3
|
+
type AllowWarnDeny = ("allow" | "off" | "warn" | "error" | "deny") | number;
|
|
4
|
+
type GlobalValue = "readonly" | "writable" | "off";
|
|
5
|
+
type ExternalPluginEntry = string | {
|
|
6
|
+
/**
|
|
7
|
+
* Custom name/alias for the plugin.
|
|
8
|
+
*
|
|
9
|
+
* Note: The following plugin names are reserved because they are implemented natively in Rust within oxlint and cannot be used for JS plugins:
|
|
10
|
+
* - react (includes react-hooks)
|
|
11
|
+
* - unicorn
|
|
12
|
+
* - typescript (includes @typescript-eslint)
|
|
13
|
+
* - oxc
|
|
14
|
+
* - import (includes import-x)
|
|
15
|
+
* - jsdoc
|
|
16
|
+
* - jest
|
|
17
|
+
* - vitest
|
|
18
|
+
* - jsx-a11y
|
|
19
|
+
* - nextjs
|
|
20
|
+
* - react-perf
|
|
21
|
+
* - promise
|
|
22
|
+
* - node
|
|
23
|
+
* - vue
|
|
24
|
+
* - eslint
|
|
25
|
+
*
|
|
26
|
+
* If you need to use the JavaScript version of any of these plugins, provide a custom alias to avoid conflicts.
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* Path or package name of the plugin
|
|
31
|
+
*/
|
|
32
|
+
specifier: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A set of glob patterns.
|
|
36
|
+
*/
|
|
37
|
+
type GlobSet = string[];
|
|
38
|
+
type LintPluginOptionsSchema = "eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue";
|
|
39
|
+
type LintPlugins = LintPluginOptionsSchema[];
|
|
40
|
+
type DummyRule = AllowWarnDeny | unknown[];
|
|
41
|
+
type OxlintOverrides = OxlintOverride[];
|
|
42
|
+
type TagNamePreference = string | {
|
|
43
|
+
message: string;
|
|
44
|
+
replacement: string;
|
|
45
|
+
[k: string]: unknown;
|
|
46
|
+
} | {
|
|
47
|
+
message: string;
|
|
48
|
+
[k: string]: unknown;
|
|
49
|
+
} | boolean;
|
|
50
|
+
type OneOrManyFor_String = string | string[];
|
|
51
|
+
type CustomComponent = string | {
|
|
52
|
+
attribute: string;
|
|
53
|
+
name: string;
|
|
54
|
+
[k: string]: unknown;
|
|
55
|
+
} | {
|
|
56
|
+
attributes: string[];
|
|
57
|
+
name: string;
|
|
58
|
+
[k: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Oxlint Configuration File
|
|
62
|
+
*
|
|
63
|
+
* This configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).
|
|
64
|
+
*
|
|
65
|
+
* Usage: `oxlint -c oxlintrc.json`
|
|
66
|
+
*
|
|
67
|
+
* Example
|
|
68
|
+
*
|
|
69
|
+
* `.oxlintrc.json`
|
|
70
|
+
*
|
|
71
|
+
* ```json
|
|
72
|
+
* {
|
|
73
|
+
* "$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
74
|
+
* "plugins": [
|
|
75
|
+
* "import",
|
|
76
|
+
* "typescript",
|
|
77
|
+
* "unicorn"
|
|
78
|
+
* ],
|
|
79
|
+
* "env": {
|
|
80
|
+
* "browser": true
|
|
81
|
+
* },
|
|
82
|
+
* "globals": {
|
|
83
|
+
* "foo": "readonly"
|
|
84
|
+
* },
|
|
85
|
+
* "settings": {
|
|
86
|
+
* "react": {
|
|
87
|
+
* "version": "18.2.0"
|
|
88
|
+
* },
|
|
89
|
+
* "custom": {
|
|
90
|
+
* "option": true
|
|
91
|
+
* }
|
|
92
|
+
* },
|
|
93
|
+
* "rules": {
|
|
94
|
+
* "eqeqeq": "warn",
|
|
95
|
+
* "import/no-cycle": "error",
|
|
96
|
+
* "react/self-closing-comp": [
|
|
97
|
+
* "error",
|
|
98
|
+
* {
|
|
99
|
+
* "html": false
|
|
100
|
+
* }
|
|
101
|
+
* ]
|
|
102
|
+
* },
|
|
103
|
+
* "overrides": [
|
|
104
|
+
* {
|
|
105
|
+
* "files": [
|
|
106
|
+
* "*.test.ts",
|
|
107
|
+
* "*.spec.ts"
|
|
108
|
+
* ],
|
|
109
|
+
* "rules": {
|
|
110
|
+
* "@typescript-eslint/no-explicit-any": "off"
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
* ]
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* `oxlint.config.ts`
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { defineConfig } from "oxlint";
|
|
121
|
+
*
|
|
122
|
+
* export default defineConfig({
|
|
123
|
+
* plugins: ["import", "typescript", "unicorn"],
|
|
124
|
+
* env: {
|
|
125
|
+
* "browser": true
|
|
126
|
+
* },
|
|
127
|
+
* globals: {
|
|
128
|
+
* "foo": "readonly"
|
|
129
|
+
* },
|
|
130
|
+
* settings: {
|
|
131
|
+
* react: {
|
|
132
|
+
* version: "18.2.0"
|
|
133
|
+
* },
|
|
134
|
+
* custom: { option: true }
|
|
135
|
+
* },
|
|
136
|
+
* rules: {
|
|
137
|
+
* "eqeqeq": "warn",
|
|
138
|
+
* "import/no-cycle": "error",
|
|
139
|
+
* "react/self-closing-comp": ["error", { "html": false }]
|
|
140
|
+
* },
|
|
141
|
+
* overrides: [
|
|
142
|
+
* {
|
|
143
|
+
* files: ["*.test.ts", "*.spec.ts"],
|
|
144
|
+
* rules: {
|
|
145
|
+
* "@typescript-eslint/no-explicit-any": "off"
|
|
146
|
+
* }
|
|
147
|
+
* }
|
|
148
|
+
* ]
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
interface Oxlintrc$1 {
|
|
153
|
+
/**
|
|
154
|
+
* Schema URI for editor tooling.
|
|
155
|
+
*/
|
|
156
|
+
$schema?: string;
|
|
157
|
+
categories?: RuleCategories;
|
|
158
|
+
/**
|
|
159
|
+
* Environments enable and disable collections of global variables.
|
|
160
|
+
*/
|
|
161
|
+
env?: OxlintEnv;
|
|
162
|
+
/**
|
|
163
|
+
* Paths of configuration files that this configuration file extends (inherits from). The files
|
|
164
|
+
* are resolved relative to the location of the configuration file that contains the `extends`
|
|
165
|
+
* property. The configuration files are merged from the first to the last, with the last file
|
|
166
|
+
* overriding the previous ones.
|
|
167
|
+
*/
|
|
168
|
+
extends?: string[];
|
|
169
|
+
/**
|
|
170
|
+
* Enabled or disabled specific global variables.
|
|
171
|
+
*/
|
|
172
|
+
globals?: OxlintGlobals;
|
|
173
|
+
/**
|
|
174
|
+
* Globs to ignore during linting. These are resolved from the configuration file path.
|
|
175
|
+
*/
|
|
176
|
+
ignorePatterns?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* JS plugins, allows usage of ESLint plugins with Oxlint.
|
|
179
|
+
*
|
|
180
|
+
* Read more about JS plugins in
|
|
181
|
+
* [the docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).
|
|
182
|
+
*
|
|
183
|
+
* Note: JS plugins are in alpha and not subject to semver.
|
|
184
|
+
*
|
|
185
|
+
* Examples:
|
|
186
|
+
*
|
|
187
|
+
* Basic usage with a local plugin path.
|
|
188
|
+
*
|
|
189
|
+
* ```json
|
|
190
|
+
* {
|
|
191
|
+
* "jsPlugins": [
|
|
192
|
+
* "./custom-plugin.js"
|
|
193
|
+
* ],
|
|
194
|
+
* "rules": {
|
|
195
|
+
* "custom/rule-name": "warn"
|
|
196
|
+
* }
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* Using a built-in Rust plugin alongside a JS plugin with the same name
|
|
201
|
+
* by giving the JS plugin an alias.
|
|
202
|
+
*
|
|
203
|
+
* ```json
|
|
204
|
+
* {
|
|
205
|
+
* "plugins": [
|
|
206
|
+
* "import"
|
|
207
|
+
* ],
|
|
208
|
+
* "jsPlugins": [
|
|
209
|
+
* {
|
|
210
|
+
* "name": "import-js",
|
|
211
|
+
* "specifier": "eslint-plugin-import"
|
|
212
|
+
* }
|
|
213
|
+
* ],
|
|
214
|
+
* "rules": {
|
|
215
|
+
* "import/no-cycle": "error",
|
|
216
|
+
* "import-js/no-unresolved": "warn"
|
|
217
|
+
* }
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
jsPlugins?: null | ExternalPluginEntry[];
|
|
222
|
+
/**
|
|
223
|
+
* Oxlint config options.
|
|
224
|
+
*/
|
|
225
|
+
options?: OxlintOptions;
|
|
226
|
+
/**
|
|
227
|
+
* Add, remove, or otherwise reconfigure rules for specific files or groups of files.
|
|
228
|
+
*/
|
|
229
|
+
overrides?: OxlintOverrides;
|
|
230
|
+
/**
|
|
231
|
+
* Enabled built-in plugins for Oxlint.
|
|
232
|
+
* You can view the list of available plugins on
|
|
233
|
+
* [the website](https://oxc.rs/docs/guide/usage/linter/plugins.html#supported-plugins).
|
|
234
|
+
*
|
|
235
|
+
* NOTE: Setting the `plugins` field will overwrite the base set of plugins.
|
|
236
|
+
* The `plugins` array should reflect all of the plugins you want to use.
|
|
237
|
+
*/
|
|
238
|
+
plugins?: LintPlugins;
|
|
239
|
+
/**
|
|
240
|
+
* Example
|
|
241
|
+
*
|
|
242
|
+
* `.oxlintrc.json`
|
|
243
|
+
*
|
|
244
|
+
* ```json
|
|
245
|
+
* {
|
|
246
|
+
* "$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
247
|
+
* "rules": {
|
|
248
|
+
* "eqeqeq": "warn",
|
|
249
|
+
* "import/no-cycle": "error",
|
|
250
|
+
* "prefer-const": [
|
|
251
|
+
* "error",
|
|
252
|
+
* {
|
|
253
|
+
* "ignoreReadBeforeAssign": true
|
|
254
|
+
* }
|
|
255
|
+
* ]
|
|
256
|
+
* }
|
|
257
|
+
* }
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html) for the list of
|
|
261
|
+
* rules.
|
|
262
|
+
*/
|
|
263
|
+
rules?: DummyRuleMap;
|
|
264
|
+
/**
|
|
265
|
+
* Plugin-specific configuration for both built-in and custom plugins.
|
|
266
|
+
* This includes settings for built-in plugins such as `react` and `jsdoc`
|
|
267
|
+
* as well as configuring settings for JS custom plugins loaded via `jsPlugins`.
|
|
268
|
+
*/
|
|
269
|
+
settings?: OxlintPluginSettings;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Configure an entire category of rules all at once.
|
|
273
|
+
*
|
|
274
|
+
* Rules enabled or disabled this way will be overwritten by individual rules in the `rules` field.
|
|
275
|
+
*
|
|
276
|
+
* Example
|
|
277
|
+
* ```json
|
|
278
|
+
* {
|
|
279
|
+
* "$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
280
|
+
* "categories": {
|
|
281
|
+
* "correctness": "warn"
|
|
282
|
+
* },
|
|
283
|
+
* "rules": {
|
|
284
|
+
* "eslint/no-unused-vars": "error"
|
|
285
|
+
* }
|
|
286
|
+
* }
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
interface RuleCategories {
|
|
290
|
+
correctness?: AllowWarnDeny;
|
|
291
|
+
nursery?: AllowWarnDeny;
|
|
292
|
+
pedantic?: AllowWarnDeny;
|
|
293
|
+
perf?: AllowWarnDeny;
|
|
294
|
+
restriction?: AllowWarnDeny;
|
|
295
|
+
style?: AllowWarnDeny;
|
|
296
|
+
suspicious?: AllowWarnDeny;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Predefine global variables.
|
|
300
|
+
*
|
|
301
|
+
* Environments specify what global variables are predefined.
|
|
302
|
+
* See [ESLint's list of environments](https://eslint.org/docs/v8.x/use/configure/language-options#specifying-environments)
|
|
303
|
+
* for what environments are available and what each one provides.
|
|
304
|
+
*/
|
|
305
|
+
interface OxlintEnv {
|
|
306
|
+
[k: string]: boolean;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Add or remove global variables.
|
|
310
|
+
*
|
|
311
|
+
* For each global variable, set the corresponding value equal to `"writable"`
|
|
312
|
+
* to allow the variable to be overwritten or `"readonly"` to disallow overwriting.
|
|
313
|
+
*
|
|
314
|
+
* Globals can be disabled by setting their value to `"off"`. For example, in
|
|
315
|
+
* an environment where most Es2015 globals are available but `Promise` is unavailable,
|
|
316
|
+
* you might use this config:
|
|
317
|
+
*
|
|
318
|
+
* ```json
|
|
319
|
+
* {
|
|
320
|
+
* "$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
321
|
+
* "env": {
|
|
322
|
+
* "es6": true
|
|
323
|
+
* },
|
|
324
|
+
* "globals": {
|
|
325
|
+
* "Promise": "off"
|
|
326
|
+
* }
|
|
327
|
+
* }
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* You may also use `"readable"` or `false` to represent `"readonly"`, and
|
|
331
|
+
* `"writeable"` or `true` to represent `"writable"`.
|
|
332
|
+
*/
|
|
333
|
+
interface OxlintGlobals {
|
|
334
|
+
[k: string]: GlobalValue;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Options for the linter.
|
|
338
|
+
*/
|
|
339
|
+
interface OxlintOptions {
|
|
340
|
+
/**
|
|
341
|
+
* Ensure warnings produce a non-zero exit code.
|
|
342
|
+
*
|
|
343
|
+
* Equivalent to passing `--deny-warnings` on the CLI.
|
|
344
|
+
*/
|
|
345
|
+
denyWarnings?: boolean;
|
|
346
|
+
/**
|
|
347
|
+
* Specify a warning threshold. Exits with an error status if warnings exceed this value.
|
|
348
|
+
*
|
|
349
|
+
* Equivalent to passing `--max-warnings` on the CLI.
|
|
350
|
+
*/
|
|
351
|
+
maxWarnings?: number;
|
|
352
|
+
/**
|
|
353
|
+
* Report unused disable directives (e.g. `// oxlint-disable-line` or `// eslint-disable-line`).
|
|
354
|
+
*
|
|
355
|
+
* Equivalent to passing `--report-unused-disable-directives-severity` on the CLI.
|
|
356
|
+
* CLI flags take precedence over this value when both are set.
|
|
357
|
+
* Only supported in the root configuration file.
|
|
358
|
+
*/
|
|
359
|
+
reportUnusedDisableDirectives?: AllowWarnDeny;
|
|
360
|
+
/**
|
|
361
|
+
* Enable rules that require type information.
|
|
362
|
+
*
|
|
363
|
+
* Equivalent to passing `--type-aware` on the CLI.
|
|
364
|
+
*
|
|
365
|
+
* Note that this requires the `oxlint-tsgolint` package to be installed.
|
|
366
|
+
*/
|
|
367
|
+
typeAware?: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Enable experimental type checking (includes TypeScript compiler diagnostics).
|
|
370
|
+
*
|
|
371
|
+
* Equivalent to passing `--type-check` on the CLI.
|
|
372
|
+
*
|
|
373
|
+
* Note that this requires the `oxlint-tsgolint` package to be installed.
|
|
374
|
+
*/
|
|
375
|
+
typeCheck?: boolean;
|
|
376
|
+
}
|
|
377
|
+
interface OxlintOverride {
|
|
378
|
+
/**
|
|
379
|
+
* Environments enable and disable collections of global variables.
|
|
380
|
+
*/
|
|
381
|
+
env?: OxlintEnv;
|
|
382
|
+
/**
|
|
383
|
+
* A list of glob patterns to override.
|
|
384
|
+
*
|
|
385
|
+
* ## Example
|
|
386
|
+
* `[ "*.test.ts", "*.spec.ts" ]`
|
|
387
|
+
*/
|
|
388
|
+
files: GlobSet;
|
|
389
|
+
/**
|
|
390
|
+
* Enabled or disabled specific global variables.
|
|
391
|
+
*/
|
|
392
|
+
globals?: OxlintGlobals;
|
|
393
|
+
/**
|
|
394
|
+
* JS plugins for this override, allows usage of ESLint plugins with Oxlint.
|
|
395
|
+
*
|
|
396
|
+
* Read more about JS plugins in
|
|
397
|
+
* [the docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).
|
|
398
|
+
*
|
|
399
|
+
* Note: JS plugins are in alpha and not subject to semver.
|
|
400
|
+
*/
|
|
401
|
+
jsPlugins?: null | ExternalPluginEntry[];
|
|
402
|
+
/**
|
|
403
|
+
* Optionally change what plugins are enabled for this override. When
|
|
404
|
+
* omitted, the base config's plugins are used.
|
|
405
|
+
*/
|
|
406
|
+
plugins?: LintPlugins;
|
|
407
|
+
rules?: DummyRuleMap;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html)
|
|
411
|
+
*/
|
|
412
|
+
interface DummyRuleMap {
|
|
413
|
+
[k: string]: DummyRule;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Configure the behavior of linter plugins.
|
|
417
|
+
*
|
|
418
|
+
* Here's an example if you're using Next.js in a monorepo:
|
|
419
|
+
*
|
|
420
|
+
* ```json
|
|
421
|
+
* {
|
|
422
|
+
* "settings": {
|
|
423
|
+
* "next": {
|
|
424
|
+
* "rootDir": "apps/dashboard/"
|
|
425
|
+
* },
|
|
426
|
+
* "react": {
|
|
427
|
+
* "linkComponents": [
|
|
428
|
+
* {
|
|
429
|
+
* "name": "Link",
|
|
430
|
+
* "linkAttribute": "to"
|
|
431
|
+
* }
|
|
432
|
+
* ]
|
|
433
|
+
* },
|
|
434
|
+
* "jsx-a11y": {
|
|
435
|
+
* "components": {
|
|
436
|
+
* "Link": "a",
|
|
437
|
+
* "Button": "button"
|
|
438
|
+
* }
|
|
439
|
+
* }
|
|
440
|
+
* }
|
|
441
|
+
* }
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
interface OxlintPluginSettings {
|
|
445
|
+
jsdoc?: JSDocPluginSettings;
|
|
446
|
+
"jsx-a11y"?: JSXA11YPluginSettings;
|
|
447
|
+
next?: NextPluginSettings;
|
|
448
|
+
react?: ReactPluginSettings;
|
|
449
|
+
vitest?: VitestPluginSettings;
|
|
450
|
+
[k: string]: unknown;
|
|
451
|
+
}
|
|
452
|
+
interface JSDocPluginSettings {
|
|
453
|
+
/**
|
|
454
|
+
* Only for `require-(yields|returns|description|example|param|throws)` rule
|
|
455
|
+
*/
|
|
456
|
+
augmentsExtendsReplacesDocs?: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* Only for `require-param-type` and `require-param-description` rule
|
|
459
|
+
*/
|
|
460
|
+
exemptDestructuredRootsFromChecks?: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* For all rules but NOT apply to `empty-tags` rule
|
|
463
|
+
*/
|
|
464
|
+
ignoreInternal?: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* For all rules but NOT apply to `check-access` and `empty-tags` rule
|
|
467
|
+
*/
|
|
468
|
+
ignorePrivate?: boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Only for `require-(yields|returns|description|example|param|throws)` rule
|
|
471
|
+
*/
|
|
472
|
+
ignoreReplacesDocs?: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Only for `require-(yields|returns|description|example|param|throws)` rule
|
|
475
|
+
*/
|
|
476
|
+
implementsReplacesDocs?: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Only for `require-(yields|returns|description|example|param|throws)` rule
|
|
479
|
+
*/
|
|
480
|
+
overrideReplacesDocs?: boolean;
|
|
481
|
+
tagNamePreference?: {
|
|
482
|
+
[k: string]: TagNamePreference;
|
|
483
|
+
};
|
|
484
|
+
[k: string]: unknown;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Configure JSX A11y plugin rules.
|
|
488
|
+
*
|
|
489
|
+
* See
|
|
490
|
+
* [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#configurations)'s
|
|
491
|
+
* configuration for a full reference.
|
|
492
|
+
*/
|
|
493
|
+
interface JSXA11YPluginSettings {
|
|
494
|
+
/**
|
|
495
|
+
* Map of attribute names to their DOM equivalents.
|
|
496
|
+
* This is useful for non-React frameworks that use different attribute names.
|
|
497
|
+
*
|
|
498
|
+
* Example:
|
|
499
|
+
*
|
|
500
|
+
* ```json
|
|
501
|
+
* {
|
|
502
|
+
* "settings": {
|
|
503
|
+
* "jsx-a11y": {
|
|
504
|
+
* "attributes": {
|
|
505
|
+
* "for": [
|
|
506
|
+
* "htmlFor",
|
|
507
|
+
* "for"
|
|
508
|
+
* ]
|
|
509
|
+
* }
|
|
510
|
+
* }
|
|
511
|
+
* }
|
|
512
|
+
* }
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
attributes?: {
|
|
516
|
+
[k: string]: string[];
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* To have your custom components be checked as DOM elements, you can
|
|
520
|
+
* provide a mapping of your component names to the DOM element name.
|
|
521
|
+
*
|
|
522
|
+
* Example:
|
|
523
|
+
*
|
|
524
|
+
* ```json
|
|
525
|
+
* {
|
|
526
|
+
* "settings": {
|
|
527
|
+
* "jsx-a11y": {
|
|
528
|
+
* "components": {
|
|
529
|
+
* "Link": "a",
|
|
530
|
+
* "IconButton": "button"
|
|
531
|
+
* }
|
|
532
|
+
* }
|
|
533
|
+
* }
|
|
534
|
+
* }
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
components?: {
|
|
538
|
+
[k: string]: string;
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* An optional setting that define the prop your code uses to create polymorphic components.
|
|
542
|
+
* This setting will be used to determine the element type in rules that
|
|
543
|
+
* require semantic context.
|
|
544
|
+
*
|
|
545
|
+
* For example, if you set the `polymorphicPropName` to `as`, then this element:
|
|
546
|
+
*
|
|
547
|
+
* ```jsx
|
|
548
|
+
* <Box as="h3">Hello</Box>
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* Will be treated as an `h3`. If not set, this component will be treated
|
|
552
|
+
* as a `Box`.
|
|
553
|
+
*/
|
|
554
|
+
polymorphicPropName?: string;
|
|
555
|
+
[k: string]: unknown;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Configure Next.js plugin rules.
|
|
559
|
+
*/
|
|
560
|
+
interface NextPluginSettings {
|
|
561
|
+
/**
|
|
562
|
+
* The root directory of the Next.js project.
|
|
563
|
+
*
|
|
564
|
+
* This is particularly useful when you have a monorepo and your Next.js
|
|
565
|
+
* project is in a subfolder.
|
|
566
|
+
*
|
|
567
|
+
* Example:
|
|
568
|
+
*
|
|
569
|
+
* ```json
|
|
570
|
+
* {
|
|
571
|
+
* "settings": {
|
|
572
|
+
* "next": {
|
|
573
|
+
* "rootDir": "apps/dashboard/"
|
|
574
|
+
* }
|
|
575
|
+
* }
|
|
576
|
+
* }
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
rootDir?: OneOrManyFor_String;
|
|
580
|
+
[k: string]: unknown;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Configure React plugin rules.
|
|
584
|
+
*
|
|
585
|
+
* Derived from [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react#configuration-legacy-eslintrc-)
|
|
586
|
+
*/
|
|
587
|
+
interface ReactPluginSettings {
|
|
588
|
+
/**
|
|
589
|
+
* Functions that wrap React components and should be treated as HOCs.
|
|
590
|
+
*
|
|
591
|
+
* Example:
|
|
592
|
+
*
|
|
593
|
+
* ```jsonc
|
|
594
|
+
* {
|
|
595
|
+
* "settings": {
|
|
596
|
+
* "react": {
|
|
597
|
+
* "componentWrapperFunctions": ["observer", "withRouter"]
|
|
598
|
+
* }
|
|
599
|
+
* }
|
|
600
|
+
* }
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
603
|
+
componentWrapperFunctions?: string[];
|
|
604
|
+
/**
|
|
605
|
+
* Components used as alternatives to `<form>` for forms, such as `<Formik>`.
|
|
606
|
+
*
|
|
607
|
+
* Example:
|
|
608
|
+
*
|
|
609
|
+
* ```jsonc
|
|
610
|
+
* {
|
|
611
|
+
* "settings": {
|
|
612
|
+
* "react": {
|
|
613
|
+
* "formComponents": [
|
|
614
|
+
* "CustomForm",
|
|
615
|
+
* // OtherForm is considered a form component and has an endpoint attribute
|
|
616
|
+
* { "name": "OtherForm", "formAttribute": "endpoint" },
|
|
617
|
+
* // allows specifying multiple properties if necessary
|
|
618
|
+
* { "name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"] }
|
|
619
|
+
* ]
|
|
620
|
+
* }
|
|
621
|
+
* }
|
|
622
|
+
* }
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
formComponents?: CustomComponent[];
|
|
626
|
+
/**
|
|
627
|
+
* Components used as alternatives to `<a>` for linking, such as `<Link>`.
|
|
628
|
+
*
|
|
629
|
+
* Example:
|
|
630
|
+
*
|
|
631
|
+
* ```jsonc
|
|
632
|
+
* {
|
|
633
|
+
* "settings": {
|
|
634
|
+
* "react": {
|
|
635
|
+
* "linkComponents": [
|
|
636
|
+
* "HyperLink",
|
|
637
|
+
* // Use `linkAttribute` for components that use a different prop name
|
|
638
|
+
* // than `href`.
|
|
639
|
+
* { "name": "MyLink", "linkAttribute": "to" },
|
|
640
|
+
* // allows specifying multiple properties if necessary
|
|
641
|
+
* { "name": "Link", "linkAttribute": ["to", "href"] }
|
|
642
|
+
* ]
|
|
643
|
+
* }
|
|
644
|
+
* }
|
|
645
|
+
* }
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
linkComponents?: CustomComponent[];
|
|
649
|
+
/**
|
|
650
|
+
* React version to use for version-specific rules.
|
|
651
|
+
*
|
|
652
|
+
* Accepts semver versions (e.g., "18.2.0", "17.0").
|
|
653
|
+
*
|
|
654
|
+
* Example:
|
|
655
|
+
*
|
|
656
|
+
* ```jsonc
|
|
657
|
+
* {
|
|
658
|
+
* "settings": {
|
|
659
|
+
* "react": {
|
|
660
|
+
* "version": "18.2.0"
|
|
661
|
+
* }
|
|
662
|
+
* }
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
version?: string;
|
|
667
|
+
[k: string]: unknown;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Configure Vitest plugin rules.
|
|
671
|
+
*
|
|
672
|
+
* See [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest)'s
|
|
673
|
+
* configuration for a full reference.
|
|
674
|
+
*/
|
|
675
|
+
interface VitestPluginSettings {
|
|
676
|
+
/**
|
|
677
|
+
* Whether to enable typecheck mode for Vitest rules.
|
|
678
|
+
* When enabled, some rules will skip certain checks for describe blocks
|
|
679
|
+
* to accommodate TypeScript type checking scenarios.
|
|
680
|
+
*/
|
|
681
|
+
typecheck?: boolean;
|
|
682
|
+
[k: string]: unknown;
|
|
683
|
+
} //#endregion
|
|
684
|
+
//#region src-js/package/config.d.ts
|
|
685
|
+
type Oxlintrc = Omit<Oxlintrc$1, "$schema" | "extends">;
|
|
686
|
+
interface OxlintConfig$1 extends Oxlintrc {
|
|
687
|
+
extends?: OxlintConfig$1[];
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Define an Oxlint configuration with type inference.
|
|
691
|
+
*
|
|
692
|
+
* @param config - Oxlint configuration
|
|
693
|
+
* @returns Config unchanged
|
|
694
|
+
*/
|
|
695
|
+
//#endregion
|
|
1
696
|
//#region src/types.d.ts
|
|
2
697
|
/**
|
|
3
698
|
* ESLint type definitions compatible with ESLint 9 and 10.
|
|
@@ -97,39 +792,12 @@ declare namespace ESLint {
|
|
|
97
792
|
[key: string]: any;
|
|
98
793
|
}
|
|
99
794
|
}
|
|
100
|
-
type
|
|
101
|
-
type OxlintConfigJsPlugins = string[];
|
|
102
|
-
type OxlintConfigCategories = Partial<Record<Category, unknown>>;
|
|
103
|
-
type OxlintConfigEnv = Record<string, boolean>;
|
|
104
|
-
type OxlintConfigIgnorePatterns = string[];
|
|
105
|
-
type OxlintConfigGlobalsValue = 'readonly' | 'writable' | 'off';
|
|
106
|
-
type OxlintSupportedSettingsKey = 'jsx-a11y' | 'next' | 'react' | 'jsdoc' | 'vitest';
|
|
107
|
-
type OxlintSettings = { [K in OxlintSupportedSettingsKey]?: Record<string, unknown> } & Record<string, Record<string, unknown> | undefined>;
|
|
108
|
-
type OxlintOptions = {
|
|
109
|
-
typeAware?: boolean;
|
|
110
|
-
typeCheck?: boolean;
|
|
111
|
-
};
|
|
112
|
-
type OxlintConfigOverride = {
|
|
113
|
-
files: string[];
|
|
114
|
-
env?: OxlintConfigEnv;
|
|
115
|
-
globals?: Record<string, OxlintConfigGlobalsValue>;
|
|
116
|
-
plugins?: OxlintConfigPlugins;
|
|
117
|
-
jsPlugins?: OxlintConfigJsPlugins;
|
|
118
|
-
categories?: OxlintConfigCategories;
|
|
119
|
-
rules?: Partial<ESLint.RulesRecord>;
|
|
120
|
-
};
|
|
121
|
-
type OxlintConfig = {
|
|
795
|
+
type OxlintConfig = Omit<OxlintConfig$1, 'overrides'> & {
|
|
122
796
|
$schema?: string;
|
|
123
|
-
env?: OxlintConfigEnv;
|
|
124
|
-
globals?: Record<string, OxlintConfigGlobalsValue>;
|
|
125
|
-
plugins?: OxlintConfigPlugins;
|
|
126
|
-
jsPlugins?: OxlintConfigJsPlugins;
|
|
127
|
-
categories?: OxlintConfigCategories;
|
|
128
|
-
rules?: Partial<ESLint.RulesRecord>;
|
|
129
797
|
overrides?: OxlintConfigOverride[];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
798
|
+
};
|
|
799
|
+
type OxlintConfigOverride = OxlintOverride & {
|
|
800
|
+
categories?: RuleCategories;
|
|
133
801
|
};
|
|
134
802
|
type RuleSkippedCategory = 'nursery' | 'type-aware' | 'not-implemented' | 'unsupported' | 'js-plugins';
|
|
135
803
|
type SkippedCategoryGroup = Record<RuleSkippedCategory, string[]>;
|
|
@@ -147,7 +815,6 @@ type Options = {
|
|
|
147
815
|
typeAware?: boolean;
|
|
148
816
|
jsPlugins?: boolean;
|
|
149
817
|
};
|
|
150
|
-
type Category = 'style' | 'correctness' | 'nursery' | 'suspicious' | 'pedantic' | 'perf' | 'restriction';
|
|
151
818
|
//#endregion
|
|
152
819
|
//#region src/index.d.ts
|
|
153
820
|
declare const main: (configs: ESLint.Config | ESLint.Config[] | Promise<ESLint.Config> | Promise<ESLint.Config[]>, oxlintConfig?: OxlintConfig, options?: Options) => Promise<OxlintConfig>;
|
package/dist/src/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as main } from "../src-
|
|
1
|
+
import { t as main } from "../src-DEzNNXJD.mjs";
|
|
2
2
|
export { main as default };
|
|
@@ -64,14 +64,14 @@ const normalizeGlobValue = (value) => {
|
|
|
64
64
|
return true;
|
|
65
65
|
};
|
|
66
66
|
const removeGlobalsWithAreCoveredByEnv = (config) => {
|
|
67
|
-
if (config.globals === void 0 || config.env === void 0) return;
|
|
67
|
+
if (config.globals === void 0 || config.globals === null || config.env === void 0 || config.env === null) return;
|
|
68
68
|
for (const [env, entries] of Object.entries(globals)) if (config.env[env] === true) {
|
|
69
69
|
for (const entry of Object.keys(entries)) if (normalizeGlobValue(config.globals[entry]) === entries[entry]) delete config.globals[entry];
|
|
70
70
|
}
|
|
71
71
|
if (Object.keys(config.globals).length === 0) delete config.globals;
|
|
72
72
|
};
|
|
73
73
|
const transformBoolGlobalToString = (config) => {
|
|
74
|
-
if (config.globals === void 0) return;
|
|
74
|
+
if (config.globals === void 0 || config.globals === null) return;
|
|
75
75
|
for (const [entry, value] of Object.entries(config.globals)) config.globals[entry] = transformEslintGlobalAccessToOxlintGlobalValue(value);
|
|
76
76
|
};
|
|
77
77
|
const transformEslintGlobalAccessToOxlintGlobalValue = (global) => {
|
|
@@ -86,7 +86,7 @@ const THRESHOLD_ENVS = [
|
|
|
86
86
|
"worker"
|
|
87
87
|
];
|
|
88
88
|
const detectEnvironmentByGlobals = (config) => {
|
|
89
|
-
if (config.globals === void 0) return;
|
|
89
|
+
if (config.globals === void 0 || config.globals === null) return;
|
|
90
90
|
for (const [env, entries] of Object.entries(globals)) {
|
|
91
91
|
if (!env.startsWith("es") && !OTHER_SUPPORTED_ENVS.includes(env)) continue;
|
|
92
92
|
if (env.startsWith("es") && !ES_VERSIONS.includes(parseInt(env.replace(/^es/, "")))) continue;
|
|
@@ -94,7 +94,7 @@ const detectEnvironmentByGlobals = (config) => {
|
|
|
94
94
|
let matches = search.filter((entry) => entry in config.globals && normalizeGlobValue(config.globals[entry]) === entries[entry]);
|
|
95
95
|
const useThreshold = THRESHOLD_ENVS.includes(env);
|
|
96
96
|
if (useThreshold && matches.length / search.length >= .97 || !useThreshold && matches.length === search.length) {
|
|
97
|
-
if (config.env === void 0) config.env = {};
|
|
97
|
+
if (config.env === void 0 || config.env === null) config.env = {};
|
|
98
98
|
config.env[env] = true;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -102,27 +102,27 @@ const detectEnvironmentByGlobals = (config) => {
|
|
|
102
102
|
const transformEnvAndGlobals = (eslintConfig, targetConfig, options) => {
|
|
103
103
|
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?.addWarning("special parser detected: " + eslintConfig.languageOptions.parser.meta?.name);
|
|
104
104
|
if (eslintConfig.languageOptions?.globals !== void 0 && eslintConfig.languageOptions?.globals !== null) {
|
|
105
|
-
if (targetConfig.globals === void 0) targetConfig.globals = {};
|
|
105
|
+
if (targetConfig.globals === void 0 || targetConfig.globals === null) targetConfig.globals = {};
|
|
106
106
|
if (options?.merge) {
|
|
107
107
|
for (const [global, globalSetting] of Object.entries(eslintConfig.languageOptions.globals)) if (!(global in targetConfig.globals)) targetConfig.globals[global] = transformEslintGlobalAccessToOxlintGlobalValue(globalSetting);
|
|
108
108
|
} else for (const [global, globalSetting] of Object.entries(eslintConfig.languageOptions.globals)) targetConfig.globals[global] = transformEslintGlobalAccessToOxlintGlobalValue(globalSetting);
|
|
109
109
|
}
|
|
110
110
|
if (eslintConfig.languageOptions?.ecmaVersion !== void 0) {
|
|
111
111
|
if (eslintConfig.languageOptions.ecmaVersion === "latest") {
|
|
112
|
-
if (targetConfig.env === void 0) targetConfig.env = {};
|
|
112
|
+
if (targetConfig.env === void 0 || targetConfig.env === null) targetConfig.env = {};
|
|
113
113
|
const latestVersion = `es${ES_VERSIONS[ES_VERSIONS.length - 1]}`;
|
|
114
114
|
if (!(latestVersion in targetConfig.env)) targetConfig.env[latestVersion] = true;
|
|
115
115
|
} else if (typeof eslintConfig.languageOptions.ecmaVersion === "number" && ES_VERSIONS.includes(eslintConfig.languageOptions.ecmaVersion)) {
|
|
116
|
-
if (targetConfig.env === void 0) targetConfig.env = {};
|
|
116
|
+
if (targetConfig.env === void 0 || targetConfig.env === null) targetConfig.env = {};
|
|
117
117
|
const targetVersion = `es${eslintConfig.languageOptions.ecmaVersion}`;
|
|
118
118
|
if (!(targetVersion in targetConfig.env)) targetConfig.env[targetVersion] = true;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
const cleanUpUselessOverridesEnv = (config) => {
|
|
123
|
-
if (config.env === void 0 || config.overrides === void 0) return;
|
|
123
|
+
if (config.env === void 0 || config.env === null || config.overrides === void 0 || config.overrides === null) return;
|
|
124
124
|
for (const override of config.overrides) {
|
|
125
|
-
if (override.env === void 0) continue;
|
|
125
|
+
if (override.env === void 0 || override.env === null) continue;
|
|
126
126
|
for (const [overrideEnv, overrideEnvConfig] of Object.entries(override.env)) if (overrideEnv in config.env && config.env[overrideEnv] === overrideEnvConfig) delete override.env[overrideEnv];
|
|
127
127
|
if (Object.keys(override.env).length === 0) delete override.env;
|
|
128
128
|
}
|
|
@@ -148,7 +148,7 @@ const cleanUpSupersetEnvs = (config) => {
|
|
|
148
148
|
for (const subsetEnv of subsetEnvs) if (config.env[subsetEnv] === config.env[supersetEnv]) delete config.env[subsetEnv];
|
|
149
149
|
}
|
|
150
150
|
if (config.overrides !== void 0) for (const override of config.overrides) {
|
|
151
|
-
if (override.env === void 0) continue;
|
|
151
|
+
if (override.env === void 0 || override.env === null) continue;
|
|
152
152
|
for (const [supersetEnv, subsetEnvs] of Object.entries(SUPERSET_ENVS)) {
|
|
153
153
|
const supersetInOverride = supersetEnv in override.env;
|
|
154
154
|
const supersetInMain = config.env !== void 0 && supersetEnv in config.env;
|
|
@@ -440,6 +440,7 @@ const styleRules = [
|
|
|
440
440
|
"unicorn/catch-error-name",
|
|
441
441
|
"unicorn/consistent-date-clone",
|
|
442
442
|
"unicorn/consistent-existence-index-check",
|
|
443
|
+
"unicorn/custom-error-definition",
|
|
443
444
|
"unicorn/empty-brace-spaces",
|
|
444
445
|
"unicorn/error-message",
|
|
445
446
|
"unicorn/filename-case",
|
|
@@ -489,6 +490,7 @@ const styleRules = [
|
|
|
489
490
|
"vitest/prefer-describe-function-title",
|
|
490
491
|
"vitest/prefer-expect-type-of",
|
|
491
492
|
"vitest/prefer-import-in-mock",
|
|
493
|
+
"vitest/prefer-strict-boolean-matchers",
|
|
492
494
|
"vitest/prefer-to-be-falsy",
|
|
493
495
|
"vitest/prefer-to-be-object",
|
|
494
496
|
"vitest/prefer-to-be-truthy",
|
|
@@ -640,6 +642,7 @@ const restrictionRules = [
|
|
|
640
642
|
"jsdoc/check-access",
|
|
641
643
|
"jsdoc/empty-tags",
|
|
642
644
|
"jsx-a11y/anchor-ambiguous-text",
|
|
645
|
+
"node/handle-callback-err",
|
|
643
646
|
"node/no-new-require",
|
|
644
647
|
"node/no-path-concat",
|
|
645
648
|
"node/no-process-env",
|
|
@@ -701,6 +704,7 @@ const restrictionRules = [
|
|
|
701
704
|
"import-x/no-relative-parent-imports",
|
|
702
705
|
"import-x/no-webpack-loader-syntax",
|
|
703
706
|
"import-x/unambiguous",
|
|
707
|
+
"n/handle-callback-err",
|
|
704
708
|
"n/no-new-require",
|
|
705
709
|
"n/no-path-concat",
|
|
706
710
|
"n/no-process-env",
|
|
@@ -1185,12 +1189,12 @@ const enableJsPluginRule = (targetConfig, rule, ruleEntry, plugins) => {
|
|
|
1185
1189
|
const pluginName = extractPluginId(rule);
|
|
1186
1190
|
if (pluginName === void 0) return false;
|
|
1187
1191
|
if (ignorePlugins.has(pluginName)) return false;
|
|
1188
|
-
if (targetConfig.jsPlugins === void 0) targetConfig.jsPlugins = [];
|
|
1192
|
+
if (targetConfig.jsPlugins === void 0 || targetConfig.jsPlugins === null) targetConfig.jsPlugins = [];
|
|
1189
1193
|
const metaName = plugins?.[pluginName]?.meta?.name;
|
|
1190
1194
|
const eslintPluginName = metaName ? resolveFromMetaName(metaName) : resolveEslintPluginName(pluginName);
|
|
1191
1195
|
if (!targetConfig.jsPlugins.includes(eslintPluginName)) targetConfig.jsPlugins.push(eslintPluginName);
|
|
1192
1196
|
const resolvedRule = resolveJsPluginRuleName(rule, plugins);
|
|
1193
|
-
targetConfig.rules = targetConfig.rules
|
|
1197
|
+
targetConfig.rules = targetConfig.rules ?? {};
|
|
1194
1198
|
targetConfig.rules[resolvedRule] = ruleEntry;
|
|
1195
1199
|
return true;
|
|
1196
1200
|
};
|
|
@@ -1594,6 +1598,8 @@ function buildUnsupportedRuleExplanations() {
|
|
|
1594
1598
|
//#region src/plugins_rules.ts
|
|
1595
1599
|
const allRules = Object.values(rules_exports).flat();
|
|
1596
1600
|
const unsupportedRuleExplanations = buildUnsupportedRuleExplanations();
|
|
1601
|
+
const OXFMT_SORTING_DOCS_URL = "https://oxc.rs/docs/guide/usage/formatter/sorting.html";
|
|
1602
|
+
const oxfmtImportSortingRules = new Set(["sort-imports", "perfectionist/sort-imports"]);
|
|
1597
1603
|
/**
|
|
1598
1604
|
* checks if value is validSet, or if validSet is an array, check if value is first value of it
|
|
1599
1605
|
*/
|
|
@@ -1610,6 +1616,10 @@ const isActiveValue = (value) => isValueInSet(value, [
|
|
|
1610
1616
|
const isOffValue = (value) => isValueInSet(value, ["off", 0]);
|
|
1611
1617
|
const isWarnValue = (value) => isValueInSet(value, ["warn", 1]);
|
|
1612
1618
|
const isErrorValue = (value) => isValueInSet(value, ["error", 2]);
|
|
1619
|
+
const isOxfmtImportSortingRule = (rule) => oxfmtImportSortingRules.has(rule);
|
|
1620
|
+
const addOxfmtImportSortingWarning = (options) => {
|
|
1621
|
+
options?.reporter?.addWarning("ESLint import-sorting rules like `sort-imports` were not migrated because they conflict with Oxfmt's import sorting.\nUse Oxfmt's `sortImports` formatter option instead. It is based on `eslint-plugin-perfectionist/sort-imports`, is disabled by default, and will need to be enabled.\n" + OXFMT_SORTING_DOCS_URL);
|
|
1622
|
+
};
|
|
1613
1623
|
const normalizeSeverityValue = (value) => {
|
|
1614
1624
|
if (value === void 0) return value;
|
|
1615
1625
|
if (isWarnValue(value)) {
|
|
@@ -1673,6 +1683,10 @@ const transformRuleEntry = (eslintConfig, targetConfig, baseConfig, options, ove
|
|
|
1673
1683
|
for (const [originalRule, config] of Object.entries(eslintConfig.rules)) {
|
|
1674
1684
|
const rule = options?.typeAware && eslintRulesToTypescriptEquivalents[originalRule] !== void 0 ? eslintRulesToTypescriptEquivalents[originalRule] : originalRule;
|
|
1675
1685
|
const normalizedConfig = normalizeSeverityValue(config);
|
|
1686
|
+
if (isOxfmtImportSortingRule(rule)) {
|
|
1687
|
+
if (isActiveValue(normalizedConfig)) addOxfmtImportSortingWarning(options);
|
|
1688
|
+
continue;
|
|
1689
|
+
}
|
|
1676
1690
|
if (!options?.merge) {
|
|
1677
1691
|
removePreviousOverrideRule(rule, eslintConfig, overrides);
|
|
1678
1692
|
if (options?.jsPlugins) {
|
|
@@ -1733,7 +1747,7 @@ const transformRuleEntry = (eslintConfig, targetConfig, baseConfig, options, ove
|
|
|
1733
1747
|
};
|
|
1734
1748
|
const detectNeededRulesPlugins = (targetConfig) => {
|
|
1735
1749
|
if (targetConfig.rules === void 0) return;
|
|
1736
|
-
if (targetConfig.plugins === void 0) targetConfig.plugins = [];
|
|
1750
|
+
if (targetConfig.plugins === void 0 || targetConfig.plugins === null) targetConfig.plugins = [];
|
|
1737
1751
|
for (const rule of Object.keys(targetConfig.rules)) {
|
|
1738
1752
|
if (!rule.includes("/")) continue;
|
|
1739
1753
|
for (const [prefix, plugin] of Object.entries(rulesPrefixesForPlugins)) if (rule.startsWith(`${prefix}/`) && !targetConfig.plugins.includes(plugin)) targetConfig.plugins.push(plugin);
|
|
@@ -1742,8 +1756,8 @@ const detectNeededRulesPlugins = (targetConfig) => {
|
|
|
1742
1756
|
};
|
|
1743
1757
|
const cleanUpUselessOverridesPlugins = (config) => {
|
|
1744
1758
|
if (config.overrides === void 0) return;
|
|
1745
|
-
if (config.plugins !== void 0) for (const override of config.overrides) {
|
|
1746
|
-
if (override.plugins === void 0) continue;
|
|
1759
|
+
if (config.plugins !== void 0 && config.plugins !== null) for (const override of config.overrides) {
|
|
1760
|
+
if (override.plugins === void 0 || override.plugins === null) continue;
|
|
1747
1761
|
override.plugins = override.plugins.filter((overridePlugin) => !config.plugins.includes(overridePlugin));
|
|
1748
1762
|
if (override.plugins.length === 0) delete override.plugins;
|
|
1749
1763
|
}
|
|
@@ -1908,8 +1922,8 @@ const cleanUpOxlintConfig = (config) => {
|
|
|
1908
1922
|
replaceNodePluginName(config);
|
|
1909
1923
|
replaceReactRefreshPluginName(config);
|
|
1910
1924
|
cleanUpRulesWhichAreCoveredByCategory(config);
|
|
1911
|
-
if (config.globals !== void 0 && Object.keys(config.globals).length === 0) delete config.globals;
|
|
1912
|
-
if (config.env !== void 0) {
|
|
1925
|
+
if (config.globals !== void 0 && config.globals !== null && Object.keys(config.globals).length === 0) delete config.globals;
|
|
1926
|
+
if (config.env !== void 0 && config.env !== null) {
|
|
1913
1927
|
delete config.env.es3;
|
|
1914
1928
|
delete config.env.es5;
|
|
1915
1929
|
delete config.env.es2015;
|
|
@@ -2168,6 +2182,19 @@ const warnSettingsInOverride = (eslintConfig, options) => {
|
|
|
2168
2182
|
};
|
|
2169
2183
|
//#endregion
|
|
2170
2184
|
//#region src/index.ts
|
|
2185
|
+
const KEY_ORDER = [
|
|
2186
|
+
"$schema",
|
|
2187
|
+
"plugins",
|
|
2188
|
+
"jsPlugins",
|
|
2189
|
+
"categories",
|
|
2190
|
+
"options",
|
|
2191
|
+
"env",
|
|
2192
|
+
"globals",
|
|
2193
|
+
"settings",
|
|
2194
|
+
"ignorePatterns",
|
|
2195
|
+
"rules",
|
|
2196
|
+
"overrides"
|
|
2197
|
+
];
|
|
2171
2198
|
const buildConfig = (configs, oxlintConfig, options) => {
|
|
2172
2199
|
if (oxlintConfig === void 0) if (options?.merge) oxlintConfig = {
|
|
2173
2200
|
plugins: [
|
|
@@ -2223,7 +2250,7 @@ const buildConfig = (configs, oxlintConfig, options) => {
|
|
|
2223
2250
|
typeAware: true
|
|
2224
2251
|
};
|
|
2225
2252
|
}
|
|
2226
|
-
return oxlintConfig;
|
|
2253
|
+
return Object.fromEntries(KEY_ORDER.filter((key) => key in oxlintConfig).map((key) => [key, oxlintConfig[key]]));
|
|
2227
2254
|
};
|
|
2228
2255
|
const main = async (configs, oxlintConfig, options) => {
|
|
2229
2256
|
const resolved = await Promise.resolve(fixForJsPlugins(configs));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxlint/migrate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"description": "Generates a `.oxlintrc.json` from a existing eslint flat config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"commander": "^14.0.0",
|
|
43
43
|
"globals": "^17.0.0",
|
|
44
|
-
"oxc-parser": "^0.
|
|
44
|
+
"oxc-parser": "^0.121.0",
|
|
45
45
|
"tinyglobby": "^0.2.14"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@antfu/eslint-config": "^7.0.0",
|
|
49
49
|
"@e18e/eslint-plugin": "^0.2.0",
|
|
50
|
-
"@eslint-react/eslint-plugin": "^
|
|
50
|
+
"@eslint-react/eslint-plugin": "^3.0.0",
|
|
51
51
|
"@eslint/js": "^10.0.0",
|
|
52
52
|
"@logux/eslint-config": "^57.0.0",
|
|
53
53
|
"@oxc-node/core": "^0.0.35",
|
|
@@ -76,16 +76,16 @@
|
|
|
76
76
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
77
77
|
"eslint-plugin-react-perf": "^3.3.3",
|
|
78
78
|
"eslint-plugin-react-refresh": "^0.5.0",
|
|
79
|
-
"eslint-plugin-react-web-api": "^
|
|
79
|
+
"eslint-plugin-react-web-api": "^3.0.0",
|
|
80
80
|
"eslint-plugin-regexp": "^3.0.0",
|
|
81
81
|
"eslint-plugin-tsdoc": "^0.5.0",
|
|
82
82
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
83
83
|
"husky": "^9.1.7",
|
|
84
84
|
"lint-staged": "^16.1.2",
|
|
85
85
|
"next": "^16.0.0",
|
|
86
|
-
"oxfmt": "^0.
|
|
87
|
-
"oxlint": "^1.
|
|
88
|
-
"oxlint-tsgolint": "^0.
|
|
86
|
+
"oxfmt": "^0.41.0",
|
|
87
|
+
"oxlint": "^1.57.0",
|
|
88
|
+
"oxlint-tsgolint": "^0.17.0",
|
|
89
89
|
"tsdown": "^0.21.0",
|
|
90
90
|
"typescript-eslint": "^8.35.0",
|
|
91
91
|
"vitest": "^4.0.0"
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"lint-staged": {
|
|
94
94
|
"*": "oxfmt --no-error-on-unmatched-pattern"
|
|
95
95
|
},
|
|
96
|
-
"packageManager": "pnpm@10.
|
|
96
|
+
"packageManager": "pnpm@10.32.1"
|
|
97
97
|
}
|