mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(oxlint,oxfmt): correct Node.js TypeScript support range (#27699)
TypeScript config load errors currently advertise `^20.19.0 || >=22.18.0`, even though Node 20 cannot load TypeScript files natively. Remove the Node 20 range from the shared Oxlint/Oxfmt diagnostic and the matching TypeScript plugin documentation, including generated schema, declarations, and website snapshot. Package engine requirements stay the same. Fixes #27678
This commit is contained in:
1 parent
5dc0152891
commit
9a424c209e
6 files changed
+20
-18
No files matched your search
@@ -596,7 +596,7 @@ export interface Oxlintrc {
|
||||
*
|
||||
* TypeScript plugin files are supported in the following environments:
|
||||
* - Deno and Bun: TypeScript files are supported natively.
|
||||
* - Node.js >=22.18.0 and Node.js ^20.19.0: TypeScript files are supported natively with built-in
|
||||
* - Node.js >=22.18.0: TypeScript files are supported natively with built-in
|
||||
* type-stripping enabled by default.
|
||||
*
|
||||
* For older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { extname as pathExtname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export const NODE_TYPESCRIPT_SUPPORT_RANGE = "^20.19.0 || >=22.18.0";
|
||||
export const NODE_TYPESCRIPT_SUPPORT_RANGE = ">=22.18.0";
|
||||
|
||||
const TS_MODULE_EXTENSIONS = new Set([".ts", ".mts", ".cts"]);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { expect, it } from "vitest";
|
||||
import {
|
||||
getUnsupportedTypeScriptModuleLoadHintForError,
|
||||
isTypeScriptModuleSpecifier,
|
||||
NODE_TYPESCRIPT_SUPPORT_RANGE,
|
||||
} from "../../src-js/js_config/node_version.ts";
|
||||
|
||||
it("detects supported TypeScript config specifiers", () => {
|
||||
@@ -13,18 +12,21 @@ it("detects supported TypeScript config specifiers", () => {
|
||||
expect(isTypeScriptModuleSpecifier("/tmp/oxfmt.config.js")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns a node version hint for unsupported TypeScript module loading", () => {
|
||||
const err = new TypeError(
|
||||
'Unknown file extension ".ts" for /tmp/oxfmt.config.ts',
|
||||
) as TypeError & { code?: string };
|
||||
err.code = "ERR_UNKNOWN_FILE_EXTENSION";
|
||||
it.each(["v20.19.0", "v20.20.2", "v22.11.0"])(
|
||||
"returns a node version hint for unsupported TypeScript module loading on %s",
|
||||
(nodeVersion) => {
|
||||
const err = new TypeError(
|
||||
'Unknown file extension ".ts" for /tmp/oxfmt.config.ts',
|
||||
) as TypeError & { code?: string };
|
||||
err.code = "ERR_UNKNOWN_FILE_EXTENSION";
|
||||
|
||||
expect(
|
||||
getUnsupportedTypeScriptModuleLoadHintForError(err, "/tmp/oxfmt.config.ts", "v22.11.0"),
|
||||
).toBe(
|
||||
`${err.message}\n\nTypeScript config files require Node.js ${NODE_TYPESCRIPT_SUPPORT_RANGE}.\nDetected Node.js v22.11.0.\nPlease upgrade Node.js or use a JSON config file instead.`,
|
||||
);
|
||||
});
|
||||
expect(
|
||||
getUnsupportedTypeScriptModuleLoadHintForError(err, "/tmp/oxfmt.config.ts", nodeVersion),
|
||||
).toBe(
|
||||
`${err.message}\n\nTypeScript config files require Node.js >=22.18.0.\nDetected Node.js ${nodeVersion}.\nPlease upgrade Node.js or use a JSON config file instead.`,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("does not add the hint for non-TypeScript specifiers or unrelated errors", () => {
|
||||
const err = new Error("Cannot find package");
|
||||
|
||||
@@ -208,7 +208,7 @@ pub struct Oxlintrc {
|
||||
///
|
||||
/// TypeScript plugin files are supported in the following environments:
|
||||
/// - Deno and Bun: TypeScript files are supported natively.
|
||||
/// - Node.js >=22.18.0 and Node.js ^20.19.0: TypeScript files are supported natively with built-in
|
||||
/// - Node.js >=22.18.0: TypeScript files are supported natively with built-in
|
||||
/// type-stripping enabled by default.
|
||||
///
|
||||
/// For older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"markdownDescription": "Globs to ignore during linting. Patterns use gitignore-style matching,\nrooted at the directory containing the configuration file.\nFiles outside that directory cannot be matched; patterns containing `..`\nare rejected as a configuration error."
|
||||
},
|
||||
"jsPlugins": {
|
||||
"description": "JS plugins, allows usage of ESLint plugins with Oxlint.\n\nRead more about JS plugins in\n[the docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).\n\nNote: JS plugins are in alpha and not subject to semver.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.js\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nBasic usage with a TypeScript plugin and a local plugin path.\n\nTypeScript plugin files are supported in the following environments:\n- Deno and Bun: TypeScript files are supported natively.\n- Node.js >=22.18.0 and Node.js ^20.19.0: TypeScript files are supported natively with built-in\ntype-stripping enabled by default.\n\nFor older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.ts\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nUsing a built-in Rust plugin alongside a JS plugin with the same name\nby giving the JS plugin an alias.\n\n```json\n{\n\"plugins\": [\"import\"],\n\"jsPlugins\": [\n{ \"name\": \"import-js\", \"specifier\": \"eslint-plugin-import\" }\n],\n\"rules\": {\n\"import/no-cycle\": \"error\",\n\"import-js/no-unresolved\": \"warn\"\n}\n}\n```",
|
||||
"description": "JS plugins, allows usage of ESLint plugins with Oxlint.\n\nRead more about JS plugins in\n[the docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).\n\nNote: JS plugins are in alpha and not subject to semver.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.js\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nBasic usage with a TypeScript plugin and a local plugin path.\n\nTypeScript plugin files are supported in the following environments:\n- Deno and Bun: TypeScript files are supported natively.\n- Node.js >=22.18.0: TypeScript files are supported natively with built-in\ntype-stripping enabled by default.\n\nFor older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.ts\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nUsing a built-in Rust plugin alongside a JS plugin with the same name\nby giving the JS plugin an alias.\n\n```json\n{\n\"plugins\": [\"import\"],\n\"jsPlugins\": [\n{ \"name\": \"import-js\", \"specifier\": \"eslint-plugin-import\" }\n],\n\"rules\": {\n\"import/no-cycle\": \"error\",\n\"import-js/no-unresolved\": \"warn\"\n}\n}\n```",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "null"
|
||||
@@ -70,7 +70,7 @@
|
||||
"uniqueItems": true
|
||||
}
|
||||
],
|
||||
"markdownDescription": "JS plugins, allows usage of ESLint plugins with Oxlint.\n\nRead more about JS plugins in\n[the docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).\n\nNote: JS plugins are in alpha and not subject to semver.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.js\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nBasic usage with a TypeScript plugin and a local plugin path.\n\nTypeScript plugin files are supported in the following environments:\n- Deno and Bun: TypeScript files are supported natively.\n- Node.js >=22.18.0 and Node.js ^20.19.0: TypeScript files are supported natively with built-in\ntype-stripping enabled by default.\n\nFor older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.ts\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nUsing a built-in Rust plugin alongside a JS plugin with the same name\nby giving the JS plugin an alias.\n\n```json\n{\n\"plugins\": [\"import\"],\n\"jsPlugins\": [\n{ \"name\": \"import-js\", \"specifier\": \"eslint-plugin-import\" }\n],\n\"rules\": {\n\"import/no-cycle\": \"error\",\n\"import-js/no-unresolved\": \"warn\"\n}\n}\n```"
|
||||
"markdownDescription": "JS plugins, allows usage of ESLint plugins with Oxlint.\n\nRead more about JS plugins in\n[the docs](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).\n\nNote: JS plugins are in alpha and not subject to semver.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.js\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nBasic usage with a TypeScript plugin and a local plugin path.\n\nTypeScript plugin files are supported in the following environments:\n- Deno and Bun: TypeScript files are supported natively.\n- Node.js >=22.18.0: TypeScript files are supported natively with built-in\ntype-stripping enabled by default.\n\nFor older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.\n\n```json\n{\n\"jsPlugins\": [\"./custom-plugin.ts\"],\n\"rules\": {\n\"custom/rule-name\": \"warn\"\n}\n}\n```\n\nUsing a built-in Rust plugin alongside a JS plugin with the same name\nby giving the JS plugin an alias.\n\n```json\n{\n\"plugins\": [\"import\"],\n\"jsPlugins\": [\n{ \"name\": \"import-js\", \"specifier\": \"eslint-plugin-import\" }\n],\n\"rules\": {\n\"import/no-cycle\": \"error\",\n\"import-js/no-unresolved\": \"warn\"\n}\n}\n```"
|
||||
},
|
||||
"options": {
|
||||
"description": "Oxlint config options.",
|
||||
|
||||
@@ -334,7 +334,7 @@ Basic usage with a TypeScript plugin and a local plugin path.
|
||||
|
||||
TypeScript plugin files are supported in the following environments:
|
||||
- Deno and Bun: TypeScript files are supported natively.
|
||||
- Node.js >=22.18.0 and Node.js ^20.19.0: TypeScript files are supported natively with built-in
|
||||
- Node.js >=22.18.0: TypeScript files are supported natively with built-in
|
||||
type-stripping enabled by default.
|
||||
|
||||
For older Node.js versions, TypeScript plugins are not supported. Please use JavaScript plugins or upgrade your Node version.
|
||||
|
||||
Reference in new issue
Block a user