Skip to content

Commit 97c8d06

Browse files
authored
feat(linter): add preserve-caught-error rule (#13748)
Close: #13654 Introduced a new linting rule `preserve-caught-error` to enforce the preservation of original errors when re-throwing exceptions. This rule helps maintain error context by requiring the use of the 'cause' property in error objects. Updated relevant snapshots and tests to reflect the new rule's functionality.
1 parent 137896a commit 97c8d06

File tree

4 files changed

+801
-0
lines changed

4 files changed

+801
-0
lines changed

crates/oxc_linter/src/generated/rule_runner_impls.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ impl RuleRunner for crate::rules::eslint::prefer_template::PreferTemplate {
637637
Some(&AstTypesBitset::from_types(&[AstType::BinaryExpression]));
638638
}
639639

640+
impl RuleRunner for crate::rules::eslint::preserve_caught_error::PreserveCaughtError {
641+
const NODE_TYPES: Option<&AstTypesBitset> =
642+
Some(&AstTypesBitset::from_types(&[AstType::TryStatement]));
643+
}
644+
640645
impl RuleRunner for crate::rules::eslint::radix::Radix {
641646
const NODE_TYPES: Option<&AstTypesBitset> =
642647
Some(&AstTypesBitset::from_types(&[AstType::CallExpression]));

crates/oxc_linter/src/rules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ pub(crate) mod eslint {
178178
pub mod prefer_rest_params;
179179
pub mod prefer_spread;
180180
pub mod prefer_template;
181+
pub mod preserve_caught_error;
181182
pub mod radix;
182183
pub mod require_await;
183184
pub mod require_yield;
@@ -773,6 +774,7 @@ oxc_macros::declare_all_lint_rules! {
773774
eslint::prefer_object_spread,
774775
eslint::prefer_rest_params,
775776
eslint::prefer_spread,
777+
eslint::preserve_caught_error,
776778
eslint::radix,
777779
eslint::require_await,
778780
eslint::require_yield,

0 commit comments

Comments
 (0)