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
15 changes: 1 addition & 14 deletions crates/oxc_linter/src/rules/unicorn/error_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions crates/oxc_linter/src/utils/unicorn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading