Skip to content

Commit 0f01fbd

Browse files
yue4uKubaJastrzcamc314
authored
feat(linter): implement eslint/object-shorthand (oxc-project#17688)
Related: oxc-project#479 This PR Implements `eslint/object-shorthand` All eslint tests are ported and should pass. Some API usage and implementation might not be in the preferred style. Some setup code and base structure is reusing the work from oxc-project#3211 --------- Co-authored-by: Jakub Jastrzębski <jakub.jastrzebski@pm.me> Co-authored-by: Cameron Clark <cameron.clark@hey.com>
1 parent 02f108f commit 0f01fbd

7 files changed

Lines changed: 3280 additions & 12 deletions

File tree

crates/oxc_linter/src/generated/rule_runner_impls.rs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_linter/src/generated/rules_enum.rs

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_linter/src/rules.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ pub(crate) mod eslint {
186186
pub mod no_void;
187187
pub mod no_warning_comments;
188188
pub mod no_with;
189+
pub mod object_shorthand;
189190
pub mod operator_assignment;
190191
pub mod prefer_const;
191192
pub mod prefer_destructuring;

crates/oxc_linter/src/rules/eslint/new_cap.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{
1414
AstNode,
1515
context::LintContext,
1616
rule::{DefaultRuleConfig, Rule},
17+
utils::deserialize_regex_option,
1718
};
1819

1920
fn new_cap_diagnostic(span: Span, cap: &GetCapResult) -> OxcDiagnostic {
@@ -84,17 +85,6 @@ impl std::ops::Deref for NewCap {
8485
}
8586
}
8687

87-
fn deserialize_regex_option<'de, D>(deserializer: D) -> Result<Option<Regex>, D::Error>
88-
where
89-
D: serde::Deserializer<'de>,
90-
{
91-
use serde::de::Error;
92-
93-
Option::<String>::deserialize(deserializer)?
94-
.map(|pattern| Regex::new(&pattern).map_err(D::Error::custom))
95-
.transpose()
96-
}
97-
9888
const CAPS_ALLOWED: [&str; 11] = [
9989
"Array", "Boolean", "Date", "Error", "Function", "Number", "Object", "RegExp", "String",
10090
"Symbol", "BigInt",

0 commit comments

Comments
 (0)