From ff2a6e63f6039b370b7de9c0e5630ec101d3b70c Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Mon, 20 Oct 2025 23:24:30 -0600 Subject: [PATCH] docs(linter): Add docs for no-param-reassign config options. This will allow us to auto-gen docs for the config rule when building the website. I believe the note about the rust regex syntax is correct, I based it on the similar comment from the new-cap rule. --- .../src/rules/eslint/no_param_reassign.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_param_reassign.rs b/crates/oxc_linter/src/rules/eslint/no_param_reassign.rs index fc8a5c89d5dba..e08e0dc3b3b42 100644 --- a/crates/oxc_linter/src/rules/eslint/no_param_reassign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_param_reassign.rs @@ -1,5 +1,6 @@ use lazy_regex::Regex; use rustc_hash::FxHashSet; +use schemars::JsonSchema; use oxc_ast::{ AstKind, @@ -29,10 +30,17 @@ fn assignment_to_param_property_diagnostic(name: &str, span: Span) -> OxcDiagnos .with_label(span) } -#[derive(Debug, Default, Clone)] +#[derive(Debug, Default, Clone, JsonSchema)] +#[serde(rename_all = "camelCase", default)] struct NoParamReassignConfig { + /// When true, also check for modifications to properties of parameters. props: bool, + /// An array of parameter names whose property modifications should be ignored. ignore_property_modifications_for: FxHashSet, + /// An array of regex patterns (as strings) for parameter names whose property modifications should be ignored. + /// Note that this uses [Rust regex syntax](https://docs.rs/regex/latest/regex/) and so may not have all features + /// available to JavaScript regexes. + #[schemars(with = "Vec", default)] ignore_property_modifications_for_regex: Vec, } @@ -73,7 +81,8 @@ declare_oxc_lint!( /// ``` NoParamReassign, eslint, - restriction + restriction, + config = NoParamReassignConfig, ); impl Rule for NoParamReassign {