@oxlint/migrate 1.71.0 → 1.73.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
@@ -115,3 +115,11 @@ Depending on how this is implemented by the given config, these behaviors may no
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
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.
118
+
119
+ ## ❤ Who's [Sponsoring Oxc](https://github.com/sponsors/Boshen)?
120
+
121
+ <p align="center">
122
+ <a href="https://github.com/sponsors/Boshen">
123
+ <img src="https://raw.githubusercontent.com/Boshen/sponsors/main/sponsors.svg" alt="Our sponsors" />
124
+ </a>
125
+ </p>
@@ -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, s as normalizeRuleToCanonical, t as main } from "../src-CLLHiI8g.mjs";
2
+ import { a as nurseryRules, i as buildUnsupportedRuleExplanations, n as preFixForJsPlugins, o as rules_exports, r as isOffValue, s as normalizeRuleToCanonical, t as main } from "../src-aj7n0D2s.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.71.0";
33
+ var version = "1.73.0";
34
34
  //#endregion
35
35
  //#region src/walker/comments/replaceRuleDirectiveComment.ts
36
36
  const allRulesSet = new Set(Object.values(rules_exports).flat());
@@ -414,6 +414,25 @@ const getFileContent = (absoluteFilePath) => {
414
414
  }
415
415
  };
416
416
  /**
417
+ * Strips JSON comments (single-line `//` and multi-line) and trailing commas
418
+ * so that `tsconfig.json` (which is actually JSONC) can be parsed with `JSON.parse`.
419
+ */
420
+ const stripJsoncFeatures = (text) => text.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/,\s*([}\]])/g, "$1");
421
+ /**
422
+ * When `--type-aware` is used, check whether the project's `tsconfig.json`
423
+ * contains a `baseUrl` value in `compilerOptions`. If it does, emit a warning
424
+ * because `tsgo` does not support `baseUrl`, which may cause issues with
425
+ * type-aware linting.
426
+ */
427
+ const warnIfTsconfigHasBaseUrl = (reporter) => {
428
+ const content = getFileContent(path.join(cwd, "tsconfig.json"));
429
+ if (content === void 0) return;
430
+ try {
431
+ const tsconfig = JSON.parse(stripJsoncFeatures(content));
432
+ if (tsconfig?.compilerOptions?.baseUrl !== void 0) reporter.addWarning(`tsconfig.json has \`baseUrl\` set to ${JSON.stringify(tsconfig.compilerOptions.baseUrl)}. \`baseUrl\` is not supported by tsgo, which may cause issues with type-aware linting. Consider removing \`baseUrl\` or using path aliases instead.`);
433
+ } catch {}
434
+ };
435
+ /**
417
436
  * Count enabled rules (excluding "off" rules) from both rules and overrides
418
437
  */
