diff --git a/crates/oxc_linter/src/rules/unicorn/error_message.rs b/crates/oxc_linter/src/rules/unicorn/error_message.rs index 49d879d860d7a..16295aa516392 100644 --- a/crates/oxc_linter/src/rules/unicorn/error_message.rs +++ b/crates/oxc_linter/src/rules/unicorn/error_message.rs @@ -6,7 +6,7 @@ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::Span; -use crate::{AstNode, context::LintContext, rule::Rule}; +use crate::{AstNode, context::LintContext, rule::Rule, utils::BUILT_IN_ERRORS}; fn missing_message(ctor_name: &str, span: Span) -> OxcDiagnostic { OxcDiagnostic::warn(format!("Pass a message to the {ctor_name:1} constructor.")) @@ -105,19 +105,6 @@ impl Rule for ErrorMessage { } } -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types -const BUILT_IN_ERRORS: [&str; 9] = [ - "Error", - "EvalError", - "RangeError", - "ReferenceError", - "SyntaxError", - "TypeError", - "URIError", - "InternalError", - "AggregateError", -]; - #[test] fn test() { use crate::tester::Tester; diff --git a/crates/oxc_linter/src/utils/unicorn.rs b/crates/oxc_linter/src/utils/unicorn.rs index 02e8dfe9b2627..da6e40e634329 100644 --- a/crates/oxc_linter/src/utils/unicorn.rs +++ b/crates/oxc_linter/src/utils/unicorn.rs @@ -14,6 +14,20 @@ use crate::LintContext; mod boolean; pub use boolean::*; +// Built-in Error constructors +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types +pub const BUILT_IN_ERRORS: [&str; 9] = [ + "Error", + "EvalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError", + "InternalError", + "AggregateError", +]; + pub fn is_node_value_not_dom_node(expr: &Expression) -> bool { matches!( expr,