@oxlint/migrate 1.51.0 → 1.52.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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
3
|
-
import main from "../src/index.mjs";
|
|
2
|
+
import { a as nurseryRules, i as buildUnsupportedRuleExplanations, n as preFixForJsPlugins, o as rules_exports, r as isOffValue, t as main } from "../src-TZG8ybfH.mjs";
|
|
4
3
|
import { program } from "commander";
|
|
5
4
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
6
5
|
import path from "node:path";
|
|
@@ -8,7 +7,6 @@ import { pathToFileURL } from "node:url";
|
|
|
8
7
|
import { parseSync } from "oxc-parser";
|
|
9
8
|
import { glob } from "tinyglobby";
|
|
10
9
|
import { writeFile } from "node:fs/promises";
|
|
11
|
-
|
|
12
10
|
//#region bin/config-loader.ts
|
|
13
11
|
const FLAT_CONFIG_FILENAMES = [
|
|
14
12
|
"eslint.config.js",
|
|
@@ -30,11 +28,9 @@ const loadESLintConfig = async (filePath) => {
|
|
|
30
28
|
if (!existsSync(filePath)) throw new Error(`eslint config file not found: ${filePath}`);
|
|
31
29
|
return import(url);
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
//#endregion
|
|
35
32
|
//#region package.json
|
|
36
|
-
var version = "1.
|
|
37
|
-
|
|
33
|
+
var version = "1.52.0";
|
|
38
34
|
//#endregion
|
|
39
35
|
//#region src/walker/comments/replaceRuleDirectiveComment.ts
|
|
40
36
|
const allRules = Object.values(rules_exports).flat();
|
|
@@ -69,7 +65,6 @@ function replaceRuleDirectiveComment(comment, type, options) {
|
|
|
69
65
|
}
|
|
70
66
|
return originalComment.replace(/eslint-/, "oxlint-");
|
|
71
67
|
}
|
|
72
|
-
|
|
73
68
|
//#endregion
|
|
74
69
|
//#region src/walker/comments/index.ts
|
|
75
70
|
function replaceComments(comment, type, options) {
|
|
@@ -82,7 +77,6 @@ function replaceComments(comment, type, options) {
|
|
|
82
77
|
}
|
|
83
78
|
return originalComment;
|
|
84
79
|
}
|
|
85
|
-
|
|
86
80
|
//#endregion
|
|
87
81
|
//#region src/walker/partialSourceTextLoader.ts
|
|
88
82
|
function extractLangAttribute(source) {
|
|
@@ -212,7 +206,6 @@ function partialAstroSourceTextLoader(sourceText) {
|
|
|
212
206
|
}));
|
|
213
207
|
return results;
|
|
214
208
|
}
|
|
215
|
-
|
|
216
209
|
//#endregion
|
|
217
210
|
//#region src/walker/replaceCommentsInFile.ts
|
|
218
211
|
const getComments = (absoluteFilePath, partialSourceText, options) => {
|
|
@@ -248,7 +241,6 @@ function replaceCommentsInFile(absoluteFilePath, fileContent, options) {
|
|
|
248
241
|
}
|
|
249
242
|
return fileContent;
|
|
250
243
|
}
|
|
251
|
-
|
|
252
244
|
//#endregion
|
|
253
245
|
//#region src/walker/index.ts
|
|
254
246
|
const walkAndReplaceProjectFiles = (projectFiles, readFileSync, writeFile, options) => {
|
|
@@ -260,7 +252,6 @@ const walkAndReplaceProjectFiles = (projectFiles, readFileSync, writeFile, optio
|
|
|
260
252
|
return writeFile(file, newSourceText);
|
|
261
253
|
}));
|
|
262
254
|
};
|
|
263
|
-
|
|
264
255
|
//#endregion
|
|
265
256
|
//#region bin/project-loader.ts
|
|
266
257
|
const getAllProjectFiles = () => {
|
|
@@ -270,7 +261,6 @@ const getAllProjectFiles = () => {
|
|
|
270
261
|
"!**/dist/**"
|
|
271
262
|
], { absolute: true });
|
|
272
263
|
};
|
|
273
|
-
|
|
274
264
|
//#endregion
|
|
275
265
|
//#region src/reporter.ts
|
|
276
266
|
var DefaultReporter = class {
|
|
@@ -306,7 +296,6 @@ var DefaultReporter = class {
|
|
|
306
296
|
return result;
|
|
307
297
|
}
|
|
308
298
|
};
|
|
309
|
-
|
|
310
299
|
//#endregion
|
|
311
300
|
//#region bin/output-formatter.ts
|
|
312
301
|
const unsupportedRuleExplanations = buildUnsupportedRuleExplanations();
|
|
@@ -413,7 +402,6 @@ function displayMigrationResult(outputMessage, warnings) {
|
|
|
413
402
|
console.log(outputMessage);
|
|
414
403
|
if (warnings.length > 0) console.warn(formatWarningsOutput(warnings));
|
|
415
404
|
}
|
|
416
|
-
|
|
417
405
|
//#endregion
|
|
418
406
|
//#region bin/oxlint-migrate.ts
|
|
419
407
|
const cwd = process.cwd();
|
|
@@ -485,6 +473,5 @@ program.name("oxlint-migrate").version(version).argument("[eslint-config]", "The
|
|
|
485
473
|
}), reporter.getWarnings());
|
|
486
474
|
});
|
|
487
475
|
program.parse();
|
|
488
|
-
|
|
489
476
|
//#endregion
|
|
490
|
-
export {
|
|
477
|
+
export {};
|
package/dist/src/index.d.mts
CHANGED
|
@@ -102,6 +102,7 @@ type OxlintConfigJsPlugins = string[];
|
|
|
102
102
|
type OxlintConfigCategories = Partial<Record<Category, unknown>>;
|
|
103
103
|
type OxlintConfigEnv = Record<string, boolean>;
|
|
104
104
|
type OxlintConfigIgnorePatterns = string[];
|
|
105
|
+
type OxlintConfigGlobalsValue = 'readonly' | 'writable' | 'off';
|
|
105
106
|
type OxlintSupportedSettingsKey = 'jsx-a11y' | 'next' | 'react' | 'jsdoc' | 'vitest';
|
|
106
107
|
type OxlintSettings = { [K in OxlintSupportedSettingsKey]?: Record<string, unknown> } & Record<string, Record<string, unknown> | undefined>;
|
|
107
108
|
type OxlintOptions = {
|
|
@@ -111,7 +112,7 @@ type OxlintOptions = {
|
|
|
111
112
|
type OxlintConfigOverride = {
|
|
112
113
|
files: string[];
|
|
113
114
|
env?: OxlintConfigEnv;
|
|
114
|
-
globals?:
|
|
115
|
+
globals?: Record<string, OxlintConfigGlobalsValue>;
|
|
115
116
|
plugins?: OxlintConfigPlugins;
|
|
116
117
|
jsPlugins?: OxlintConfigJsPlugins;
|
|
117
118
|
categories?: OxlintConfigCategories;
|
|
@@ -120,7 +121,7 @@ type OxlintConfigOverride = {
|
|
|
120
121
|
type OxlintConfig = {
|
|
121
122
|
$schema?: string;
|
|
122
123
|
env?: OxlintConfigEnv;
|
|
123
|
-
globals?:
|
|
124
|
+
globals?: Record<string, OxlintConfigGlobalsValue>;
|
|
124
125
|
plugins?: OxlintConfigPlugins;
|
|
125
126
|
jsPlugins?: OxlintConfigJsPlugins;
|
|
126
127
|
categories?: OxlintConfigCategories;
|
package/dist/src/index.mjs
CHANGED
|
@@ -1,67 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/index.ts
|
|
4
|
-
const buildConfig = (configs, oxlintConfig, options) => {
|
|
5
|
-
if (oxlintConfig === void 0) if (options?.merge) oxlintConfig = {
|
|
6
|
-
plugins: [
|
|
7
|
-
"oxc",
|
|
8
|
-
"typescript",
|
|
9
|
-
"unicorn",
|
|
10
|
-
"react"
|
|
11
|
-
],
|
|
12
|
-
categories: { correctness: "warn" }
|
|
13
|
-
};
|
|
14
|
-
else oxlintConfig = {
|
|
15
|
-
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
16
|
-
plugins: [],
|
|
17
|
-
categories: { correctness: "off" }
|
|
18
|
-
};
|
|
19
|
-
if (oxlintConfig.$schema === void 0 && options?.merge) oxlintConfig.$schema = "./node_modules/oxlint/configuration_schema.json";
|
|
20
|
-
if (oxlintConfig.env?.builtin === void 0) {
|
|
21
|
-
if (oxlintConfig.env === void 0) oxlintConfig.env = {};
|
|
22
|
-
oxlintConfig.env.builtin = true;
|
|
23
|
-
}
|
|
24
|
-
const overrides = options?.merge ? oxlintConfig.overrides ?? [] : [];
|
|
25
|
-
const globalPlugins = {};
|
|
26
|
-
for (const config of configs) if (config.plugins) Object.assign(globalPlugins, config.plugins);
|
|
27
|
-
for (const config of configs) {
|
|
28
|
-
if (config.name?.startsWith("oxlint/")) continue;
|
|
29
|
-
let targetConfig;
|
|
30
|
-
if (config.files === void 0) targetConfig = oxlintConfig;
|
|
31
|
-
else {
|
|
32
|
-
const validFiles = processConfigFiles(config.files, options?.reporter);
|
|
33
|
-
if (validFiles.length === 0) continue;
|
|
34
|
-
targetConfig = { files: validFiles };
|
|
35
|
-
const [push, result] = detectSameOverride(oxlintConfig, targetConfig);
|
|
36
|
-
if (push) overrides.push(result);
|
|
37
|
-
}
|
|
38
|
-
transformIgnorePatterns(config, targetConfig, options);
|
|
39
|
-
transformRuleEntry(config, targetConfig, config.files !== void 0 ? oxlintConfig : void 0, options, config.files === void 0 ? overrides : void 0, globalPlugins);
|
|
40
|
-
transformEnvAndGlobals(config, targetConfig, options);
|
|
41
|
-
if (config.files === void 0) transformSettings(config, oxlintConfig, options);
|
|
42
|
-
else warnSettingsInOverride(config, options);
|
|
43
|
-
if ("files" in targetConfig) {
|
|
44
|
-
detectNeededRulesPlugins(targetConfig);
|
|
45
|
-
detectEnvironmentByGlobals(targetConfig);
|
|
46
|
-
cleanUpOxlintConfig(targetConfig);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
oxlintConfig.overrides = overrides;
|
|
50
|
-
detectNeededRulesPlugins(oxlintConfig);
|
|
51
|
-
detectEnvironmentByGlobals(oxlintConfig);
|
|
52
|
-
cleanUpOxlintConfig(oxlintConfig);
|
|
53
|
-
if (options?.typeAware) {
|
|
54
|
-
if ([...Object.keys(oxlintConfig.rules ?? {}), ...(oxlintConfig.overrides ?? []).flatMap((o) => Object.keys(o.rules ?? {}))].some((rule) => typeAwareRules.includes(rule))) oxlintConfig.options = {
|
|
55
|
-
...oxlintConfig.options,
|
|
56
|
-
typeAware: true
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return oxlintConfig;
|
|
60
|
-
};
|
|
61
|
-
const main = async (configs, oxlintConfig, options) => {
|
|
62
|
-
const resolved = await Promise.resolve(fixForJsPlugins(configs));
|
|
63
|
-
return buildConfig(Array.isArray(resolved) ? resolved : [resolved], oxlintConfig, options);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
export { main as default };
|
|
1
|
+
import { t as main } from "../src-TZG8ybfH.mjs";
|
|
2
|
+
export { main as default };
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import globals from "globals";
|
|
2
|
-
|
|
3
2
|
//#region \0rolldown/runtime.js
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __exportAll = (all, no_symbols) => {
|
|
6
5
|
let target = {};
|
|
7
|
-
for (var name in all) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (!no_symbols) {
|
|
14
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
-
}
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
11
|
return target;
|
|
17
12
|
};
|
|
18
|
-
|
|
19
13
|
//#endregion
|
|
20
14
|
//#region src/env_globals.ts
|
|
21
15
|
const ES_VERSIONS = [
|
|
@@ -78,8 +72,12 @@ const removeGlobalsWithAreCoveredByEnv = (config) => {
|
|
|
78
72
|
};
|
|
79
73
|
const transformBoolGlobalToString = (config) => {
|
|
80
74
|
if (config.globals === void 0) return;
|
|
81
|
-
for (const [entry, value] of Object.entries(config.globals))
|
|
82
|
-
|
|
75
|
+
for (const [entry, value] of Object.entries(config.globals)) config.globals[entry] = transformEslintGlobalAccessToOxlintGlobalValue(value);
|
|
76
|
+
};
|
|
77
|
+
const transformEslintGlobalAccessToOxlintGlobalValue = (global) => {
|
|
78
|
+
if (global === false || global === "readable" || global === "readonly") return "readonly";
|
|
79
|
+
else if (global === true || global === "writeable" || global === "writable") return "writable";
|
|
80
|
+
else return "off";
|
|
83
81
|
};
|
|
84
82
|
const THRESHOLD_ENVS = [
|
|
85
83
|
"browser",
|
|
@@ -106,8 +104,8 @@ const transformEnvAndGlobals = (eslintConfig, targetConfig, options) => {
|
|
|
106
104
|
if (eslintConfig.languageOptions?.globals !== void 0 && eslintConfig.languageOptions?.globals !== null) {
|
|
107
105
|
if (targetConfig.globals === void 0) targetConfig.globals = {};
|
|
108
106
|
if (options?.merge) {
|
|
109
|
-
for (const [global, globalSetting] of Object.entries(eslintConfig.languageOptions.globals)) if (!(global in targetConfig.globals)) targetConfig.globals[global] = globalSetting;
|
|
110
|
-
} else Object.
|
|
107
|
+
for (const [global, globalSetting] of Object.entries(eslintConfig.languageOptions.globals)) if (!(global in targetConfig.globals)) targetConfig.globals[global] = transformEslintGlobalAccessToOxlintGlobalValue(globalSetting);
|
|
108
|
+
} else for (const [global, globalSetting] of Object.entries(eslintConfig.languageOptions.globals)) targetConfig.globals[global] = transformEslintGlobalAccessToOxlintGlobalValue(globalSetting);
|
|
111
109
|
}
|
|
112
110
|
if (eslintConfig.languageOptions?.ecmaVersion !== void 0) {
|
|
113
111
|
if (eslintConfig.languageOptions.ecmaVersion === "latest") {
|
|
@@ -166,7 +164,6 @@ const cleanUpSupersetEnvs = (config) => {
|
|
|
166
164
|
if (Object.keys(override.env).length === 0) delete override.env;
|
|
167
165
|
}
|
|
168
166
|
};
|
|
169
|
-
|
|
170
167
|
//#endregion
|
|
171
168
|
//#region src/generated/rules.ts
|
|
172
169
|
var rules_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -936,6 +933,7 @@ const nurseryRules = [
|
|
|
936
933
|
"@typescript-eslint/dot-notation",
|
|
937
934
|
"@typescript-eslint/no-unnecessary-condition",
|
|
938
935
|
"@typescript-eslint/no-unnecessary-qualifier",
|
|
936
|
+
"@typescript-eslint/no-unnecessary-type-conversion",
|
|
939
937
|
"@typescript-eslint/no-unnecessary-type-parameters",
|
|
940
938
|
"@typescript-eslint/no-useless-default-assignment",
|
|
941
939
|
"@typescript-eslint/prefer-find",
|
|
@@ -985,6 +983,7 @@ const typeAwareRules = [
|
|
|
985
983
|
"@typescript-eslint/no-unnecessary-template-expression",
|
|
986
984
|
"@typescript-eslint/no-unnecessary-type-arguments",
|
|
987
985
|
"@typescript-eslint/no-unnecessary-type-assertion",
|
|
986
|
+
"@typescript-eslint/no-unnecessary-type-conversion",
|
|
988
987
|
"@typescript-eslint/no-unnecessary-type-parameters",
|
|
989
988
|
"@typescript-eslint/no-unsafe-argument",
|
|
990
989
|
"@typescript-eslint/no-unsafe-assignment",
|
|
@@ -1021,7 +1020,6 @@ const typeAwareRules = [
|
|
|
1021
1020
|
"@typescript-eslint/unbound-method",
|
|
1022
1021
|
"@typescript-eslint/use-unknown-in-catch-callback-variable"
|
|
1023
1022
|
];
|
|
1024
|
-
|
|
1025
1023
|
//#endregion
|
|
1026
1024
|
//#region src/constants.ts
|
|
1027
1025
|
const rulesPrefixesForPlugins = {
|
|
@@ -1043,6 +1041,10 @@ const rulesPrefixesForPlugins = {
|
|
|
1043
1041
|
vitest: "vitest",
|
|
1044
1042
|
vue: "vue"
|
|
1045
1043
|
};
|
|
1044
|
+
const eslintRulesToTypescriptEquivalents = {
|
|
1045
|
+
"dot-notation": "@typescript-eslint/dot-notation",
|
|
1046
|
+
"consistent-return": "@typescript-eslint/consistent-return"
|
|
1047
|
+
};
|
|
1046
1048
|
const typescriptRulesExtendEslintRules = [
|
|
1047
1049
|
"class-methods-use-this",
|
|
1048
1050
|
"default-param-last",
|
|
@@ -1063,7 +1065,6 @@ const typescriptRulesExtendEslintRules = [
|
|
|
1063
1065
|
"no-use-before-define",
|
|
1064
1066
|
"no-useless-constructor"
|
|
1065
1067
|
];
|
|
1066
|
-
|
|
1067
1068
|
//#endregion
|
|
1068
1069
|
//#region src/jsPlugins.ts
|
|
1069
1070
|
const ignorePlugins = new Set([
|
|
@@ -1191,7 +1192,6 @@ const enableJsPluginRule = (targetConfig, rule, ruleEntry, plugins) => {
|
|
|
1191
1192
|
targetConfig.rules[resolvedRule] = ruleEntry;
|
|
1192
1193
|
return true;
|
|
1193
1194
|
};
|
|
1194
|
-
|
|
1195
1195
|
//#endregion
|
|
1196
1196
|
//#region src/generated/unsupported-rules.json
|
|
1197
1197
|
var unsupportedRules = {
|
|
@@ -1269,6 +1269,8 @@ var unsupportedRules = {
|
|
|
1269
1269
|
"react/jsx-curly-newline": "Stylistic rule from eslint-plugin-react. Should use Oxfmt for stylistic rules, or use JS Plugins to enable this rule.",
|
|
1270
1270
|
"react/jsx-child-element-spacing": "Stylistic rule from eslint-plugin-react. Should use Oxfmt for stylistic rules, or use JS Plugins to enable this rule.",
|
|
1271
1271
|
"react/jsx-one-expression-per-line": "Stylistic rule from eslint-plugin-react. Should use Oxfmt for stylistic rules, or use JS Plugins to enable this rule.",
|
|
1272
|
+
"react/jsx-sort-props": "Stylistic rule from eslint-plugin-react. Should use Oxfmt for stylistic rules, or use JS Plugins to enable this rule.",
|
|
1273
|
+
"react/no-adjacent-inline-elements": "Stylistic rule from eslint-plugin-react. Should use Oxfmt for stylistic rules, or use JS Plugins to enable this rule.",
|
|
1272
1274
|
"react/config": "React Compiler rules will not be implemented in oxlint for now, as they require integration with the react compiler itself. These rules can be used via JS Plugins if desired.",
|
|
1273
1275
|
"react/error-boundaries": "React Compiler rules will not be implemented in oxlint for now, as they require integration with the react compiler itself. These rules can be used via JS Plugins if desired.",
|
|
1274
1276
|
"react/component-hook-factories": "React Compiler rules will not be implemented in oxlint for now, as they require integration with the react compiler itself. These rules can be used via JS Plugins if desired.",
|
|
@@ -1308,6 +1310,8 @@ var unsupportedRules = {
|
|
|
1308
1310
|
"react/sort-default-props": "`defaultProps` is removed entirely in React 19, this rule is no longer relevant. Also stylistic.",
|
|
1309
1311
|
"react/sort-prop-types": "PropTypes are ignored in React 19, and this rule is only relevant if you use the PropTypes package. Also stylistic.",
|
|
1310
1312
|
"react/static-property-placement": "This rule only applies to legacy class components, which are not widely used in modern React.",
|
|
1313
|
+
"react/require-optimization": "This rule only applies to legacy class components, which are not widely used in modern React.",
|
|
1314
|
+
"react/prefer-read-only-props": "This rule is niche and primarily applies to legacy class components, which are not widely used in modern React.",
|
|
1311
1315
|
"typescript/sort-type-constituents": "Deprecated, replaced by `perfectionist/sort-intersection-types` and `perfectionist/sort-union-types` rules.",
|
|
1312
1316
|
"typescript/no-type-alias": "Deprecated, replaced by `typescript-eslint/consistent-type-definitions` rule.",
|
|
1313
1317
|
"typescript/typedef": "Deprecated.",
|
|
@@ -1557,7 +1561,6 @@ var unsupportedRules = {
|
|
|
1557
1561
|
"vue/valid-v-bind-sync": "Deprecated.",
|
|
1558
1562
|
"vue/valid-model-definition": "Deprecated."
|
|
1559
1563
|
};
|
|
1560
|
-
|
|
1561
1564
|
//#endregion
|
|
1562
1565
|
//#region src/utilities.ts
|
|
1563
1566
|
const isEqualDeep = (a, b) => {
|
|
@@ -1585,7 +1588,6 @@ function buildUnsupportedRuleExplanations() {
|
|
|
1585
1588
|
}
|
|
1586
1589
|
return explanations;
|
|
1587
1590
|
}
|
|
1588
|
-
|
|
1589
1591
|
//#endregion
|
|
1590
1592
|
//#region src/plugins_rules.ts
|
|
1591
1593
|
const allRules = Object.values(rules_exports).flat();
|
|
@@ -1666,7 +1668,8 @@ const transformRuleEntry = (eslintConfig, targetConfig, baseConfig, options, ove
|
|
|
1666
1668
|
...globalPlugins,
|
|
1667
1669
|
...eslintConfig.plugins
|
|
1668
1670
|
} : eslintConfig.plugins;
|
|
1669
|
-
for (const [
|
|
1671
|
+
for (const [originalRule, config] of Object.entries(eslintConfig.rules)) {
|
|
1672
|
+
const rule = options?.typeAware && eslintRulesToTypescriptEquivalents[originalRule] !== void 0 ? eslintRulesToTypescriptEquivalents[originalRule] : originalRule;
|
|
1670
1673
|
const normalizedConfig = normalizeSeverityValue(config);
|
|
1671
1674
|
if (!options?.merge) {
|
|
1672
1675
|
removePreviousOverrideRule(rule, eslintConfig, overrides);
|
|
@@ -1851,7 +1854,6 @@ const replaceReactRefreshPluginName = (config) => {
|
|
|
1851
1854
|
delete config.rules[rule];
|
|
1852
1855
|
}
|
|
1853
1856
|
};
|
|
1854
|
-
|
|
1855
1857
|
//#endregion
|
|
1856
1858
|
//#region src/cleanup.ts
|
|
1857
1859
|
const TS_ESLINT_DEFAULT_OVERRIDE = {
|
|
@@ -1976,7 +1978,6 @@ function mergeConsecutiveOverridesWithDifferingFiles(config) {
|
|
|
1976
1978
|
}
|
|
1977
1979
|
config.overrides = mergedOverrides;
|
|
1978
1980
|
}
|
|
1979
|
-
|
|
1980
1981
|
//#endregion
|
|
1981
1982
|
//#region src/ignorePatterns.ts
|
|
1982
1983
|
const transformIgnorePatterns = (eslintConfig, targetConfig, options) => {
|
|
@@ -1988,7 +1989,6 @@ const transformIgnorePatterns = (eslintConfig, targetConfig, options) => {
|
|
|
1988
1989
|
if (targetConfig.ignorePatterns === void 0) targetConfig.ignorePatterns = [];
|
|
1989
1990
|
for (const ignores of eslintConfig.ignores) if (!targetConfig.ignorePatterns.includes(ignores)) targetConfig.ignorePatterns.push(ignores);
|
|
1990
1991
|
};
|
|
1991
|
-
|
|
1992
1992
|
//#endregion
|
|
1993
1993
|
//#region src/overrides.ts
|
|
1994
1994
|
const detectSameOverride = (config, override) => {
|
|
@@ -1999,7 +1999,6 @@ const detectSameOverride = (config, override) => {
|
|
|
1999
1999
|
if (matchedOverride !== void 0) return [false, matchedOverride];
|
|
2000
2000
|
return [true, override];
|
|
2001
2001
|
};
|
|
2002
|
-
|
|
2003
2002
|
//#endregion
|
|
2004
2003
|
//#region src/js_plugin_fixes.ts
|
|
2005
2004
|
/**
|
|
@@ -2036,7 +2035,6 @@ function fixForJsPlugins(configs) {
|
|
|
2036
2035
|
const preFixForJsPlugins = () => {
|
|
2037
2036
|
return fixForNextEslintConfig();
|
|
2038
2037
|
};
|
|
2039
|
-
|
|
2040
2038
|
//#endregion
|
|
2041
2039
|
//#region src/files.ts
|
|
2042
2040
|
/**
|
|
@@ -2061,7 +2059,6 @@ function processConfigFiles(files, reporter) {
|
|
|
2061
2059
|
} else simpleFiles.push(file);
|
|
2062
2060
|
return simpleFiles;
|
|
2063
2061
|
}
|
|
2064
|
-
|
|
2065
2062
|
//#endregion
|
|
2066
2063
|
//#region src/settings.ts
|
|
2067
2064
|
const OXLINT_SUPPORTED_SETTINGS_KEYS = [
|
|
@@ -2167,6 +2164,68 @@ const warnSettingsInOverride = (eslintConfig, options) => {
|
|
|
2167
2164
|
options?.reporter?.addWarning("Settings found under a 'files' pattern — oxlint does not support settings in overrides and they will be skipped:\n" + formatSettingsKeyList(settingsKeys));
|
|
2168
2165
|
}
|
|
2169
2166
|
};
|
|
2170
|
-
|
|
2171
2167
|
//#endregion
|
|
2172
|
-
|
|
2168
|
+
//#region src/index.ts
|
|
2169
|
+
const buildConfig = (configs, oxlintConfig, options) => {
|
|
2170
|
+
if (oxlintConfig === void 0) if (options?.merge) oxlintConfig = {
|
|
2171
|
+
plugins: [
|
|
2172
|
+
"oxc",
|
|
2173
|
+
"typescript",
|
|
2174
|
+
"unicorn",
|
|
2175
|
+
"react"
|
|
2176
|
+
],
|
|
2177
|
+
categories: { correctness: "warn" }
|
|
2178
|
+
};
|
|
2179
|
+
else oxlintConfig = {
|
|
2180
|
+
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
2181
|
+
plugins: [],
|
|
2182
|
+
categories: { correctness: "off" }
|
|
2183
|
+
};
|
|
2184
|
+
if (oxlintConfig.$schema === void 0 && options?.merge) oxlintConfig.$schema = "./node_modules/oxlint/configuration_schema.json";
|
|
2185
|
+
if (oxlintConfig.env?.builtin === void 0) {
|
|
2186
|
+
if (oxlintConfig.env === void 0) oxlintConfig.env = {};
|
|
2187
|
+
oxlintConfig.env.builtin = true;
|
|
2188
|
+
}
|
|
2189
|
+
const overrides = options?.merge ? oxlintConfig.overrides ?? [] : [];
|
|
2190
|
+
const globalPlugins = {};
|
|
2191
|
+
for (const config of configs) if (config.plugins) Object.assign(globalPlugins, config.plugins);
|
|
2192
|
+
for (const config of configs) {
|
|
2193
|
+
if (config.name?.startsWith("oxlint/")) continue;
|
|
2194
|
+
let targetConfig;
|
|
2195
|
+
if (config.files === void 0) targetConfig = oxlintConfig;
|
|
2196
|
+
else {
|
|
2197
|
+
const validFiles = processConfigFiles(config.files, options?.reporter);
|
|
2198
|
+
if (validFiles.length === 0) continue;
|
|
2199
|
+
targetConfig = { files: validFiles };
|
|
2200
|
+
const [push, result] = detectSameOverride(oxlintConfig, targetConfig);
|
|
2201
|
+
if (push) overrides.push(result);
|
|
2202
|
+
}
|
|
2203
|
+
transformIgnorePatterns(config, targetConfig, options);
|
|
2204
|
+
transformRuleEntry(config, targetConfig, config.files !== void 0 ? oxlintConfig : void 0, options, config.files === void 0 ? overrides : void 0, globalPlugins);
|
|
2205
|
+
transformEnvAndGlobals(config, targetConfig, options);
|
|
2206
|
+
if (config.files === void 0) transformSettings(config, oxlintConfig, options);
|
|
2207
|
+
else warnSettingsInOverride(config, options);
|
|
2208
|
+
if ("files" in targetConfig) {
|
|
2209
|
+
detectNeededRulesPlugins(targetConfig);
|
|
2210
|
+
detectEnvironmentByGlobals(targetConfig);
|
|
2211
|
+
cleanUpOxlintConfig(targetConfig);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
oxlintConfig.overrides = overrides;
|
|
2215
|
+
detectNeededRulesPlugins(oxlintConfig);
|
|
2216
|
+
detectEnvironmentByGlobals(oxlintConfig);
|
|
2217
|
+
cleanUpOxlintConfig(oxlintConfig);
|
|
2218
|
+
if (options?.typeAware) {
|
|
2219
|
+
if ([...Object.keys(oxlintConfig.rules ?? {}), ...(oxlintConfig.overrides ?? []).flatMap((o) => Object.keys(o.rules ?? {}))].some((rule) => typeAwareRules.includes(rule))) oxlintConfig.options = {
|
|
2220
|
+
...oxlintConfig.options,
|
|
2221
|
+
typeAware: true
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
return oxlintConfig;
|
|
2225
|
+
};
|
|
2226
|
+
const main = async (configs, oxlintConfig, options) => {
|
|
2227
|
+
const resolved = await Promise.resolve(fixForJsPlugins(configs));
|
|
2228
|
+
return buildConfig(Array.isArray(resolved) ? resolved : [resolved], oxlintConfig, options);
|
|
2229
|
+
};
|
|
2230
|
+
//#endregion
|
|
2231
|
+
export { nurseryRules as a, buildUnsupportedRuleExplanations as i, preFixForJsPlugins as n, rules_exports as o, isOffValue as r, main as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxlint/migrate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.52.0",
|
|
4
4
|
"description": "Generates a `.oxlintrc.json` from a existing eslint flat config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"generate:unsupported": "node --import @oxc-node/core/register ./scripts/fetch-unsupported-rules.ts",
|
|
34
34
|
"generate:all": "pnpm generate:vitest && pnpm generate && pnpm generate:unsupported && pnpm format",
|
|
35
35
|
"format": "oxfmt",
|
|
36
|
-
"lint": "oxlint
|
|
36
|
+
"lint": "oxlint",
|
|
37
37
|
"test": "vitest",
|
|
38
38
|
"build": "tsdown",
|
|
39
39
|
"manual-test": "pnpm build; chmod +x dist/bin/oxlint-migrate.mjs; npx ."
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"commander": "^14.0.0",
|
|
43
43
|
"globals": "^17.0.0",
|
|
44
|
-
"oxc-parser": "^0.
|
|
44
|
+
"oxc-parser": "^0.116.0",
|
|
45
45
|
"tinyglobby": "^0.2.14"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
@@ -83,10 +83,10 @@
|
|
|
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.
|
|
89
|
-
"tsdown": "^0.
|
|
86
|
+
"oxfmt": "^0.36.0",
|
|
87
|
+
"oxlint": "^1.52.0",
|
|
88
|
+
"oxlint-tsgolint": "^0.16.0",
|
|
89
|
+
"tsdown": "^0.21.0",
|
|
90
90
|
"typescript-eslint": "^8.35.0",
|
|
91
91
|
"vitest": "^4.0.0"
|
|
92
92
|
},
|