From 4551baaf4ae09b07d933db8ddb82d16bd54deedb Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:49:16 +0000 Subject: [PATCH] docs(linter): document `rules` (#6983) closes #6370 --- crates/oxc_linter/src/config/oxlintrc.rs | 18 +++++++++++++++++- .../oxc_linter/src/snapshots/schema_json.snap | 2 +- npm/oxlint/configuration_schema.json | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/oxc_linter/src/config/oxlintrc.rs b/crates/oxc_linter/src/config/oxlintrc.rs index d830eccfe675a..db5676da1fbe1 100644 --- a/crates/oxc_linter/src/config/oxlintrc.rs +++ b/crates/oxc_linter/src/config/oxlintrc.rs @@ -51,7 +51,23 @@ use crate::{options::LintPlugins, utils::read_to_string}; pub struct Oxlintrc { pub plugins: LintPlugins, pub categories: OxlintCategories, - /// See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html). + /// Example + /// + /// `.oxlintrc.json` + /// + /// ```json + /// { + /// "$schema": "./node_modules/oxlint/configuration_schema.json", + /// "rules": { + /// "eqeqeq": "warn", + /// "import/no-cycle": "error", + /// "prefer-const": ["error", { "ignoreReadBeforeAssign": true }] + /// } + /// } + /// ``` + /// + /// See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html) for the list of + /// rules. pub rules: OxlintRules, pub settings: OxlintSettings, /// Environments enable and disable collections of global variables. diff --git a/crates/oxc_linter/src/snapshots/schema_json.snap b/crates/oxc_linter/src/snapshots/schema_json.snap index d30a04f8800c8..ebb339ce0f3c4 100644 --- a/crates/oxc_linter/src/snapshots/schema_json.snap +++ b/crates/oxc_linter/src/snapshots/schema_json.snap @@ -50,7 +50,7 @@ expression: json ] }, "rules": { - "description": "See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html).", + "description": "Example\n\n`.oxlintrc.json`\n\n```json { \"$schema\": \"./node_modules/oxlint/configuration_schema.json\", \"rules\": { \"eqeqeq\": \"warn\", \"import/no-cycle\": \"error\", \"prefer-const\": [\"error\", { \"ignoreReadBeforeAssign\": true }] } } ```\n\nSee [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html) for the list of rules.", "default": {}, "allOf": [ { diff --git a/npm/oxlint/configuration_schema.json b/npm/oxlint/configuration_schema.json index 11cb88437cfe2..44b7b00ec91a1 100644 --- a/npm/oxlint/configuration_schema.json +++ b/npm/oxlint/configuration_schema.json @@ -46,7 +46,7 @@ ] }, "rules": { - "description": "See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html).", + "description": "Example\n\n`.oxlintrc.json`\n\n```json { \"$schema\": \"./node_modules/oxlint/configuration_schema.json\", \"rules\": { \"eqeqeq\": \"warn\", \"import/no-cycle\": \"error\", \"prefer-const\": [\"error\", { \"ignoreReadBeforeAssign\": true }] } } ```\n\nSee [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html) for the list of rules.", "default": {}, "allOf": [ {