@oxlint/migrate 1.3.0 → 1.5.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
@@ -32,6 +32,11 @@ This behavior can change in the future.
32
32
  - Execute `npx @oxlint/migrate`
33
33
  - (Optional): Disable supported rules via [eslint-plugin-oxlint](https://github.com/oxc-project/eslint-plugin-oxlint)
34
34
 
35
+ ### TypeScript ESLint Configuration Files
36
+
37
+ For Deno and Bun, TypeScript configuration files, like `eslint.config.mts`, are natively supported.
38
+ For Node.js, you must install [jiti](https://www.npmjs.com/package/jiti) as a dev dependency.
39
+
35
40
  ## Contributing
36
41
 
37
42
  ### Generate rules
@@ -0,0 +1,46 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ const FLAT_CONFIG_FILENAMES = [
5
+ "eslint.config.js",
6
+ "eslint.config.mjs",
7
+ "eslint.config.cjs",
8
+ "eslint.config.ts",
9
+ "eslint.config.mts",
10
+ "eslint.config.cts"
11
+ ];
12
+ const getAutodetectedEslintConfigName = (cwd) => {
13
+ for (const filename of FLAT_CONFIG_FILENAMES) {
14
+ const filePath = path.join(cwd, filename);
15
+ if (existsSync(filePath)) {
16
+ return filePath;
17
+ }
18
+ }
19
+ };
20
+ const loadESLintConfig = async (filePath) => {
21
+ if (filePath.endsWith("json")) {
22
+ throw new Error(
23
+ `json format is not supported. @oxlint/migrate only supports the eslint flat configuration`
24
+ );
25
+ }
26
+ let url = pathToFileURL(filePath).toString();
27
+ if (!existsSync(filePath)) {
28
+ throw new Error(`eslint config file not found: ${filePath}`);
29
+ }
30
+ if ("Bun" in globalThis || "Deno" in globalThis) {
31
+ return import(url);
32
+ }
33
+ if (filePath.endsWith(".ts") || filePath.endsWith(".mts") || filePath.endsWith(".cts")) {
34
+ const { createJiti } = await import("jiti");
35
+ const jitiInstance = createJiti(filePath, {
36
+ interopDefault: false,
37
+ moduleCache: false
38
+ });
39
+ return jitiInstance.import(url);
40
+ }
41
+ return import(url);
42
+ };
43
+ export {
44
+ getAutodetectedEslintConfigName,
45
+ loadESLintConfig
46
+ };
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { program } from "commander";
3
- import { getAutodetectedEslintConfigName } from "./autoDetectConfigFile.mjs";
4
- import { existsSync, readFileSync, renameSync, writeFileSync } from "fs";
3
+ import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { getAutodetectedEslintConfigName, loadESLintConfig } from "./config-loader.mjs";
5
6
  import main from "../src/index.mjs";
6
- import path from "path";
7
7
  import packageJson from "../package.json.mjs";
8
- import { pathToFileURL } from "node:url";
9
8
  const cwd = process.cwd();
10
9
  program.name("oxlint-migrate").version(packageJson.version).argument("[eslint-config]", "The path to the eslint v9 config file").option(
11
10
  "--output-file <file>",
@@ -30,15 +29,7 @@ program.name("oxlint-migrate").version(packageJson.version).argument("[eslint-co
30
29
  if (filePath === void 0) {
31
30
  program.error(`could not autodetect eslint config file`);
32
31
  }
33
- if (filePath.endsWith("json")) {
34
- program.error(
35
- `json format is not supported. @oxlint/migrate only supports the eslint flat configuration`
36
- );
37
- }
38
- if (!existsSync(filePath)) {
39
- program.error(`eslint config file not found: ${filePath}`);
40
- }
41
- const eslintConfigs = await import(pathToFileURL(filePath).toString());
32
+ const eslintConfigs = await loadESLintConfig(filePath);
42
33
  const options = {
43
34
  reporter: console.warn,
44
35
  merge: !!cliOptions.merge,
@@ -1,4 +1,4 @@
1
- const version = "1.3.0";
1
+ const version = "1.5.0";
2
2
  const packageJson = {
3
3
  version
4
4
  };
@@ -1,6 +1,6 @@
1
1
  export declare const pedanticRules: string[];
2
- export declare const suspiciousRules: string[];
3
2
  export declare const styleRules: string[];
3
+ export declare const suspiciousRules: string[];
4
4
  export declare const restrictionRules: string[];
5
5
  export declare const correctnessRules: string[];
6
6
  export declare const nurseryRules: string[];
@@ -87,49 +87,8 @@ const pedanticRules = [
87
87
  "import-x/max-dependencies",
88
88
  "vitest/no-conditional-in-test"
89
89
  ];
90
- const suspiciousRules = [
91
- "block-scoped-var",
92
- "no-extra-bind",
93
- "no-unneeded-ternary",
94
- "no-extend-native",
95
- "no-new",
96
- "no-unexpected-multiline",
97
- "no-useless-concat",
98
- "no-useless-constructor",
99
- "import/no-unassigned-import",
100
- "import/no-empty-named-blocks",
101
- "import/no-absolute-path",
102
- "import/no-duplicates",
103
- "import/no-named-as-default",
104
- "import/no-named-as-default-member",
105
- "import/no-self-import",
106
- "jest/no-commented-out-tests",
107
- "promise/no-promise-in-callback",
108
- "react/iframe-missing-sandbox",
109
- "react/jsx-no-comment-textnodes",
110
- "react/jsx-no-script-url",
111
- "react/no-namespace",
112
- "react/react-in-jsx-scope",
113
- "react/style-prop-object",
114
- "@typescript-eslint/no-confusing-non-null-assertion",
115
- "@typescript-eslint/no-extraneous-class",
116
- "@typescript-eslint/no-unnecessary-type-constraint",
117
- "unicorn/consistent-function-scoping",
118
- "unicorn/no-instanceof-builtins",
119
- "unicorn/no-accessor-recursion",
120
- "unicorn/prefer-add-event-listener",
121
- "unicorn/require-post-message-target-origin",
122
- "@typescript-eslint/no-useless-constructor",
123
- "import-x/no-unassigned-import",
124
- "import-x/no-empty-named-blocks",
125
- "import-x/no-absolute-path",
126
- "import-x/no-duplicates",
127
- "import-x/no-named-as-default",
128
- "import-x/no-named-as-default-member",
129
- "import-x/no-self-import",
130
- "vitest/no-commented-out-tests"
131
- ];
132
90
  const styleRules = [
91
+ "arrow-body-style",
133
92
  "curly",
134
93
  "default-case-last",
135
94
  "default-param-last",
@@ -137,6 +96,7 @@ const styleRules = [
137
96
  "func-names",
138
97
  "grouped-accessor-pairs",
139
98
  "guard-for-in",
99
+ "id-length",
140
100
  "init-declarations",
141
101
  "max-params",
142
102
  "new-cap",
@@ -175,6 +135,8 @@ const styleRules = [
175
135
  "import/no-mutable-exports",
176
136
  "import/no-named-default",
177
137
  "import/no-namespace",
138
+ "import/no-duplicates",
139
+ "import/prefer-default-export",
178
140
  "jest/consistent-test-it",
179
141
  "jest/max-expects",
180
142
  "jest/max-nested-describe",
@@ -246,6 +208,7 @@ const styleRules = [
246
208
  "unicorn/no-array-method-this-argument",
247
209
  "unicorn/no-await-expression-member",
248
210
  "unicorn/no-console-spaces",
211
+ "unicorn/no-nested-ternary",
249
212
  "unicorn/no-null",
250
213
  "unicorn/no-unreadable-array-destructuring",
251
214
  "unicorn/no-zero-fractions",
@@ -286,6 +249,8 @@ const styleRules = [
286
249
  "import-x/no-mutable-exports",
287
250
  "import-x/no-named-default",
288
251
  "import-x/no-namespace",
252
+ "import-x/no-duplicates",
253
+ "import-x/prefer-default-export",
289
254
  "vitest/consistent-test-it",
290
255
  "vitest/max-expects",
291
256
  "vitest/max-nested-describe",
@@ -311,6 +276,46 @@ const styleRules = [
311
276
  "vitest/prefer-todo",
312
277
  "vitest/require-top-level-describe"
313
278
  ];
279
+ const suspiciousRules = [
280
+ "block-scoped-var",
281
+ "no-extra-bind",
282
+ "no-unneeded-ternary",
283
+ "no-extend-native",
284
+ "no-new",
285
+ "no-unexpected-multiline",
286
+ "no-useless-concat",
287
+ "no-useless-constructor",
288
+ "import/no-unassigned-import",
289
+ "import/no-empty-named-blocks",
290
+ "import/no-absolute-path",
291
+ "import/no-named-as-default",
292
+ "import/no-named-as-default-member",
293
+ "import/no-self-import",
294
+ "jest/no-commented-out-tests",
295
+ "promise/no-promise-in-callback",
296
+ "react/iframe-missing-sandbox",
297
+ "react/jsx-no-comment-textnodes",
298
+ "react/jsx-no-script-url",
299
+ "react/no-namespace",
300
+ "react/react-in-jsx-scope",
301
+ "react/style-prop-object",
302
+ "@typescript-eslint/no-confusing-non-null-assertion",
303
+ "@typescript-eslint/no-extraneous-class",
304
+ "@typescript-eslint/no-unnecessary-type-constraint",
305
+ "unicorn/consistent-function-scoping",
306
+ "unicorn/no-instanceof-builtins",
307
+ "unicorn/no-accessor-recursion",
308
+ "unicorn/prefer-add-event-listener",
309
+ "unicorn/require-post-message-target-origin",
310
+ "@typescript-eslint/no-useless-constructor",
311
+ "import-x/no-unassigned-import",
312
+ "import-x/no-empty-named-blocks",
313
+ "import-x/no-absolute-path",
314
+ "import-x/no-named-as-default",
315
+ "import-x/no-named-as-default-member",
316
+ "import-x/no-self-import",
317
+ "vitest/no-commented-out-tests"
318
+ ];
314
319
  const restrictionRules = [
315
320
  "default-case",
316
321
  "no-alert",
@@ -368,7 +373,6 @@ const restrictionRules = [
368
373
  "unicorn/no-document-cookie",
369
374
  "unicorn/no-length-as-slice-end",
370
375
  "unicorn/no-magic-array-flat-depth",
371
- "unicorn/no-nested-ternary",
372
376
  "unicorn/no-process-exit",
373
377
  "unicorn/prefer-modern-math-apis",
374
378
  "unicorn/prefer-node-protocol",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxlint/migrate",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Generates a `.oxlintrc.json` from a existing eslint flat config",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,37 +37,38 @@
37
37
  "author": "Sysix <sysix@sysix-coding.de>",
38
38
  "license": "MIT",
39
39
  "devDependencies": {
40
- "@antfu/eslint-config": "^4.2.0",
41
- "@eslint/eslintrc": "^3.3.0",
42
- "@eslint/js": "^9.20.0",
43
- "@logux/eslint-config": "^55.0.0",
44
- "@oxc-node/core": "^0.0.28",
45
- "@stylistic/eslint-plugin": "^4.0.1",
46
- "@stylistic/eslint-plugin-ts": "^4.0.0",
40
+ "@antfu/eslint-config": "^4.16.1",
41
+ "@eslint/eslintrc": "^3.3.1",
42
+ "@eslint/js": "^9.29.0",
43
+ "@logux/eslint-config": "^55.2.1",
44
+ "@oxc-node/core": "^0.0.29",
45
+ "@stylistic/eslint-plugin": "^5.0.0",
46
+ "@stylistic/eslint-plugin-ts": "^4.4.1",
47
47
  "@types/eslint-config-prettier": "^6.11.3",
48
- "@types/node": "^24.0.0",
49
- "@typescript-eslint/eslint-plugin": "^8.25.0",
50
- "@typescript-eslint/parser": "^8.25.0",
51
- "@vitest/coverage-v8": "^3.0.5",
52
- "eslint": "^9.20.1",
53
- "eslint-config-prettier": "^10.0.1",
48
+ "@types/node": "^24.0.4",
49
+ "@typescript-eslint/eslint-plugin": "^8.35.0",
50
+ "@typescript-eslint/parser": "^8.35.0",
51
+ "@vitest/coverage-v8": "^3.2.4",
52
+ "eslint": "^9.29.0",
53
+ "eslint-config-prettier": "^10.1.5",
54
54
  "eslint-plugin-header": "^3.1.1",
55
- "eslint-plugin-import": "^2.31.0",
56
- "eslint-plugin-import-x": "^4.6.1",
57
- "eslint-plugin-jsdoc": "^51.0.0",
55
+ "eslint-plugin-import": "^2.32.0",
56
+ "eslint-plugin-import-x": "^4.16.0",
57
+ "eslint-plugin-jsdoc": "^51.2.3",
58
58
  "eslint-plugin-local": "^6.0.0",
59
- "eslint-plugin-oxlint": "^1.0.0",
60
- "eslint-plugin-regexp": "^2.7.0",
61
- "eslint-plugin-unicorn": "^59.0.0",
59
+ "eslint-plugin-oxlint": "^1.3.0",
60
+ "eslint-plugin-regexp": "^2.9.0",
61
+ "eslint-plugin-unicorn": "^59.0.1",
62
62
  "husky": "^9.1.7",
63
- "lint-staged": "^16.0.0",
64
- "oxlint": "^1.3.0",
65
- "prettier": "^3.5.1",
66
- "typescript": "^5.7.3",
67
- "typescript-eslint": "^8.24.0",
68
- "vite": "^6.1.0",
69
- "vite-plugin-dts": "^4.5.0",
70
- "vitest": "^3.0.5"
63
+ "jiti": "^2.4.2",
64
+ "lint-staged": "^16.1.2",
65
+ "oxlint": "^1.5.0",
66
+ "prettier": "^3.6.1",
67
+ "typescript": "^5.8.3",
68
+ "typescript-eslint": "^8.35.0",
69
+ "vite": "^7.0.0",
70
+ "vite-plugin-dts": "^4.5.4",
71
+ "vitest": "^3.2.4"
71
72
  },
72
73
  "lint-staged": {
73
74
  "*": "prettier --ignore-unknown --write"
@@ -76,7 +77,8 @@
76
77
  "commander": "^14.0.0"
77
78
  },
78
79
  "peerDependencies": {
79
- "globals": "^14.0.0 || ^15.0.0 || ^16.0.0"
80
+ "globals": "^14.0.0 || ^15.0.0 || ^16.0.0",
81
+ "jiti": "*"
80
82
  },
81
- "packageManager": "pnpm@10.12.1"
83
+ "packageManager": "pnpm@10.12.4"
82
84
  }
@@ -1,21 +0,0 @@
1
- import { existsSync } from "fs";
2
- import path from "node:path";
3
- const FLAT_CONFIG_FILENAMES = [
4
- "eslint.config.js",
5
- "eslint.config.mjs",
6
- "eslint.config.cjs",
7
- "eslint.config.ts",
8
- "eslint.config.mts",
9
- "eslint.config.cts"
10
- ];
11
- const getAutodetectedEslintConfigName = (cwd) => {
12
- for (const filename of FLAT_CONFIG_FILENAMES) {
13
- const filePath = path.join(cwd, filename);
14
- if (existsSync(filePath)) {
15
- return filePath;
16
- }
17
- }
18
- };
19
- export {
20
- getAutodetectedEslintConfigName
21
- };