From 3701cdcba127f29ad78fc65f574fa4c30f771ef5 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 28 Oct 2025 20:54:54 -0600 Subject: [PATCH 1/3] docs(linter): Add configuration option docs for eslint/no-multi-assign rule. --- .../src/rules/eslint/no_multi_assign.rs | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs b/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs index 80d8fa53208bc..7d79283304653 100644 --- a/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs @@ -2,6 +2,7 @@ use oxc_ast::{AstKind, ast::Expression}; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::Span; +use schemars::JsonSchema; use crate::{AstNode, context::LintContext, rule::Rule}; @@ -11,8 +12,32 @@ fn no_multi_assign_diagnostic(span: Span) -> OxcDiagnostic { .with_label(span) } -#[derive(Debug, Default, Clone)] +#[derive(Debug, Default, Clone, JsonSchema)] +#[serde(rename_all = "camelCase", default)] pub struct NoMultiAssign { + /// When set to `true`, the rule allows chains that don't include initializing a variable in a declaration or initializing a class field. + /// + /// Examples of **correct** code for this option set to `false`: + /// ```js + /// let a; + /// let b; + /// a = b = "baz"; + /// + /// const x = {}; + /// const y = {}; + /// x.one = y.one = 1; + /// ``` + /// + /// Examples of **incorrect** code this option set to `true`: + /// ```js + /// let a = b = "baz"; + /// + /// const foo = bar = 1; + /// + /// class Foo { + /// a = b = 10; + /// } + /// ``` ignore_non_declaration: bool, } @@ -71,38 +96,10 @@ declare_oxc_lint!( /// a = "quux"; /// b = "quux"; /// ``` - /// - /// ### Options - /// - /// This rule has an object option: - /// * `"ignoreNonDeclaration"`: When set to `true`, the rule allows chains that don't include initializing a variable in a declaration or initializing a class field. Default is `false`. - /// - /// #### ignoreNonDeclaration - /// - /// Examples of **correct** code for the `{ "ignoreNonDeclaration": true }` option: - /// ```js - /// let a; - /// let b; - /// a = b = "baz"; - /// - /// const x = {}; - /// const y = {}; - /// x.one = y.one = 1; - /// ``` - /// - /// Examples of **incorrect** code for the `{ "ignoreNonDeclaration": true }` option: - /// ```js - /// let a = b = "baz"; - /// - /// const foo = bar = 1; - /// - /// class Foo { - /// a = b = 10; - /// } - /// ``` NoMultiAssign, eslint, style, + config = NoMultiAssign, ); impl Rule for NoMultiAssign { From 9a5718c5f6a9a6ad5361b97f7896e92987d98ee0 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 28 Oct 2025 21:06:56 -0600 Subject: [PATCH 2/3] Update crates/oxc_linter/src/rules/eslint/no_multi_assign.rs Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Signed-off-by: Connor Shea --- crates/oxc_linter/src/rules/eslint/no_multi_assign.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs b/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs index 7d79283304653..d201e25dc7790 100644 --- a/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs @@ -17,7 +17,7 @@ fn no_multi_assign_diagnostic(span: Span) -> OxcDiagnostic { pub struct NoMultiAssign { /// When set to `true`, the rule allows chains that don't include initializing a variable in a declaration or initializing a class field. /// - /// Examples of **correct** code for this option set to `false`: + /// Examples of **correct** code for this option set to `true`: /// ```js /// let a; /// let b; From bbbf5980e99a3785e4fd5924819ebd07382f7973 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 28 Oct 2025 21:07:08 -0600 Subject: [PATCH 3/3] Update crates/oxc_linter/src/rules/eslint/no_multi_assign.rs Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Signed-off-by: Connor Shea --- crates/oxc_linter/src/rules/eslint/no_multi_assign.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs b/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs index d201e25dc7790..1f70ddc025d9c 100644 --- a/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_multi_assign.rs @@ -28,7 +28,7 @@ pub struct NoMultiAssign { /// x.one = y.one = 1; /// ``` /// - /// Examples of **incorrect** code this option set to `true`: + /// Examples of **incorrect** code for this option set to `true`: /// ```js /// let a = b = "baz"; ///