From 450d10f967a86359d8f8e3d096a39b3e85f49315 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Wed, 28 Jan 2026 19:34:03 +0000 Subject: [PATCH] docs(linter): document jsPlugins examples --- crates/oxc_linter/src/config/oxlintrc.rs | 29 +++++++++++++++++++ npm/oxlint/configuration_schema.json | 4 +-- .../src/snapshots/schema_json.snap | 4 +-- .../src/snapshots/schema_markdown.snap | 29 +++++++++++++++++++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/crates/oxc_linter/src/config/oxlintrc.rs b/crates/oxc_linter/src/config/oxlintrc.rs index c4eb682d54e0e..f8f3db6745262 100644 --- a/crates/oxc_linter/src/config/oxlintrc.rs +++ b/crates/oxc_linter/src/config/oxlintrc.rs @@ -89,6 +89,35 @@ pub struct Oxlintrc { /// /// Note: JS plugins are experimental and not subject to semver. /// They are not supported in the language server (and thus editor integrations) at present. + /// + /// Examples: + /// + /// Basic usage with a local plugin path. + /// + /// ```json + /// { + /// "jsPlugins": ["./eslint-plugin-custom.js"], + /// "rules": { + /// "custom/rule-name": "warn" + /// } + /// } + /// ``` + /// + /// Using a built-in Rust plugin alongside a JS plugin with the same name + /// by giving the JS plugin an alias. + /// + /// ```json + /// { + /// "plugins": ["import"], + /// "jsPlugins": [ + /// { "name": "import-js", "specifier": "eslint-plugin-import" } + /// ], + /// "rules": { + /// "import/no-cycle": "error", + /// "import-js/no-unresolved": "warn" + /// } + /// } + /// ``` #[serde(rename = "jsPlugins", default, skip_serializing_if = "Option::is_none")] #[schemars(schema_with = "external_plugins_schema")] pub external_plugins: Option>, diff --git a/npm/oxlint/configuration_schema.json b/npm/oxlint/configuration_schema.json index 191d77ba1063a..956bc2354da87 100644 --- a/npm/oxlint/configuration_schema.json +++ b/npm/oxlint/configuration_schema.json @@ -60,7 +60,7 @@ "markdownDescription": "Globs to ignore during linting. These are resolved from the configuration file path." }, "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present.", + "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./eslint-plugin-custom.js\"],\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" @@ -73,7 +73,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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present." + "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./eslint-plugin-custom.js\"],\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```" }, "overrides": { "description": "Add, remove, or otherwise reconfigure rules for specific files or groups of files.", diff --git a/tasks/website_linter/src/snapshots/schema_json.snap b/tasks/website_linter/src/snapshots/schema_json.snap index 9690465bee1db..82d8156668c9f 100644 --- a/tasks/website_linter/src/snapshots/schema_json.snap +++ b/tasks/website_linter/src/snapshots/schema_json.snap @@ -64,7 +64,7 @@ expression: json "markdownDescription": "Globs to ignore during linting. These are resolved from the configuration file path." }, "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present.", + "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./eslint-plugin-custom.js\"],\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" @@ -77,7 +77,7 @@ expression: json "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present." + "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 experimental and not subject to semver.\nThey are not supported in the language server (and thus editor integrations) at present.\n\nExamples:\n\nBasic usage with a local plugin path.\n\n```json\n{\n\"jsPlugins\": [\"./eslint-plugin-custom.js\"],\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```" }, "overrides": { "description": "Add, remove, or otherwise reconfigure rules for specific files or groups of files.", diff --git a/tasks/website_linter/src/snapshots/schema_markdown.snap b/tasks/website_linter/src/snapshots/schema_markdown.snap index 6338a2248d176..2723de4b38545 100644 --- a/tasks/website_linter/src/snapshots/schema_markdown.snap +++ b/tasks/website_linter/src/snapshots/schema_markdown.snap @@ -224,6 +224,35 @@ Read more about JS plugins in Note: JS plugins are experimental and not subject to semver. They are not supported in the language server (and thus editor integrations) at present. +Examples: + +Basic usage with a local plugin path. + +```json +{ +"jsPlugins": ["./eslint-plugin-custom.js"], +"rules": { +"custom/rule-name": "warn" +} +} +``` + +Using a built-in Rust plugin alongside a JS plugin with the same name +by giving the JS plugin an alias. + +```json +{ +"plugins": ["import"], +"jsPlugins": [ +{ "name": "import-js", "specifier": "eslint-plugin-import" } +], +"rules": { +"import/no-cycle": "error", +"import-js/no-unresolved": "warn" +} +} +``` + ### jsPlugins[n]