Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 16 additions & 10 deletions crates/oxc_linter/src/rules/eslint/new_cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn new_cap_diagnostic(span: Span, cap: &GetCapResult) -> OxcDiagnostic {
#[derive(Debug, Default, Clone)]
pub struct NewCap(Box<NewCapConfig>);

#[derive(Debug, Default, Clone)]
#[derive(Debug, Clone)]
pub struct NewCapConfig {
new_is_cap: bool,
cap_is_new: bool,
Expand All @@ -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;

Expand Down Expand Up @@ -81,15 +95,7 @@ fn regex_serde_value(map: &serde_json::Map<String, serde_json::Value>, 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
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/tests/rule_configuration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading