@oxlint/migrate 0.0.5 → 0.15.13
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 +4 -5
- package/dist/package.json.mjs +1 -1
- package/dist/src/cleanup.mjs +4 -2
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.mjs +24 -1
- package/dist/src/env_globals.mjs +3 -0
- package/dist/src/generated/rules.mjs +37 -2
- package/dist/src/plugins_rules.d.ts +5 -0
- package/dist/src/plugins_rules.mjs +37 -1
- package/package.json +12 -6
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# oxlint
|
|
1
|
+
# @oxlint/migrate
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
[](https://www.npmjs.com/package/@oxlint/migrate)
|
|
@@ -11,16 +11,15 @@ Generates a `.oxlintrc.json` from a existing eslint flat config.
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```shell
|
|
14
|
-
|
|
15
|
-
npx oxlint-migrate <optional-eslint-flat-config-path>
|
|
14
|
+
npx @oxlint/migrate <optional-eslint-flat-config-path>
|
|
16
15
|
```
|
|
17
16
|
|
|
18
17
|
When no config file provided, the script searches for the default eslint config filenames in the current directory.
|
|
19
18
|
|
|
20
19
|
### User Flow
|
|
21
20
|
|
|
22
|
-
- Upgrade `oxlint` and
|
|
23
|
-
- Execute `npx oxlint
|
|
21
|
+
- Upgrade `oxlint` and `@oxlint/migrate` to the same version.
|
|
22
|
+
- Execute `npx @oxlint/migrate`
|
|
24
23
|
- (Optional): Disable supported rules via [eslint-plugin-oxlint](https://github.com/oxc-project/eslint-plugin-oxlint)
|
|
25
24
|
|
|
26
25
|
## Contributing
|
package/dist/package.json.mjs
CHANGED
package/dist/src/cleanup.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { removeGlobalsWithAreCoveredByEnv, transformBoolGlobalToString, ES_VERSIONS, cleanUpUselessOverridesEnv } from "./env_globals.mjs";
|
|
2
|
-
import { cleanUpUselessOverridesRules, cleanUpUselessOverridesPlugins } from "./plugins_rules.mjs";
|
|
2
|
+
import { replaceTypescriptAliasRules, replaceNodePluginName, cleanUpUselessOverridesRules, cleanUpUselessOverridesPlugins } from "./plugins_rules.mjs";
|
|
3
3
|
const isEqualDeep = (a, b) => {
|
|
4
4
|
if (a === b) {
|
|
5
5
|
return true;
|
|
@@ -50,6 +50,7 @@ const cleanUpDefaultTypeScriptOverridesForEslint = (config) => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const cleanUpUselessOverridesEntries = (config) => {
|
|
53
|
+
cleanUpDefaultTypeScriptOverridesForEslint(config);
|
|
53
54
|
cleanUpUselessOverridesRules(config);
|
|
54
55
|
cleanUpUselessOverridesPlugins(config);
|
|
55
56
|
cleanUpUselessOverridesEnv(config);
|
|
@@ -71,6 +72,8 @@ const cleanUpUselessOverridesEntries = (config) => {
|
|
|
71
72
|
const cleanUpOxlintConfig = (config) => {
|
|
72
73
|
removeGlobalsWithAreCoveredByEnv(config);
|
|
73
74
|
transformBoolGlobalToString(config);
|
|
75
|
+
replaceTypescriptAliasRules(config);
|
|
76
|
+
replaceNodePluginName(config);
|
|
74
77
|
if (config.globals !== void 0 && Object.keys(config.globals).length === 0) {
|
|
75
78
|
delete config.globals;
|
|
76
79
|
}
|
|
@@ -88,7 +91,6 @@ const cleanUpOxlintConfig = (config) => {
|
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
if (!("files" in config)) {
|
|
91
|
-
cleanUpDefaultTypeScriptOverridesForEslint(config);
|
|
92
94
|
cleanUpUselessOverridesEntries(config);
|
|
93
95
|
}
|
|
94
96
|
};
|
package/dist/src/constants.d.ts
CHANGED
package/dist/src/constants.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const rulesPrefixesForPlugins = {
|
|
2
2
|
import: "import",
|
|
3
|
+
"import-x": "import",
|
|
3
4
|
jest: "jest",
|
|
4
5
|
jsdoc: "jsdoc",
|
|
5
6
|
"jsx-a11y": "jsx-a11y",
|
|
6
7
|
"@next/next": "nextjs",
|
|
7
8
|
node: "node",
|
|
9
|
+
n: "node",
|
|
8
10
|
promise: "promise",
|
|
9
11
|
react: "react",
|
|
10
12
|
"react-perf": "react",
|
|
@@ -12,6 +14,27 @@ const rulesPrefixesForPlugins = {
|
|
|
12
14
|
unicorn: "unicorn",
|
|
13
15
|
vitest: "vitest"
|
|
14
16
|
};
|
|
17
|
+
const typescriptRulesExtendEslintRules = [
|
|
18
|
+
"class-methods-use-this",
|
|
19
|
+
"default-param-last",
|
|
20
|
+
"init-declarations",
|
|
21
|
+
"max-params",
|
|
22
|
+
"no-array-constructor",
|
|
23
|
+
"no-dupe-class-members",
|
|
24
|
+
"no-empty-function",
|
|
25
|
+
"no-invalid-this",
|
|
26
|
+
"no-loop-func",
|
|
27
|
+
"no-loss-of-precision",
|
|
28
|
+
"no-magic-numbers",
|
|
29
|
+
"no-redeclare",
|
|
30
|
+
"no-restricted-imports",
|
|
31
|
+
"no-shadow",
|
|
32
|
+
"no-unused-expressions",
|
|
33
|
+
"no-unused-vars",
|
|
34
|
+
"no-use-before-define",
|
|
35
|
+
"no-useless-constructor"
|
|
36
|
+
];
|
|
15
37
|
export {
|
|
16
|
-
rulesPrefixesForPlugins
|
|
38
|
+
rulesPrefixesForPlugins,
|
|
39
|
+
typescriptRulesExtendEslintRules
|
|
17
40
|
};
|
package/dist/src/env_globals.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const rules = [
|
|
2
2
|
"array-callback-return",
|
|
3
3
|
"constructor-super",
|
|
4
|
+
"curly",
|
|
4
5
|
"default-case",
|
|
5
6
|
"default-case-last",
|
|
6
7
|
"default-param-last",
|
|
@@ -9,13 +10,18 @@ const rules = [
|
|
|
9
10
|
"func-style",
|
|
10
11
|
"func-names",
|
|
11
12
|
"getter-return",
|
|
13
|
+
"grouped-accessor-pairs",
|
|
12
14
|
"guard-for-in",
|
|
13
15
|
"init-declarations",
|
|
16
|
+
"max-nested-callbacks",
|
|
17
|
+
"max-lines-per-function",
|
|
14
18
|
"max-classes-per-file",
|
|
19
|
+
"max-depth",
|
|
15
20
|
"max-lines",
|
|
16
21
|
"max-params",
|
|
17
22
|
"new-cap",
|
|
18
23
|
"no-useless-call",
|
|
24
|
+
"no-unneeded-ternary",
|
|
19
25
|
"no-extra-label",
|
|
20
26
|
"no-multi-assign",
|
|
21
27
|
"no-nested-ternary",
|
|
@@ -114,6 +120,7 @@ const rules = [
|
|
|
114
120
|
"no-var",
|
|
115
121
|
"no-void",
|
|
116
122
|
"no-with",
|
|
123
|
+
"operator-assignment",
|
|
117
124
|
"prefer-promise-reject-errors",
|
|
118
125
|
"prefer-exponentiation-operator",
|
|
119
126
|
"prefer-numeric-literals",
|
|
@@ -136,6 +143,8 @@ const rules = [
|
|
|
136
143
|
"import/default",
|
|
137
144
|
"import/export",
|
|
138
145
|
"import/first",
|
|
146
|
+
"import/no-absolute-path",
|
|
147
|
+
"import/no-mutable-exports",
|
|
139
148
|
"import/no-named-default",
|
|
140
149
|
"import/no-namespace",
|
|
141
150
|
"import/max-dependencies",
|
|
@@ -290,12 +299,14 @@ const rules = [
|
|
|
290
299
|
"oxc/no-const-enum",
|
|
291
300
|
"oxc/no-map-spread",
|
|
292
301
|
"oxc/no-optional-chaining",
|
|
302
|
+
"oxc/no-redundant-constructor-init",
|
|
293
303
|
"oxc/no-rest-spread-properties",
|
|
294
304
|
"oxc/number-arg-out-of-range",
|
|
295
305
|
"oxc/only-used-in-recursion",
|
|
296
306
|
"oxc/uninvoked-array-callback",
|
|
297
307
|
"promise/avoid-new",
|
|
298
308
|
"promise/catch-or-return",
|
|
309
|
+
"promise/no-nesting",
|
|
299
310
|
"promise/no-promise-in-callback",
|
|
300
311
|
"promise/no-callback-in-promise",
|
|
301
312
|
"promise/no-new-statics",
|
|
@@ -319,6 +330,7 @@ const rules = [
|
|
|
319
330
|
"react/jsx-no-undef",
|
|
320
331
|
"react/jsx-no-useless-fragment",
|
|
321
332
|
"react/jsx-props-no-spread-multi",
|
|
333
|
+
"react/no-namespace",
|
|
322
334
|
"react/no-array-index-key",
|
|
323
335
|
"react/no-children-prop",
|
|
324
336
|
"react/no-danger-with-children",
|
|
@@ -384,6 +396,7 @@ const rules = [
|
|
|
384
396
|
"@typescript-eslint/prefer-ts-expect-error",
|
|
385
397
|
"@typescript-eslint/triple-slash-reference",
|
|
386
398
|
"unicorn/catch-error-name",
|
|
399
|
+
"unicorn/consistent-date-clone",
|
|
387
400
|
"unicorn/consistent-empty-array-spread",
|
|
388
401
|
"unicorn/consistent-existence-index-check",
|
|
389
402
|
"unicorn/consistent-function-scoping",
|
|
@@ -393,6 +406,7 @@ const rules = [
|
|
|
393
406
|
"unicorn/explicit-length-check",
|
|
394
407
|
"unicorn/filename-case",
|
|
395
408
|
"unicorn/new-for-builtins",
|
|
409
|
+
"unicorn/no-invalid-fetch-options",
|
|
396
410
|
"unicorn/no-abusive-eslint-disable",
|
|
397
411
|
"unicorn/no-anonymous-default-export",
|
|
398
412
|
"unicorn/no-array-for-each",
|
|
@@ -494,6 +508,27 @@ const rules = [
|
|
|
494
508
|
"@typescript-eslint/no-unused-expressions",
|
|
495
509
|
"@typescript-eslint/no-unused-vars",
|
|
496
510
|
"@typescript-eslint/no-useless-constructor",
|
|
511
|
+
"import-x/default",
|
|
512
|
+
"import-x/export",
|
|
513
|
+
"import-x/first",
|
|
514
|
+
"import-x/no-absolute-path",
|
|
515
|
+
"import-x/no-mutable-exports",
|
|
516
|
+
"import-x/no-named-default",
|
|
517
|
+
"import-x/no-namespace",
|
|
518
|
+
"import-x/max-dependencies",
|
|
519
|
+
"import-x/named",
|
|
520
|
+
"import-x/namespace",
|
|
521
|
+
"import-x/no-amd",
|
|
522
|
+
"import-x/no-commonjs",
|
|
523
|
+
"import-x/no-cycle",
|
|
524
|
+
"import-x/no-default-export",
|
|
525
|
+
"import-x/no-duplicates",
|
|
526
|
+
"import-x/no-dynamic-require",
|
|
527
|
+
"import-x/no-named-as-default",
|
|
528
|
+
"import-x/no-named-as-default-member",
|
|
529
|
+
"import-x/no-self-import",
|
|
530
|
+
"import-x/no-webpack-loader-syntax",
|
|
531
|
+
"import-x/unambiguous",
|
|
497
532
|
"vitest/consistent-test-it",
|
|
498
533
|
"vitest/expect-expect",
|
|
499
534
|
"vitest/max-expects",
|
|
@@ -532,7 +567,6 @@ const rules = [
|
|
|
532
567
|
const nurseryRules = [
|
|
533
568
|
"constructor-super",
|
|
534
569
|
"getter-return",
|
|
535
|
-
"no-restricted-imports",
|
|
536
570
|
"no-undef",
|
|
537
571
|
"no-unreachable",
|
|
538
572
|
"import/export",
|
|
@@ -542,7 +576,8 @@ const nurseryRules = [
|
|
|
542
576
|
"react-hooks/exhaustive-deps",
|
|
543
577
|
"react/require-render-return",
|
|
544
578
|
"@typescript-eslint/consistent-type-imports",
|
|
545
|
-
"
|
|
579
|
+
"import-x/export",
|
|
580
|
+
"import-x/named"
|
|
546
581
|
];
|
|
547
582
|
export {
|
|
548
583
|
rules as default,
|
|
@@ -4,3 +4,8 @@ export declare const transformRuleEntry: (eslintConfig: Linter.Config, targetCon
|
|
|
4
4
|
export declare const detectNeededRulesPlugins: (targetConfig: OxlintConfigOrOverride, reporter?: Reporter) => void;
|
|
5
5
|
export declare const cleanUpUselessOverridesPlugins: (config: OxlintConfig) => void;
|
|
6
6
|
export declare const cleanUpUselessOverridesRules: (config: OxlintConfig) => void;
|
|
7
|
+
export declare const replaceTypescriptAliasRules: (config: OxlintConfigOrOverride) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Oxlint support them only under the node plugin name
|
|
10
|
+
*/
|
|
11
|
+
export declare const replaceNodePluginName: (config: OxlintConfigOrOverride) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import rules, { nurseryRules } from "./generated/rules.mjs";
|
|
2
|
-
import { rulesPrefixesForPlugins } from "./constants.mjs";
|
|
2
|
+
import { rulesPrefixesForPlugins, typescriptRulesExtendEslintRules } from "./constants.mjs";
|
|
3
3
|
const isValueInSet = (value, validSet) => validSet.includes(value) || Array.isArray(value) && validSet.includes(value[0]);
|
|
4
4
|
const isActiveValue = (value) => isValueInSet(value, ["error", "warn", 1, 2]);
|
|
5
5
|
const transformRuleEntry = (eslintConfig, targetConfig, reporter) => {
|
|
@@ -84,9 +84,45 @@ const cleanUpUselessOverridesRules = (config) => {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
+
const replaceTypescriptAliasRules = (config) => {
|
|
88
|
+
if (config.rules === void 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
for (const rule of Object.keys(config.rules)) {
|
|
92
|
+
const prefix = "@typescript-eslint/";
|
|
93
|
+
if (!rule.startsWith(prefix)) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const eslintRule = rule.slice(prefix.length);
|
|
97
|
+
if (!typescriptRulesExtendEslintRules.includes(eslintRule)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
config.rules[eslintRule] = config.rules[rule];
|
|
101
|
+
delete config.rules[rule];
|
|
102
|
+
}
|
|
103
|
+
if (Object.keys(config.rules).length === 0) {
|
|
104
|
+
delete config.rules;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const replaceNodePluginName = (config) => {
|
|
108
|
+
if (config.rules === void 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const rule of Object.keys(config.rules)) {
|
|
112
|
+
const prefix = "n/";
|
|
113
|
+
if (!rule.startsWith(prefix)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const nodeRule = `node/${rule.slice(prefix.length)}`;
|
|
117
|
+
config.rules[nodeRule] = config.rules[rule];
|
|
118
|
+
delete config.rules[rule];
|
|
119
|
+
}
|
|
120
|
+
};
|
|
87
121
|
export {
|
|
88
122
|
cleanUpUselessOverridesPlugins,
|
|
89
123
|
cleanUpUselessOverridesRules,
|
|
90
124
|
detectNeededRulesPlugins,
|
|
125
|
+
replaceNodePluginName,
|
|
126
|
+
replaceTypescriptAliasRules,
|
|
91
127
|
transformRuleEntry
|
|
92
128
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxlint/migrate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.13",
|
|
4
4
|
"description": "Generates a `.oxlintrc.json` from a existing eslint flat config",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"oxlint
|
|
7
|
+
"@oxlint/migrate": "./dist/bin/oxlint-migrate.mjs"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -33,16 +33,22 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@antfu/eslint-config": "^4.2.0",
|
|
36
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
36
37
|
"@eslint/js": "^9.20.0",
|
|
37
|
-
"@logux/eslint-config": "^
|
|
38
|
+
"@logux/eslint-config": "^55.0.0",
|
|
38
39
|
"@oxc-node/core": "^0.0.19",
|
|
40
|
+
"@stylistic/eslint-plugin": "^4.0.1",
|
|
39
41
|
"@stylistic/eslint-plugin-ts": "^4.0.0",
|
|
40
42
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
41
43
|
"@types/node": "^22.13.4",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.25.0",
|
|
45
|
+
"@typescript-eslint/parser": "^8.25.0",
|
|
42
46
|
"@vitest/coverage-v8": "^3.0.5",
|
|
43
47
|
"eslint": "^9.20.1",
|
|
44
48
|
"eslint-config-prettier": "^10.0.1",
|
|
45
49
|
"eslint-plugin-header": "^3.1.1",
|
|
50
|
+
"eslint-plugin-import": "^2.31.0",
|
|
51
|
+
"eslint-plugin-import-x": "^4.6.1",
|
|
46
52
|
"eslint-plugin-jsdoc": "^50.6.3",
|
|
47
53
|
"eslint-plugin-local": "^6.0.0",
|
|
48
54
|
"eslint-plugin-oxlint": "^0.15.10",
|
|
@@ -50,7 +56,7 @@
|
|
|
50
56
|
"eslint-plugin-unicorn": "^57.0.0",
|
|
51
57
|
"husky": "^9.1.7",
|
|
52
58
|
"lint-staged": "^15.4.3",
|
|
53
|
-
"oxlint": "^0.15.
|
|
59
|
+
"oxlint": "^0.15.13",
|
|
54
60
|
"prettier": "^3.5.1",
|
|
55
61
|
"typescript": "^5.7.3",
|
|
56
62
|
"typescript-eslint": "^8.24.0",
|
|
@@ -63,7 +69,7 @@
|
|
|
63
69
|
},
|
|
64
70
|
"dependencies": {
|
|
65
71
|
"commander": "^13.1.0",
|
|
66
|
-
"globals": "^
|
|
72
|
+
"globals": "^16.0.0"
|
|
67
73
|
},
|
|
68
|
-
"packageManager": "pnpm@10.
|
|
74
|
+
"packageManager": "pnpm@10.5.2"
|
|
69
75
|
}
|