diff --git a/crates/oxc_linter/src/rules/eslint/new_cap.rs b/crates/oxc_linter/src/rules/eslint/new_cap.rs index 7839d9cdabe86..70f3a4521534f 100644 --- a/crates/oxc_linter/src/rules/eslint/new_cap.rs +++ b/crates/oxc_linter/src/rules/eslint/new_cap.rs @@ -21,7 +21,7 @@ fn new_cap_diagnostic(span: Span, cap: &GetCapResult) -> OxcDiagnostic { #[derive(Debug, Default, Clone)] pub struct NewCap(Box); -#[derive(Debug, Default, Clone)] +#[derive(Debug, Clone)] pub struct NewCapConfig { new_is_cap: bool, cap_is_new: bool, @@ -32,6 +32,20 @@ pub struct NewCapConfig { properties: bool, } +impl Default for NewCapConfig { + fn default() -> Self { + Self { + new_is_cap: true, + cap_is_new: true, + new_is_cap_exceptions: caps_allowed_vec(), + new_is_cap_exception_pattern: None, + cap_is_new_exceptions: vec![], + cap_is_new_exception_pattern: None, + properties: true, + } + } +} + impl std::ops::Deref for NewCap { type Target = NewCapConfig; @@ -81,15 +95,7 @@ fn regex_serde_value(map: &serde_json::Map, key: &str impl From<&serde_json::Value> for NewCap { fn from(raw: &serde_json::Value) -> Self { let Some(config_entry) = raw.get(0) else { - return Self(Box::new(NewCapConfig { - new_is_cap: true, - cap_is_new: true, - new_is_cap_exceptions: caps_allowed_vec(), - new_is_cap_exception_pattern: None, - cap_is_new_exceptions: vec![], - cap_is_new_exception_pattern: None, - properties: true, - })); + return Self(Box::default()); }; let config = config_entry diff --git a/crates/oxc_linter/tests/rule_configuration_test.rs b/crates/oxc_linter/tests/rule_configuration_test.rs index 09ecd82717989..830f6234b883b 100644 --- a/crates/oxc_linter/tests/rule_configuration_test.rs +++ b/crates/oxc_linter/tests/rule_configuration_test.rs @@ -25,7 +25,6 @@ fn test_rule_default_matches_from_configuration_null() { // 1. The Default implementation returns the same values as from_configuration(null), or // 2. The from_configuration method is updated to return Default::default() when given null let exceptions = [ - "eslint/new-cap", "eslint/no-unneeded-ternary", "eslint/no-else-return", "import/extensions",