419
438
  const countEnabledRules = (config) => {
@@ -440,6 +459,7 @@ program.name("oxlint-migrate").version(version).argument("[eslint-config]", "The
440
459
  typeAware: !!cliOptions.typeAware,
441
460
  jsPlugins
442
461
  };
462
+ if (options.typeAware) warnIfTsconfigHasBaseUrl(reporter);
443
463
  if (cliOptions.replaceEslintComments) {
444
464
  await walkAndReplaceProjectFiles(await getAllProjectFiles(), (filePath) => getFileContent(filePath), (filePath, content) => writeFile(filePath, content, "utf-8"), options);
445
465
  return;
@@ -4,7 +4,7 @@
4
4
  /**
5
5
  * What to enforce for `/// <reference types="..." />` references.
6
6
  */
7
- //#region node_modules/.pnpm/oxlint@1.71.0_oxlint-tsgolint@0.23.0/node_modules/oxlint/dist/index.d.ts
7
+ //#region node_modules/.pnpm/oxlint@1.73.0_oxlint-tsgolint@0.24.0/node_modules/oxlint/dist/index.d.ts
8
8
  //#region src-js/package/config.generated.d.ts
9
9
  type AllowWarnDeny = ("allow" | "off" | "warn" | "error" | "deny") | number;
10
10
  type GlobalValue = ("readonly" | "writable" | "off") | undefined;
@@ -116,11 +116,15 @@ type AllowKind = "functions" | "arrowFunctions" | "generatorFunctions" | "method
116
116
  type NoInnerDeclarationsConfig = "functions" | "both";
117
117
  type BlockScopedFunctions = "allow" | "disallow";
118
118
  type NoMagicNumbersNumber = number | string;
119
+ type NoRestrictedImportsConfigEnum = string | RestrictedPath | NoRestrictedImportsConfig;
120
+ type PossiblePaths = string | RestrictedPath;
121
+ type PossiblePatterns = string | RestrictedPattern;
119
122
  type NoReturnAssignMode = "always" | "except-parens";
120
123
  /**
121
124
  * Controls how hoisting is handled when checking for shadowing.
122
125
  */
123
126
  type HoistOption = "all" | "functions" | "functions-and-types" | "never" | "types";
127
+ type LoopType = "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement";
124
128
  type NoUnusedVarsConfig = VarsOption | NoUnusedVarsOptions;
125
129
  type VarsOption = "all" | "local";
126
130
  type ArgsOption = "after-used" | "all" | "none";
@@ -142,6 +146,7 @@ type CallbackReturn = string[];
142
146
  * - a regexp pattern (e.g. `"^(err|error)$"`)
143
147
  *
144
148
  * If the configured name of the error variable begins with a `^` it is considered to be a regexp pattern.
149
+ * Invalid regexp patterns are rejected during configuration parsing.
145
150
  *
146
151
  * Default: `"err"`.
147
152
  */
@@ -292,6 +297,7 @@ type PathOption = "always" | "never";
292
297
  type TypesOption = "always" | "never" | "prefer-import";
293
298
  type BomOptionType = "always" | "never";
294
299
  type NonZero = "greater-than" | "not-equal";
300
+ type ExplicitTimerDelayMode = "always" | "never";
295
301
  type ModuleStylesOverride = (false | {
296
302
  /**
297
303
  * Whether default imports or whole-module `require()` assignments are allowed for this module.
@@ -1012,7 +1018,7 @@ interface DummyRuleMap {
1012
1018
  "no-cond-assign"?: RuleNoConfig | [AllowWarnDeny, NoCondAssignConfig];
1013
1019
  "no-console"?: RuleNoConfig | [AllowWarnDeny, NoConsoleConfig];
1014
1020
  "no-const-assign"?: RuleNoConfig;
1015
- "no-constant-binary-expression"?: RuleNoConfig;
1021
+ "no-constant-binary-expression"?: RuleNoConfig | [AllowWarnDeny, NoConstantBinaryExpressionConfig];
1016
1022
  "no-constant-condition"?: RuleNoConfig | [AllowWarnDeny, NoConstantCondition];
1017
1023
  "no-constructor-return"?: RuleNoConfig;
1018
1024
  "no-continue"?: RuleNoConfig;
@@ -1078,7 +1084,7 @@ interface DummyRuleMap {
1078
1084
  "no-regex-spaces"?: RuleNoConfig;
1079
1085
  "no-restricted-exports"?: RuleNoConfig | [AllowWarnDeny, NoRestrictedExportsConfig];
1080
1086
  "no-restricted-globals"?: DummyRule;
1081
- "no-restricted-imports"?: DummyRule;
1087
+ "no-restricted-imports"?: RuleNoConfig | [AllowWarnDeny, NoRestrictedImportsConfigEnum, ...NoRestrictedImportsConfigEnum[]];
1082
1088
  "no-restricted-properties"?: RuleNoConfig | [AllowWarnDeny, PropertyDetails, ...PropertyDetails[]];
1083
1089
  "no-return-assign"?: RuleNoConfig | [AllowWarnDeny, NoReturnAssignMode];
1084
1090
  "no-script-url"?: RuleNoConfig;
@@ -1101,6 +1107,7 @@ interface DummyRuleMap {
1101
1107
  "no-unmodified-loop-condition"?: RuleNoConfig;
1102
1108
  "no-unneeded-ternary"?: RuleNoConfig | [AllowWarnDeny, NoUnneededTernary];
1103
1109
  "no-unreachable"?: RuleNoConfig;
1110
+ "no-unreachable-loop"?: RuleNoConfig | [AllowWarnDeny, NoUnreachableLoopConfig];
1104
1111
  "no-unsafe-finally"?: RuleNoConfig;
1105
1112
  "no-unsafe-negation"?: RuleNoConfig | [AllowWarnDeny, NoUnsafeNegation];
1106
1113
  "no-unsafe-optional-chaining"?: RuleNoConfig | [AllowWarnDeny, NoUnsafeOptionalChaining];
@@ -1388,6 +1395,7 @@ interface DummyRuleMap {
1388
1395
  "unicorn/error-message"?: RuleNoConfig;
1389
1396
  "unicorn/escape-case"?: RuleNoConfig;
1390
1397
  "unicorn/explicit-length-check"?: RuleNoConfig | [AllowWarnDeny, ExplicitLengthCheck];
1398
+ "unicorn/explicit-timer-delay"?: RuleNoConfig | [AllowWarnDeny, ExplicitTimerDelayMode];
1391
1399
  "unicorn/filename-case"?: DummyRule;
1392
1400
  "unicorn/import-style"?: RuleNoConfig | [AllowWarnDeny, ImportStyleConfig];
1393
1401
  "unicorn/max-nested-calls"?: RuleNoConfig | [AllowWarnDeny, MaxNestedCalls];
@@ -1404,6 +1412,7 @@ interface DummyRuleMap {
1404
1412
  "unicorn/no-array-sort"?: RuleNoConfig | [AllowWarnDeny, NoArraySort];
1405
1413
  "unicorn/no-await-expression-member"?: RuleNoConfig;
1406
1414
  "unicorn/no-await-in-promise-methods"?: RuleNoConfig;
1415
+ "unicorn/no-confusing-array-with"?: RuleNoConfig;
1407
1416
  "unicorn/no-console-spaces"?: RuleNoConfig;
1408
1417
  "unicorn/no-document-cookie"?: RuleNoConfig;
1409
1418
  "unicorn/no-empty-file"?: RuleNoConfig;
@@ -2265,6 +2274,7 @@ interface PreferEndingWithAnExpectConfig {
2265
2274
  additionalTestBlockFunctions?: string[];
2266
2275
  /**
2267
2276
  * A list of function names that should be treated as assertion functions.
2277
+ * Default: `["expect"]`
2268
2278
  */
2269
2279
  assertFunctionNames?: string[];
2270
2280
  }
@@ -2789,6 +2799,9 @@ interface NoConsoleConfig {
2789
2799
  */
2790
2800
  allow?: string[];
2791
2801
  }
2802
+ interface NoConstantBinaryExpressionConfig {
2803
+ checkRelationalComparisons?: boolean;
2804
+ }
2792
2805
  interface NoConstantCondition {
2793
2806
  /**
2794
2807
  * Configuration option to specify whether to check for constant conditions in loops.
@@ -3305,6 +3318,28 @@ interface RestrictDefaultExports {
3305
3318
  */
3306
3319
  namespaceFrom?: boolean;
3307
3320
  }
3321
+ interface RestrictedPath {
3322
+ allowImportNames?: string[];
3323
+ allowTypeImports?: boolean;
3324
+ importNames?: string[];
3325
+ message?: string;
3326
+ name: string;
3327
+ }
3328
+ interface NoRestrictedImportsConfig {
3329
+ paths?: PossiblePaths[];
3330
+ patterns?: PossiblePatterns[];
3331
+ }
3332
+ interface RestrictedPattern {
3333
+ allowImportNamePattern?: string;
3334
+ allowImportNames?: string[];
3335
+ allowTypeImports?: boolean;
3336
+ caseSensitive?: boolean;
3337
+ group?: string[];
3338
+ importNamePattern?: string;
3339
+ importNames?: string[];
3340
+ message?: string;
3341
+ regex?: string;
3342
+ }
3308
3343
  interface PropertyDetails {
3309
3344
  /**
3310
3345
  * Objects where property access should be allowed. This must be used with `property` and
@@ -3443,6 +3478,9 @@ interface NoUnneededTernary {
3443
3478
  */
3444
3479
  defaultAssignment?: boolean;
3445
3480
  }
3481
+ interface NoUnreachableLoopConfig {
3482
+ ignore?: LoopType[];
3483
+ }
3446
3484
  interface NoUnsafeNegation {
3447
3485
  /**
3448
3486
  * The `enforceForOrderingRelations` option determines whether negation is allowed
@@ -4227,20 +4265,20 @@ interface ForbidItemObject {
4227
4265
  * Component names for which this prop is **allowed** (all others are
4228
4266
  * forbidden).
4229
4267
  */
4230
- allowedFor: string[];
4268
+ allowedFor?: string[];
4231
4269
  /**
4232
4270
  * Glob patterns for component names where the prop is **allowed**.
4233
4271
  */
4234
- allowedForPatterns: string[];
4272
+ allowedForPatterns?: string[];
4235
4273
  /**
4236
4274
  * Component names for which this prop is **disallowed** (all others are
4237
4275
  * allowed).
4238
4276
  */
4239
- disallowedFor: string[];
4277
+ disallowedFor?: string[];
4240
4278
  /**
4241
4279
  * Glob patterns for component names where the prop is **disallowed**.
4242
4280
  */
4243
- disallowedForPatterns: string[];
4281
+ disallowedForPatterns?: string[];
4244
4282
  /**
4245
4283
  * Custom message to display.
4246
4284
  */
@@ -4262,7 +4300,7 @@ interface ForbidDomPropsConfig {
4262
4300
  * An array of prop names or objects that are forbidden on DOM elements.
4263
4301
  *
4264
4302
  * Each array element can be a string with the property name, or an object
4265
- * with `propName`, an optional `disallowedFor` array of DOM node names,
4303
+ * with `propName`, optional `disallowedFor` and `disallowedValues` arrays,
4266
4304
  * and an optional custom `message`.
4267
4305
  *
4268
4306
  * Examples:
@@ -4270,11 +4308,13 @@ interface ForbidDomPropsConfig {
4270
4308
  * - `["error", { "forbid": ["id", "style"] }]`
4271
4309
  * - `["error", { "forbid": [{ "propName": "className", "message": "Use class instead" }] }]`
4272
4310
  * - `["error", { "forbid": [{ "propName": "style", "disallowedFor": ["div", "span"] }] }]`
4311
+ * - `["error", { "forbid": [{ "propName": "type", "disallowedValues": ["button"] }] }]`
4273
4312
  */
4274
4313
  forbid?: ForbidDomPropsItem[];
4275
4314
  }
4276
4315
  /**
4277
- * A prop with optional `disallowedFor` DOM node list and custom `message`.
4316
+ * A prop with optional `disallowedFor` DOM node list, optional `disallowedValues`
4317
+ * value list, and custom `message`.
4278
4318
  */
4279
4319
  interface PropWithOptions {
4280
4320
  /**
@@ -4283,6 +4323,11 @@ interface PropWithOptions {
4283
4323
  * DOM elements.
4284
4324
  */
4285
4325
  disallowedFor?: string[];
4326
+ /**
4327
+ * A list of string literal values for which this prop is forbidden. If
4328
+ * omitted, the prop is forbidden for all values.
4329
+ */
4330
+ disallowedValues?: string[];
4286
4331
  /**
4287
4332
  * A custom message to display when this prop is used.
4288
4333
  */
@@ -5934,6 +5979,16 @@ interface NoArrayReverse {
5934
5979
  allowExpressionStatement?: boolean;
5935
5980
  }
5936
5981
  interface NoArraySort {
5982
+ /**
5983
+ * When set to `true`, allows sorting a fresh array created by a spread, e.g. `[...iterable].sort()`.
5984
+ * This avoids the double allocation of `toSorted()` when sorting an iterable such as a `Set`.
5985
+ *
5986
+ * Example of **correct** code for this rule with `allowAfterSpread` set to `true`:
5987
+ * ```js
5988
+ * const sorted = [...mySet].sort();
5989
+ * ```
5990
+ */
5991
+ allowAfterSpread?: boolean;
5937
5992
  /**
5938
5993
  * When set to `true` (default), allows `array.sort()` as an expression statement.
5939
5994
  * Set to `false` to forbid `Array#sort()` even if it's an expression statement.
@@ -1,2 +1,2 @@
1
- import { t as main } from "../src-CLLHiI8g.mjs";
1
+ import { t as main } from "../src-aj7n0D2s.mjs";
2
2
  export { main as default };
@@ -706,6 +706,7 @@ const styleRules = [
706
706
  "unicorn/custom-error-definition",
707
707
  "unicorn/empty-brace-spaces",
708
708
  "unicorn/error-message",
709
+ "unicorn/explicit-timer-delay",
709
710
  "unicorn/filename-case",
710
711
  "unicorn/max-nested-calls",
711
712
  "unicorn/no-array-method-this-argument",
@@ -862,6 +863,7 @@ const suspiciousRules = [
862
863
  "unicorn/no-array-fill-with-reference-type",
863
864
  "unicorn/no-array-reverse",
864
865
  "unicorn/no-array-sort",
866
+ "unicorn/no-confusing-array-with",
865
867
  "unicorn/no-instanceof-builtins",
866
868
  "unicorn/prefer-add-event-listener",
867
869
  "unicorn/require-module-specifiers",
@@ -1238,6 +1240,7 @@ const perfRules = [
1238
1240
  const nurseryRules = [
1239
1241
  "no-restricted-exports",
1240
1242
  "no-undef",
1243
+ "no-unreachable-loop",
1241
1244
  "no-useless-assignment",
1242
1245
  "import/export",
1243
1246
  "import/named",
@@ -1351,6 +1354,15 @@ var unsupportedRules = {
1351
1354
  "import/no-deprecated": "No need to implement, already implemented by `typescript/no-deprecated` via tsgolint.",
1352
1355
  "n/no-restricted-import": "No need to implement, already implemented by `no-restricted-imports` rule.",
1353
1356
  "n/no-restricted-require": "No need to implement, already implemented by `no-restricted-imports` rule.",
1357
+ "n/prefer-global/buffer": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1358
+ "n/prefer-global/console": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1359
+ "n/prefer-global/crypto": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1360
+ "n/prefer-global/process": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1361
+ "n/prefer-global/text-decoder": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1362
+ "n/prefer-global/text-encoder": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1363
+ "n/prefer-global/timers": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1364
+ "n/prefer-global/url": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1365
+ "n/prefer-global/url-search-params": "No need to implement, the same policy can be enforced with generic restriction rules such as `no-restricted-imports` and `no-restricted-globals`.",
1354
1366
  "import/order": "Not implementing this in Oxlint as its behavior is covered very well by [Oxfmt's import sorting](https://oxc.rs/docs/guide/usage/formatter/sorting.html).",
1355
1367
  "unicorn/template-indent": "Stylistic rule.",
1356
1368
  "jsdoc/type-formatting": "Experimental rule in the original plugin, may reconsider once stable.",
@@ -1518,6 +1530,7 @@ var unsupportedRules = {
1518
1530
  "react/jsx-uses-vars": "Handled by `eslint/no-unused-vars`, which already evaluates whether vars are used in JSX.",
1519
1531
  "unicorn/no-named-default": "Implemented via `import/no-named-default`.",
1520
1532
  "unicorn/no-double-comparison": "Use `oxc/double-comparisons` instead.",
1533
+ "unicorn/no-chained-comparison": "Use `oxc/bad-comparison-sequence` instead. TypeScript also reports errors for these comparisons.",
1521
1534
  "vue/no-lone-template": "Not currently possible, as it requires Vue template parsing.",
1522
1535
  "vue/no-v-html": "Not currently possible, as it requires Vue template parsing.",
1523
1536
  "vue/this-in-template": "Not currently possible, as it requires Vue template parsing.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxlint/migrate",
3
- "version": "1.71.0",
3
+ "version": "1.73.0",
4
4
  "description": "Generates a `.oxlintrc.json` from a existing eslint flat config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -40,12 +40,12 @@
40
40
  "dependencies": {
41
41
  "commander": "^15.0.0",
42
42
  "globals": "^17.0.0",
43
- "oxc-parser": "^0.137.0",
43
+ "oxc-parser": "^0.138.0",
44
44
  "tinyglobby": "^0.2.14"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@antfu/eslint-config": "^9.0.0",
48
- "@babel/eslint-plugin": "^7.27.1",
48
+ "@babel/eslint-plugin": "^8.0.0",
49
49
  "@e18e/eslint-plugin": "^0.5.0",
50
50
  "@eslint-react/eslint-plugin": "^5.0.0",
51
51
  "@eslint/js": "^10.0.0",
@@ -79,13 +79,13 @@
79
79
  "eslint-plugin-react-web-api": "^5.0.0",
80
80
  "eslint-plugin-regexp": "^3.0.0",
81
81
  "eslint-plugin-tsdoc": "^0.5.0",
82
- "eslint-plugin-unicorn": "^65.0.0",
82
+ "eslint-plugin-unicorn": "^67.0.0",
83
83
  "husky": "^9.1.7",
84
84
  "lint-staged": "^17.0.0",
85
85
  "next": "^16.0.0",
86
- "oxfmt": "^0.55.0",
87
- "oxlint": "^1.71.0",
88
- "oxlint-tsgolint": "^0.23.0",
86
+ "oxfmt": "^0.57.0",
87
+ "oxlint": "^1.73.0",
88
+ "oxlint-tsgolint": "^0.24.0",
89
89
  "tsdown": "^0.22.0",
90
90
  "typescript": "^6.0.0",
91
91
  "typescript-eslint": "^8.35.0",
@@ -94,5 +94,5 @@
94
94
  "lint-staged": {
95
95
  "*": "oxfmt --no-error-on-unmatched-pattern"
96
96
  },
97
- "packageManager": "pnpm@11.8.0"
97
+ "packageManager": "pnpm@11.9.0"
98
98
  }