From a6b0100501fda75ec313146a992a9f5fce995518 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sun, 1 Dec 2024 16:31:22 +0800 Subject: [PATCH] docs(linter): fix config example headings (#7562) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com> --- crates/oxc_linter/src/config/settings/jsx_a11y.rs | 2 +- crates/oxc_linter/src/config/settings/mod.rs | 2 -- crates/oxc_linter/src/config/settings/next.rs | 2 +- crates/oxc_linter/src/config/settings/react.rs | 4 ++-- crates/oxc_linter/src/snapshots/schema_json.snap | 11 ++++++----- npm/oxlint/configuration_schema.json | 10 +++++----- .../website/src/linter/snapshots/schema_markdown.snap | 9 ++++----- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/crates/oxc_linter/src/config/settings/jsx_a11y.rs b/crates/oxc_linter/src/config/settings/jsx_a11y.rs index e2744ee5ba8c3..96038b9d4a397 100644 --- a/crates/oxc_linter/src/config/settings/jsx_a11y.rs +++ b/crates/oxc_linter/src/config/settings/jsx_a11y.rs @@ -29,7 +29,7 @@ pub struct JSXA11yPluginSettings { /// To have your custom components be checked as DOM elements, you can /// provide a mapping of your component names to the DOM element name. /// - /// ## Example + /// Example: /// /// ```json /// { diff --git a/crates/oxc_linter/src/config/settings/mod.rs b/crates/oxc_linter/src/config/settings/mod.rs index 0aed87547a34c..e32c7d75822af 100644 --- a/crates/oxc_linter/src/config/settings/mod.rs +++ b/crates/oxc_linter/src/config/settings/mod.rs @@ -15,8 +15,6 @@ use self::{ /// /// Configure the behavior of linter plugins. /// -/// ## Example -/// /// Here's an example if you're using Next.js in a monorepo: /// /// ```json diff --git a/crates/oxc_linter/src/config/settings/next.rs b/crates/oxc_linter/src/config/settings/next.rs index 7e0f1b31e9193..52e00d05b848c 100644 --- a/crates/oxc_linter/src/config/settings/next.rs +++ b/crates/oxc_linter/src/config/settings/next.rs @@ -12,7 +12,7 @@ pub struct NextPluginSettings { /// This is particularly useful when you have a monorepo and your Next.js /// project is in a subfolder. /// - /// ## Example + /// Example: /// /// ```json /// { diff --git a/crates/oxc_linter/src/config/settings/react.rs b/crates/oxc_linter/src/config/settings/react.rs index 0432189c7d2d1..ed42a02931b7f 100644 --- a/crates/oxc_linter/src/config/settings/react.rs +++ b/crates/oxc_linter/src/config/settings/react.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; pub struct ReactPluginSettings { /// Components used as alternatives to `
` for forms, such as ``. /// - /// ## Example + /// Example: /// /// ```jsonc /// { @@ -35,7 +35,7 @@ pub struct ReactPluginSettings { /// Components used as alternatives to `` for linking, such as ``. /// - /// ## Example + /// Example: /// /// ```jsonc /// { diff --git a/crates/oxc_linter/src/snapshots/schema_json.snap b/crates/oxc_linter/src/snapshots/schema_json.snap index 0ded976439e32..6c939e9ee3a06 100644 --- a/crates/oxc_linter/src/snapshots/schema_json.snap +++ b/crates/oxc_linter/src/snapshots/schema_json.snap @@ -1,6 +1,7 @@ --- source: crates/oxc_linter/src/lib.rs expression: json +snapshot_kind: text --- { "$schema": "http://json-schema.org/draft-07/schema#", @@ -252,7 +253,7 @@ expression: json "type": "object", "properties": { "components": { - "description": "To have your custom components be checked as DOM elements, you can provide a mapping of your component names to the DOM element name.\n\n## Example\n\n```json { \"settings\": { \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"IconButton\": \"button\" } } } } ```", + "description": "To have your custom components be checked as DOM elements, you can provide a mapping of your component names to the DOM element name.\n\nExample:\n\n```json { \"settings\": { \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"IconButton\": \"button\" } } } } ```", "default": {}, "type": "object", "additionalProperties": { @@ -279,7 +280,7 @@ expression: json "type": "object", "properties": { "rootDir": { - "description": "The root directory of the Next.js project.\n\nThis is particularly useful when you have a monorepo and your Next.js project is in a subfolder.\n\n## Example\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" } } } ```", + "description": "The root directory of the Next.js project.\n\nThis is particularly useful when you have a monorepo and your Next.js project is in a subfolder.\n\nExample:\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" } } } ```", "default": [], "allOf": [ { @@ -396,7 +397,7 @@ expression: json }, "OxlintSettings": { "title": "Oxlint Plugin Settings", - "description": "Configure the behavior of linter plugins.\n\n## Example\n\nHere's an example if you're using Next.js in a monorepo:\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" }, \"react\": { \"linkComponents\": [ { \"name\": \"Link\", \"linkAttribute\": \"to\" } ] }, \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"Button\": \"button\" } } } } ```", + "description": "Configure the behavior of linter plugins.\n\nHere's an example if you're using Next.js in a monorepo:\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" }, \"react\": { \"linkComponents\": [ { \"name\": \"Link\", \"linkAttribute\": \"to\" } ] }, \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"Button\": \"button\" } } } } ```", "type": "object", "properties": { "jsdoc": { @@ -455,7 +456,7 @@ expression: json "type": "object", "properties": { "formComponents": { - "description": "Components used as alternatives to `` for forms, such as ``.\n\n## Example\n\n```jsonc { \"settings\": { \"react\": { \"formComponents\": [ \"CustomForm\", // OtherForm is considered a form component and has an endpoint attribute { \"name\": \"OtherForm\", \"formAttribute\": \"endpoint\" }, // allows specifying multiple properties if necessary { \"name\": \"Form\", \"formAttribute\": [\"registerEndpoint\", \"loginEndpoint\"] } ] } } } ```", + "description": "Components used as alternatives to `` for forms, such as ``.\n\nExample:\n\n```jsonc { \"settings\": { \"react\": { \"formComponents\": [ \"CustomForm\", // OtherForm is considered a form component and has an endpoint attribute { \"name\": \"OtherForm\", \"formAttribute\": \"endpoint\" }, // allows specifying multiple properties if necessary { \"name\": \"Form\", \"formAttribute\": [\"registerEndpoint\", \"loginEndpoint\"] } ] } } } ```", "default": [], "type": "array", "items": { @@ -463,7 +464,7 @@ expression: json } }, "linkComponents": { - "description": "Components used as alternatives to `` for linking, such as ``.\n\n## Example\n\n```jsonc { \"settings\": { \"react\": { \"linkComponents\": [ \"HyperLink\", // Use `linkAttribute` for components that use a different prop name // than `href`. { \"name\": \"MyLink\", \"linkAttribute\": \"to\" }, // allows specifying multiple properties if necessary { \"name\": \"Link\", \"linkAttribute\": [\"to\", \"href\"] } ] } } } ```", + "description": "Components used as alternatives to `` for linking, such as ``.\n\nExample:\n\n```jsonc { \"settings\": { \"react\": { \"linkComponents\": [ \"HyperLink\", // Use `linkAttribute` for components that use a different prop name // than `href`. { \"name\": \"MyLink\", \"linkAttribute\": \"to\" }, // allows specifying multiple properties if necessary { \"name\": \"Link\", \"linkAttribute\": [\"to\", \"href\"] } ] } } } ```", "default": [], "type": "array", "items": { diff --git a/npm/oxlint/configuration_schema.json b/npm/oxlint/configuration_schema.json index ba0f547ab3895..8209ad1655b80 100644 --- a/npm/oxlint/configuration_schema.json +++ b/npm/oxlint/configuration_schema.json @@ -248,7 +248,7 @@ "type": "object", "properties": { "components": { - "description": "To have your custom components be checked as DOM elements, you can provide a mapping of your component names to the DOM element name.\n\n## Example\n\n```json { \"settings\": { \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"IconButton\": \"button\" } } } } ```", + "description": "To have your custom components be checked as DOM elements, you can provide a mapping of your component names to the DOM element name.\n\nExample:\n\n```json { \"settings\": { \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"IconButton\": \"button\" } } } } ```", "default": {}, "type": "object", "additionalProperties": { @@ -275,7 +275,7 @@ "type": "object", "properties": { "rootDir": { - "description": "The root directory of the Next.js project.\n\nThis is particularly useful when you have a monorepo and your Next.js project is in a subfolder.\n\n## Example\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" } } } ```", + "description": "The root directory of the Next.js project.\n\nThis is particularly useful when you have a monorepo and your Next.js project is in a subfolder.\n\nExample:\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" } } } ```", "default": [], "allOf": [ { @@ -392,7 +392,7 @@ }, "OxlintSettings": { "title": "Oxlint Plugin Settings", - "description": "Configure the behavior of linter plugins.\n\n## Example\n\nHere's an example if you're using Next.js in a monorepo:\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" }, \"react\": { \"linkComponents\": [ { \"name\": \"Link\", \"linkAttribute\": \"to\" } ] }, \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"Button\": \"button\" } } } } ```", + "description": "Configure the behavior of linter plugins.\n\nHere's an example if you're using Next.js in a monorepo:\n\n```json { \"settings\": { \"next\": { \"rootDir\": \"apps/dashboard/\" }, \"react\": { \"linkComponents\": [ { \"name\": \"Link\", \"linkAttribute\": \"to\" } ] }, \"jsx-a11y\": { \"components\": { \"Link\": \"a\", \"Button\": \"button\" } } } } ```", "type": "object", "properties": { "jsdoc": { @@ -451,7 +451,7 @@ "type": "object", "properties": { "formComponents": { - "description": "Components used as alternatives to `` for forms, such as ``.\n\n## Example\n\n```jsonc { \"settings\": { \"react\": { \"formComponents\": [ \"CustomForm\", // OtherForm is considered a form component and has an endpoint attribute { \"name\": \"OtherForm\", \"formAttribute\": \"endpoint\" }, // allows specifying multiple properties if necessary { \"name\": \"Form\", \"formAttribute\": [\"registerEndpoint\", \"loginEndpoint\"] } ] } } } ```", + "description": "Components used as alternatives to `` for forms, such as ``.\n\nExample:\n\n```jsonc { \"settings\": { \"react\": { \"formComponents\": [ \"CustomForm\", // OtherForm is considered a form component and has an endpoint attribute { \"name\": \"OtherForm\", \"formAttribute\": \"endpoint\" }, // allows specifying multiple properties if necessary { \"name\": \"Form\", \"formAttribute\": [\"registerEndpoint\", \"loginEndpoint\"] } ] } } } ```", "default": [], "type": "array", "items": { @@ -459,7 +459,7 @@ } }, "linkComponents": { - "description": "Components used as alternatives to `` for linking, such as ``.\n\n## Example\n\n```jsonc { \"settings\": { \"react\": { \"linkComponents\": [ \"HyperLink\", // Use `linkAttribute` for components that use a different prop name // than `href`. { \"name\": \"MyLink\", \"linkAttribute\": \"to\" }, // allows specifying multiple properties if necessary { \"name\": \"Link\", \"linkAttribute\": [\"to\", \"href\"] } ] } } } ```", + "description": "Components used as alternatives to `` for linking, such as ``.\n\nExample:\n\n```jsonc { \"settings\": { \"react\": { \"linkComponents\": [ \"HyperLink\", // Use `linkAttribute` for components that use a different prop name // than `href`. { \"name\": \"MyLink\", \"linkAttribute\": \"to\" }, // allows specifying multiple properties if necessary { \"name\": \"Link\", \"linkAttribute\": [\"to\", \"href\"] } ] } } } ```", "default": [], "type": "array", "items": { diff --git a/tasks/website/src/linter/snapshots/schema_markdown.snap b/tasks/website/src/linter/snapshots/schema_markdown.snap index bc81c19b49d68..8280431385817 100644 --- a/tasks/website/src/linter/snapshots/schema_markdown.snap +++ b/tasks/website/src/linter/snapshots/schema_markdown.snap @@ -1,6 +1,7 @@ --- source: tasks/website/src/linter/json_schema.rs expression: snapshot +snapshot_kind: text --- # Oxlint Configuration File @@ -225,8 +226,6 @@ type: `object` Configure the behavior of linter plugins. -## Example - Here's an example if you're using Next.js in a monorepo: ```json @@ -352,7 +351,7 @@ default: `{}` To have your custom components be checked as DOM elements, you can provide a mapping of your component names to the DOM element name. -## Example +Example: ```json { "settings": { "jsx-a11y": { "components": { "Link": "a", "IconButton": "button" } } } } ``` @@ -407,7 +406,7 @@ default: `[]` Components used as alternatives to `` for forms, such as ``. -## Example +Example: ```jsonc { "settings": { "react": { "formComponents": [ "CustomForm", // OtherForm is considered a form component and has an endpoint attribute { "name": "OtherForm", "formAttribute": "endpoint" }, // allows specifying multiple properties if necessary { "name": "Form", "formAttribute": ["registerEndpoint", "loginEndpoint"] } ] } } } ``` @@ -427,7 +426,7 @@ default: `[]` Components used as alternatives to `` for linking, such as ``. -## Example +Example: ```jsonc { "settings": { "react": { "linkComponents": [ "HyperLink", // Use `linkAttribute` for components that use a different prop name // than `href`. { "name": "MyLink", "linkAttribute": "to" }, // allows specifying multiple properties if necessary { "name": "Link", "linkAttribute": ["to", "href"] } ] } } } ```