Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_param_reassign.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use lazy_regex::Regex;
use rustc_hash::FxHashSet;
use schemars::JsonSchema;

use oxc_ast::{
AstKind,
Expand Down Expand Up @@ -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<String>,
/// 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<String>", default)]
ignore_property_modifications_for_regex: Vec<Regex>,
}

Expand Down Expand Up @@ -73,7 +81,8 @@ declare_oxc_lint!(
/// ```
NoParamReassign,
eslint,
restriction
restriction,
config = NoParamReassignConfig,
);

impl Rule for NoParamReassign {
Expand Down
Loading