@oxlint/migrate 1.43.0 → 1.48.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 CHANGED
@@ -44,31 +44,18 @@ Tested ESLint Plugins with `oxlint` can be found in this [Oxc Discussion](https:
44
44
 
45
45
  ### TypeScript ESLint Configuration Files
46
46
 
47
- For Deno and Bun, TypeScript configuration files, like `eslint.config.mts`, are natively supported.
48
- For Node.js, you must install [jiti](https://www.npmjs.com/package/jiti) as a dev dependency.
47
+ TypeScript configuration files, like `eslint.config.mts`, are supported in the following environments:
49
48
 
50
- ## Contributing
51
-
52
- ### Generate rules
49
+ - **Deno and Bun**: TypeScript configuration files are natively supported.
50
+ - **Node.js >=22.18.0**: TypeScript configuration files are supported natively with built-in type-stripping enabled by default.
51
+ - **Node.js >=22.6.0**: TypeScript configuration files can be used by setting `NODE_OPTIONS=--experimental-strip-types`.
52
+ - **Node.js <22.6.0**: TypeScript configuration files can be used by setting `NODE_OPTIONS=--import @oxc-node/core/register` and installing [@oxc-node/core](https://www.npmjs.com/package/@oxc-node/core) as a dev dependency.
53
53
 
54
- Generates the rules from installed oxlint version
54
+ If you attempt to use a TypeScript configuration file without the proper setup for your Node.js version, Node.js will throw an error when trying to import the file.
55
55
 
56
- ```shell
57
- pnpm generate
58
- pnpm format
59
- ```
60
-
61
- ### Unit + Integration Test
62
-
63
- ```shell
64
- pnpm vitest
65
- ```
66
-
67
- ### Manual Testing
56
+ ## Contributing
68
57
 
69
- ```shell
70
- pnpm manual-test
71
- ```
58
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to contribute to this project.
72
59
 
73
60
  ## Caveats
74
61
 
@@ -76,9 +63,11 @@ The migration tool has been tested to work quite well for simple ESLint flat con
76
63
 
77
64
  Here are some known caveats to be aware of:
78
65
 
79
- **`settings` field not migrated**
66
+ **`settings` field migration**
67
+
68
+ The `settings` field (e.g. for setting the React version) is migrated for known oxlint-supported plugins: `jsx-a11y`, `next`, `react`, `jsdoc`, and `vitest`. By default, other settings keys are skipped since they aren't supported by oxlint. If using the `--js-plugins` flag, other settings keys will also be migrated in order to support JS Plugins.
80
69
 
81
- The `settings` field (e.g. for setting the React version) is not migrated to the oxlint config yet. You may need to copy it over manually if you have any settings specified.
70
+ Note: Oxlint does not support `settings` in override configs. If your ESLint config has settings in configs with `files` patterns, those settings will be skipped and a warning will be shown.
82
71
 
83
72
  Not all `settings` options are supported by oxlint, and so rule behavior in certain edge-cases may differ. See [the Settings docs](https://oxc.rs/docs/guide/usage/linter/config-file-reference.html#settings) for more info.
84
73
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { a as rules_exports, i as nurseryRules, n as preFixForJsPlugins, r as isOffValue, t as src_default } from "../src-BMWXAQvA.mjs";
2
+ import { a as preFixForJsPlugins, f as nurseryRules, p as rules_exports, u as isOffValue } from "../settings-DozKYNAk.mjs";
3
+ import main from "../src/index.mjs";
3
4
  import { program } from "commander";
4
5
  import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
5
6
  import path from "node:path";
@@ -27,20 +28,12 @@ const loadESLintConfig = async (filePath) => {
27
28
  if (filePath.endsWith("json")) throw new Error(`json format is not supported. @oxlint/migrate only supports the eslint flat configuration`);
28
29
  let url = pathToFileURL(filePath).toString();
29
30
  if (!existsSync(filePath)) throw new Error(`eslint config file not found: ${filePath}`);
30
- if ("Bun" in globalThis || "Deno" in globalThis) return import(url);
31
- if (filePath.endsWith(".ts") || filePath.endsWith(".mts") || filePath.endsWith(".cts")) {
32
- const { createJiti } = await import("jiti");
33
- return createJiti(filePath, {
34
- interopDefault: false,
35
- moduleCache: false
36
- }).import(url);
37
- }
38
31
  return import(url);
39
32
  };
40
33
 
41
34
  //#endregion
42
35
  //#region package.json
43
- var version = "1.43.0";
36
+ var version = "1.48.0";
44
37
 
45
38
  //#endregion
46
39
  //#region src/walker/comments/replaceRuleDirectiveComment.ts
@@ -449,7 +442,7 @@ program.name("oxlint-migrate").version(version).argument("[eslint-config]", "The
449
442
  encoding: "utf8",
450
443
  flag: "r"
451
444
  }));
452
- const oxlintConfig = "default" in eslintConfigs ? await src_default(eslintConfigs.default, config, options) : await src_default(eslintConfigs, config, options);
445
+ const oxlintConfig = "default" in eslintConfigs ? await main(eslintConfigs.default, config, options) : await main(eslintConfigs, config, options);
453
446
  if (existsSync(oxlintFilePath)) renameSync(oxlintFilePath, `${oxlintFilePath}.bak`);
454
447
  writeFileSync(oxlintFilePath, JSON.stringify(oxlintConfig, null, 2));
455
448
  const enabledRulesCount = countEnabledRules(oxlintConfig);
@@ -1,8 +1,8 @@
1
1
  import globals from "globals";
2
2
 
3
- //#region rolldown:runtime
3
+ //#region \0rolldown/runtime.js
4
4
  var __defProp = Object.defineProperty;
5
- var __exportAll = (all, symbols) => {
5
+ var __exportAll = (all, no_symbols) => {
6
6
  let target = {};
7
7
  for (var name in all) {
8
8
  __defProp(target, name, {
@@ -10,7 +10,7 @@ var __exportAll = (all, symbols) => {
10
10
  enumerable: true
11
11
  });
12
12
  }
13
- if (symbols) {
13
+ if (!no_symbols) {
14
14
  __defProp(target, Symbol.toStringTag, { value: "Module" });
15
15
  }
16
16
  return target;
@@ -425,16 +425,20 @@ const styleRules = [
425
425
  "@typescript-eslint/adjacent-overload-signatures",
426
426
  "@typescript-eslint/array-type",
427
427
  "@typescript-eslint/ban-tslint-comment",
428
+ "@typescript-eslint/class-literal-property-style",
428
429
  "@typescript-eslint/consistent-generic-constructors",
429
430
  "@typescript-eslint/consistent-indexed-object-style",
431
+ "@typescript-eslint/consistent-type-assertions",
430
432
  "@typescript-eslint/consistent-type-definitions",
431
433
  "@typescript-eslint/consistent-type-imports",
432
434
  "@typescript-eslint/no-empty-interface",
433
435
  "@typescript-eslint/no-inferrable-types",
436
+ "@typescript-eslint/parameter-properties",
434
437
  "@typescript-eslint/prefer-for-of",
435
438
  "@typescript-eslint/prefer-function-type",
436
439
  "@typescript-eslint/prefer-reduce-type-parameter",
437
440
  "@typescript-eslint/prefer-return-this-type",
441
+ "@typescript-eslint/unified-signatures",
438
442
  "unicorn/catch-error-name",
439
443
  "unicorn/consistent-date-clone",
440
444
  "unicorn/consistent-existence-index-check",
@@ -471,6 +475,7 @@ const styleRules = [
471
475
  "unicorn/prefer-string-raw",
472
476
  "unicorn/prefer-string-trim-start-end",
473
477
  "unicorn/prefer-structured-clone",
478
+ "unicorn/relative-url-style",
474
479
  "unicorn/require-array-join-separator",
475
480
  "unicorn/require-module-attributes",
476
481
  "unicorn/switch-case-braces",
@@ -482,6 +487,7 @@ const styleRules = [
482
487
  "vitest/prefer-called-once",
483
488
  "vitest/prefer-called-times",
484
489
  "vitest/prefer-describe-function-title",
490
+ "vitest/prefer-expect-type-of",
485
491
  "vitest/prefer-to-be-falsy",
486
492
  "vitest/prefer-to-be-object",
487
493
  "vitest/prefer-to-be-truthy",
@@ -545,7 +551,9 @@ const suspiciousRules = [
545
551
  "no-extend-native",
546
552
  "no-extra-bind",
547
553
  "no-new",
554
+ "no-shadow",
548
555
  "no-unexpected-multiline",
556
+ "no-unmodified-loop-condition",
549
557
  "no-unneeded-ternary",
550
558
  "no-useless-concat",
551
559
  "no-useless-constructor",
@@ -585,6 +593,7 @@ const suspiciousRules = [
585
593
  "unicorn/require-post-message-target-origin",
586
594
  "vue/no-required-prop-with-default",
587
595
  "vue/require-default-export",
596
+ "@typescript-eslint/no-shadow",
588
597
  "@typescript-eslint/no-useless-constructor",
589
598
  "import-x/no-absolute-path",
590
599
  "import-x/no-empty-named-blocks",
@@ -605,7 +614,6 @@ const restrictionRules = [
605
614
  "no-empty",
606
615
  "no-empty-function",
607
616
  "no-eq-null",
608
- "no-iterator",
609
617
  "no-param-reassign",
610
618
  "no-plusplus",
611
619
  "no-proto",
@@ -647,11 +655,13 @@ const restrictionRules = [
647
655
  "@typescript-eslint/no-empty-object-type",
648
656
  "@typescript-eslint/no-explicit-any",
649
657
  "@typescript-eslint/no-import-type-side-effects",
658
+ "@typescript-eslint/no-invalid-void-type",
650
659
  "@typescript-eslint/no-namespace",
651
660
  "@typescript-eslint/no-non-null-asserted-nullish-coalescing",
652
661
  "@typescript-eslint/no-non-null-assertion",
653
662
  "@typescript-eslint/no-require-imports",
654
663
  "@typescript-eslint/no-restricted-types",
664
+ "@typescript-eslint/no-use-before-define",
655
665
  "@typescript-eslint/no-var-requires",
656
666
  "@typescript-eslint/non-nullable-type-assertion-style",
657
667
  "@typescript-eslint/prefer-literal-enum-member",
@@ -717,7 +727,9 @@ const correctnessRules = [
717
727
  "no-import-assign",
718
728
  "no-invalid-regexp",
719
729
  "no-irregular-whitespace",
730
+ "no-iterator",
720
731
  "no-loss-of-precision",
732
+ "no-misleading-character-class",
721
733
  "no-new-native-nonconstructor",
722
734
  "no-nonoctal-decimal-escape",
723
735
  "no-obj-calls",
@@ -787,6 +799,7 @@ const correctnessRules = [
787
799
  "jsx-a11y/no-distracting-elements",
788
800
  "jsx-a11y/no-noninteractive-tabindex",
789
801
  "jsx-a11y/no-redundant-roles",
802
+ "jsx-a11y/no-static-element-interactions",
790
803
  "jsx-a11y/prefer-tag-over-role",
791
804
  "jsx-a11y/role-has-required-aria-props",
792
805
  "jsx-a11y/role-supports-aria-props",
@@ -903,14 +916,13 @@ const correctnessRules = [
903
916
  ];
904
917
  const nurseryRules = [
905
918
  "getter-return",
906
- "no-misleading-character-class",
907
919
  "no-undef",
908
920
  "no-unreachable",
909
921
  "import/export",
910
922
  "import/named",
911
- "jsx-a11y/no-static-element-interactions",
912
923
  "promise/no-return-in-finally",
913
924
  "react/require-render-return",
925
+ "@typescript-eslint/no-unnecessary-condition",
914
926
  "@typescript-eslint/prefer-optional-chain",
915
927
  "import-x/export",
916
928
  "import-x/named"
@@ -918,6 +930,7 @@ const nurseryRules = [
918
930
  const perfRules = [
919
931
  "no-await-in-loop",
920
932
  "no-useless-call",
933
+ "react/jsx-no-constructed-context-values",
921
934
  "react/no-array-index-key",
922
935
  "react-perf/jsx-no-jsx-as-prop",
923
936
  "react-perf/jsx-no-new-array-as-prop",
@@ -943,6 +956,7 @@ const typeAwareRules = [
943
956
  "@typescript-eslint/no-mixed-enums",
944
957
  "@typescript-eslint/no-redundant-type-constituents",
945
958
  "@typescript-eslint/no-unnecessary-boolean-literal-compare",
959
+ "@typescript-eslint/no-unnecessary-condition",
946
960
  "@typescript-eslint/no-unnecessary-template-expression",
947
961
  "@typescript-eslint/no-unnecessary-type-arguments",
948
962
  "@typescript-eslint/no-unnecessary-type-assertion",
@@ -1100,6 +1114,11 @@ const normalizeSeverityValue = (value) => {
1100
1114
  return "off";
1101
1115
  }
1102
1116
  };
1117
+ const removePreviousOverrideRule = (rule, eslintConfig, overrides) => {
1118
+ if (eslintConfig.files === void 0 && overrides) {
1119
+ for (const override of overrides) if (override.rules?.[rule]) delete override.rules[rule];
1120
+ }
1121
+ };
1103
1122
  /**
1104
1123
  * Merges a new rule configuration with an existing one, preserving options when
1105
1124
  * the new config only specifies a severity level.
@@ -1125,11 +1144,12 @@ const mergeRuleConfig = (existingConfig, newConfig) => {
1125
1144
  if (Array.isArray(newConfig) && newConfig.length === 1 && existingIsArray && existingConfig.length > 1) return [newConfig[0], ...existingConfig.slice(1)];
1126
1145
  return newConfig;
1127
1146
  };
1128
- const transformRuleEntry = (eslintConfig, targetConfig, baseConfig, options) => {
1147
+ const transformRuleEntry = (eslintConfig, targetConfig, baseConfig, options, overrides) => {
1129
1148
  if (eslintConfig.rules === void 0) return;
1130
1149
  if (targetConfig.rules === void 0) targetConfig.rules = {};
1131
1150
  for (const [rule, config] of Object.entries(eslintConfig.rules)) {
1132
1151
  const normalizedConfig = normalizeSeverityValue(config);
1152
+ if (!options?.merge) removePreviousOverrideRule(rule, eslintConfig, overrides);
1133
1153
  if (allRules.includes(rule)) {
1134
1154
  if (!options?.withNursery && nurseryRules.includes(rule)) {
1135
1155
  options?.reporter?.markSkipped(rule, "nursery");
@@ -1533,59 +1553,105 @@ function processConfigFiles(files, reporter) {
1533
1553
  }
1534
1554
 
1535
1555
  //#endregion
1536
- //#region src/index.ts
1537
- const buildConfig = (configs, oxlintConfig, options) => {
1538
- if (oxlintConfig === void 0) if (options?.merge) oxlintConfig = {
1539
- plugins: [
1540
- "oxc",
1541
- "typescript",
1542
- "unicorn",
1543
- "react"
1544
- ],
1545
- categories: { correctness: "warn" }
1546
- };
1547
- else oxlintConfig = {
1548
- $schema: "./node_modules/oxlint/configuration_schema.json",
1549
- plugins: [],
1550
- categories: { correctness: "off" }
1551
- };
1552
- if (oxlintConfig.$schema === void 0 && options?.merge) oxlintConfig.$schema = "./node_modules/oxlint/configuration_schema.json";
1553
- if (oxlintConfig.env?.builtin === void 0) {
1554
- if (oxlintConfig.env === void 0) oxlintConfig.env = {};
1555
- oxlintConfig.env.builtin = true;
1556
- }
1557
- const overrides = options?.merge ? oxlintConfig.overrides ?? [] : [];
1558
- for (const config of configs) {
1559
- if (config.name?.startsWith("oxlint/")) continue;
1560
- let targetConfig;
1561
- if (config.files === void 0) targetConfig = oxlintConfig;
1562
- else {
1563
- const validFiles = processConfigFiles(config.files, options?.reporter);
1564
- if (validFiles.length === 0) continue;
1565
- targetConfig = { files: validFiles };
1566
- const [push, result] = detectSameOverride(oxlintConfig, targetConfig);
1567
- if (push) overrides.push(result);
1556
+ //#region src/settings.ts
1557
+ const OXLINT_SUPPORTED_SETTINGS_KEYS = [
1558
+ "jsx-a11y",
1559
+ "next",
1560
+ "react",
1561
+ "jsdoc",
1562
+ "vitest"
1563
+ ];
1564
+ const UNSUPPORTED_SETTINGS_SUB_KEYS = {
1565
+ react: ["pragma", "fragment"],
1566
+ vitest: ["vitestImports"]
1567
+ };
1568
+ /**
1569
+ * Deep merge source into target, combining nested objects rather than replacing them.
1570
+ * Arrays are replaced, not merged. Mutates `target` in place.
1571
+ */
1572
+ const deepMerge = (target, source) => {
1573
+ for (const [key, value] of Object.entries(source)) if (value !== null && typeof value === "object" && !Array.isArray(value) && key in target && target[key] !== null && typeof target[key] === "object" && !Array.isArray(target[key])) deepMerge(target[key], value);
1574
+ else target[key] = value;
1575
+ };
1576
+ /**
1577
+ * Check if a settings key is known to be supported by oxlint.
1578
+ */
1579
+ const isSupportedSettingsKey = (key) => {
1580
+ return OXLINT_SUPPORTED_SETTINGS_KEYS.includes(key);
1581
+ };
1582
+ /**
1583
+ * Transform ESLint settings to oxlint settings.
1584
+ *
1585
+ * Only processes settings for the base config (not overrides) since oxlint
1586
+ * does not support settings in overrides.
1587
+ *
1588
+ * Only known oxlint-supported settings keys are migrated:
1589
+ * - jsx-a11y
1590
+ * - next
1591
+ * - react
1592
+ * - jsdoc
1593
+ * - vitest
1594
+ *
1595
+ * @param eslintConfig - The source ESLint config
1596
+ * @param targetConfig - The target oxlint config (must be base config, not override)
1597
+ * @param options - Migration options
1598
+ */
1599
+ const transformSettings = (eslintConfig, targetConfig, options) => {
1600
+ if (eslintConfig.settings === void 0 || eslintConfig.settings === null || Object.keys(eslintConfig.settings).length === 0) return;
1601
+ const eslintSettings = eslintConfig.settings;
1602
+ const filteredSettings = {};
1603
+ const skippedKeys = [];
1604
+ for (const [key, value] of Object.entries(eslintSettings)) {
1605
+ if (value === null || typeof value !== "object") {
1606
+ skippedKeys.push(key);
1607
+ continue;
1568
1608
  }
1569
- transformIgnorePatterns(config, targetConfig, options);
1570
- transformRuleEntry(config, targetConfig, config.files !== void 0 ? oxlintConfig : void 0, options);
1571
- transformEnvAndGlobals(config, targetConfig, options);
1572
- if ("files" in targetConfig) {
1573
- detectNeededRulesPlugins(targetConfig);
1574
- detectEnvironmentByGlobals(targetConfig);
1575
- cleanUpOxlintConfig(targetConfig);
1609
+ if (!options?.jsPlugins && !isSupportedSettingsKey(key)) {
1610
+ skippedKeys.push(key);
1611
+ continue;
1576
1612
  }
1613
+ if (key === "import" || key.startsWith("import/")) {
1614
+ skippedKeys.push(key);
1615
+ continue;
1616
+ }
1617
+ let settingsValue = value;
1618
+ if (key === "react" && settingsValue.version === "detect") {
1619
+ options?.reporter?.addWarning("react.version \"detect\" is not supported by oxlint. Please specify an explicit version (e.g., \"18.2.0\") in your oxlint config.");
1620
+ const { version: _, ...restReactSettings } = settingsValue;
1621
+ settingsValue = restReactSettings;
1622
+ }
1623
+ const unsupportedSubKeys = UNSUPPORTED_SETTINGS_SUB_KEYS[key];
1624
+ if (unsupportedSubKeys !== void 0) {
1625
+ const strippedKeys = [];
1626
+ for (const subKey of unsupportedSubKeys) if (subKey in settingsValue) {
1627
+ strippedKeys.push(`${key}.${subKey}`);
1628
+ const { [subKey]: _, ...rest } = settingsValue;
1629
+ settingsValue = rest;
1630
+ }
1631
+ if (strippedKeys.length > 0) options?.reporter?.addWarning(`Settings not migrated (not supported by oxlint): ${strippedKeys.join(", ")}.`);
1632
+ }
1633
+ if (Object.keys(settingsValue).length === 0) continue;
1634
+ filteredSettings[key] = settingsValue;
1577
1635
  }
1578
- oxlintConfig.overrides = overrides;
1579
- detectNeededRulesPlugins(oxlintConfig);
1580
- detectEnvironmentByGlobals(oxlintConfig);
1581
- cleanUpOxlintConfig(oxlintConfig);
1582
- return oxlintConfig;
1636
+ if (skippedKeys.length > 0) options?.reporter?.addWarning(`Settings not migrated (not supported by oxlint): ${skippedKeys.join(", ")}.`);
1637
+ if (Object.keys(filteredSettings).length === 0) return;
1638
+ if (targetConfig.settings === void 0) targetConfig.settings = {};
1639
+ if (options?.merge) deepMerge(targetConfig.settings, filteredSettings);
1640
+ else Object.assign(targetConfig.settings, filteredSettings);
1583
1641
  };
1584
- const main = async (configs, oxlintConfig, options) => {
1585
- const resolved = await Promise.resolve(fixForJsPlugins(configs));
1586
- return buildConfig(Array.isArray(resolved) ? resolved : [resolved], oxlintConfig, options);
1642
+ /**
1643
+ * Warn when settings are found in an override config, since oxlint does not
1644
+ * support settings in overrides.
1645
+ *
1646
+ * @param eslintConfig - The ESLint config being processed
1647
+ * @param options - Migration options
1648
+ */
1649
+ const warnSettingsInOverride = (eslintConfig, options) => {
1650
+ if (eslintConfig.settings !== void 0 && eslintConfig.settings !== null && Object.keys(eslintConfig.settings).length > 0) {
1651
+ const settingsKeys = Object.keys(eslintConfig.settings).join(", ");
1652
+ options?.reporter?.addWarning(`Settings found in config with 'files' pattern (${settingsKeys}). Oxlint does not support settings in overrides, these settings will be skipped.`);
1653
+ }
1587
1654
  };
1588
- var src_default = main;
1589
1655
 
1590
1656
  //#endregion
1591
- export { rules_exports as a, nurseryRules as i, preFixForJsPlugins as n, isOffValue as r, src_default as t };
1657
+ export { preFixForJsPlugins as a, cleanUpOxlintConfig as c, transformRuleEntry as d, nurseryRules as f, transformEnvAndGlobals as h, fixForJsPlugins as i, detectNeededRulesPlugins as l, detectEnvironmentByGlobals as m, warnSettingsInOverride as n, detectSameOverride as o, rules_exports as p, processConfigFiles as r, transformIgnorePatterns as s, transformSettings as t, isOffValue as u };
@@ -2671,6 +2671,8 @@ type OxlintConfigJsPlugins = string[];
2671
2671
  type OxlintConfigCategories = Partial<Record<Category, unknown>>;
2672
2672
  type OxlintConfigEnv = Record<string, boolean>;
2673
2673
  type OxlintConfigIgnorePatterns = string[];
2674
+ type OxlintSupportedSettingsKey = 'jsx-a11y' | 'next' | 'react' | 'jsdoc' | 'vitest';
2675
+ type OxlintSettings = { [K in OxlintSupportedSettingsKey]?: Record<string, unknown> } & Record<string, Record<string, unknown> | undefined>;
2674
2676
  type OxlintConfigOverride = {
2675
2677
  files: string[];
2676
2678
  env?: OxlintConfigEnv;
@@ -2690,6 +2692,7 @@ type OxlintConfig = {
2690
2692
  rules?: Partial<Linter.RulesRecord>;
2691
2693
  overrides?: OxlintConfigOverride[];
2692
2694
  ignorePatterns?: OxlintConfigIgnorePatterns;
2695
+ settings?: OxlintSettings;
2693
2696
  };
2694
2697
  type RuleSkippedCategory = 'nursery' | 'type-aware' | 'unsupported' | 'js-plugins';
2695
2698
  type SkippedCategoryGroup = Record<RuleSkippedCategory, string[]>;
@@ -1,3 +1,59 @@
1
- import { t as src_default } from "../src-BMWXAQvA.mjs";
1
+ import { c as cleanUpOxlintConfig, d as transformRuleEntry, h as transformEnvAndGlobals, i as fixForJsPlugins, l as detectNeededRulesPlugins, m as detectEnvironmentByGlobals, n as warnSettingsInOverride, o as detectSameOverride, r as processConfigFiles, s as transformIgnorePatterns, t as transformSettings } from "../settings-DozKYNAk.mjs";
2
2
 
3
- export { src_default as default };
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
+ for (const config of configs) {
26
+ if (config.name?.startsWith("oxlint/")) continue;
27
+ let targetConfig;
28
+ if (config.files === void 0) targetConfig = oxlintConfig;
29
+ else {
30
+ const validFiles = processConfigFiles(config.files, options?.reporter);
31
+ if (validFiles.length === 0) continue;
32
+ targetConfig = { files: validFiles };
33
+ const [push, result] = detectSameOverride(oxlintConfig, targetConfig);
34
+ if (push) overrides.push(result);
35
+ }
36
+ transformIgnorePatterns(config, targetConfig, options);
37
+ transformRuleEntry(config, targetConfig, config.files !== void 0 ? oxlintConfig : void 0, options, config.files === void 0 ? overrides : void 0);
38
+ transformEnvAndGlobals(config, targetConfig, options);
39
+ if (config.files === void 0) transformSettings(config, oxlintConfig, options);
40
+ else warnSettingsInOverride(config, options);
41
+ if ("files" in targetConfig) {
42
+ detectNeededRulesPlugins(targetConfig);
43
+ detectEnvironmentByGlobals(targetConfig);
44
+ cleanUpOxlintConfig(targetConfig);
45
+ }
46
+ }
47
+ oxlintConfig.overrides = overrides;
48
+ detectNeededRulesPlugins(oxlintConfig);
49
+ detectEnvironmentByGlobals(oxlintConfig);
50
+ cleanUpOxlintConfig(oxlintConfig);
51
+ return oxlintConfig;
52
+ };
53
+ const main = async (configs, oxlintConfig, options) => {
54
+ const resolved = await Promise.resolve(fixForJsPlugins(configs));
55
+ return buildConfig(Array.isArray(resolved) ? resolved : [resolved], oxlintConfig, options);
56
+ };
57
+
58
+ //#endregion
59
+ export { main as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxlint/migrate",
3
- "version": "1.43.0",
3
+ "version": "1.48.0",
4
4
  "description": "Generates a `.oxlintrc.json` from a existing eslint flat config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -68,24 +68,20 @@
68
68
  "eslint-plugin-react": "^7.37.5",
69
69
  "eslint-plugin-react-hooks": "^7.0.1",
70
70
  "eslint-plugin-react-perf": "^3.3.3",
71
- "eslint-plugin-react-refresh": "^0.4.26",
71
+ "eslint-plugin-react-refresh": "^0.5.0",
72
72
  "eslint-plugin-regexp": "^3.0.0",
73
73
  "eslint-plugin-tsdoc": "^0.5.0",
74
74
  "eslint-plugin-unicorn": "^62.0.0",
75
75
  "husky": "^9.1.7",
76
- "jiti": "^2.4.2",
77
76
  "lint-staged": "^16.1.2",
78
77
  "next": "^16.0.0",
79
78
  "oxfmt": "^0.28.0",
80
- "oxlint": "^1.43.0",
79
+ "oxlint": "^1.48.0",
81
80
  "oxlint-tsgolint": "^0.11.3",
82
81
  "tsdown": "^0.20.0",
83
82
  "typescript-eslint": "^8.35.0",
84
83
  "vitest": "^4.0.0"
85
84
  },
86
- "peerDependencies": {
87
- "jiti": "*"
88
- },
89
85
  "lint-staged": {
90
86
  "*": "oxfmt --no-error-on-unmatched-pattern"
91
87
  },