From ec58371e141f1ca161b141cbd6258c7feaff012e Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Wed, 29 Oct 2025 16:04:44 -0600 Subject: [PATCH] docs(linter): Add configuration option docs for oxc/no-optional-chaining rule. --- .../src/rules/oxc/no_optional_chaining.rs | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/crates/oxc_linter/src/rules/oxc/no_optional_chaining.rs b/crates/oxc_linter/src/rules/oxc/no_optional_chaining.rs index 798379165803b..801ed9047700f 100644 --- a/crates/oxc_linter/src/rules/oxc/no_optional_chaining.rs +++ b/crates/oxc_linter/src/rules/oxc/no_optional_chaining.rs @@ -2,6 +2,7 @@ use oxc_ast::AstKind; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::Span; +use schemars::JsonSchema; use crate::{AstNode, context::LintContext, rule::Rule}; @@ -18,8 +19,12 @@ fn no_optional_chaining_diagnostic(span: Span, help: &str) -> OxcDiagnostic { #[derive(Debug, Default, Clone)] pub struct NoOptionalChaining(Box); -#[derive(Debug, Default, Clone)] +#[derive(Debug, Default, Clone, JsonSchema)] +#[serde(rename_all = "camelCase", default)] pub struct NoOptionalChainingConfig { + /// A custom help message to display when optional chaining is found. + /// For example, "Our output target is ES2016, and optional chaining results in verbose + /// helpers and should be avoided." message: String, } @@ -52,28 +57,10 @@ declare_oxc_lint!( /// const foo = obj?.foo; /// obj.fn?.(); /// ``` - /// - /// ### Options - /// - /// ```json - /// { - /// "rules": { - /// "no-optional-chaining": [ - /// "error", - /// { - /// "message": "Our output target is ES2016, and optional chaining results in verbose - /// helpers and should be avoided.", - /// } - /// ] - /// } - /// } - /// ``` - /// - /// - `message`: A custom help message to display when optional chaining is found. - /// NoOptionalChaining, oxc, restriction, + config = NoOptionalChainingConfig, ); impl Rule for NoOptionalChaining {