Skip to content

Commit f9e8dd4

Browse files
committed
refactor(linter): move BUILT_IN_ERRORS to utils file (#14221)
1 parent 6a9dbb5 commit f9e8dd4

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

crates/oxc_linter/src/rules/unicorn/error_message.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use oxc_diagnostics::OxcDiagnostic;
66
use oxc_macros::declare_oxc_lint;
77
use oxc_span::Span;
88

9-
use crate::{AstNode, context::LintContext, rule::Rule};
9+
use crate::{AstNode, context::LintContext, rule::Rule, utils::BUILT_IN_ERRORS};
1010

1111
fn missing_message(ctor_name: &str, span: Span) -> OxcDiagnostic {
1212
OxcDiagnostic::warn(format!("Pass a message to the {ctor_name:1} constructor."))
@@ -105,19 +105,6 @@ impl Rule for ErrorMessage {
105105
}
106106
}
107107

108-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
109-
const BUILT_IN_ERRORS: [&str; 9] = [
110-
"Error",
111-
"EvalError",
112-
"RangeError",
113-
"ReferenceError",
114-
"SyntaxError",
115-
"TypeError",
116-
"URIError",
117-
"InternalError",
118-
"AggregateError",
119-
];
120-
121108
#[test]
122109
fn test() {
123110
use crate::tester::Tester;

crates/oxc_linter/src/utils/unicorn.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ use crate::LintContext;
1414
mod boolean;
1515
pub use boolean::*;
1616

17+
// Built-in Error constructors
18+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
19+
pub const BUILT_IN_ERRORS: [&str; 9] = [
20+
"Error",
21+
"EvalError",
22+
"RangeError",
23+
"ReferenceError",
24+
"SyntaxError",
25+
"TypeError",
26+
"URIError",
27+
"InternalError",
28+
"AggregateError",
29+
];
30+
1731
pub fn is_node_value_not_dom_node(expr: &Expression) -> bool {
1832
matches!(
1933
expr,

0 commit comments

Comments
 (0)