You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/oxc_linter/src/rules/unicorn/error_message.rs
+24-30Lines changed: 24 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -27,10 +27,15 @@ pub struct ErrorMessage;
27
27
declare_oxc_lint!(
28
28
/// ### What it does
29
29
///
30
-
/// This rule enforces a `message` value to be passed in when creating an instance of a built-in `Error` object, which leads to more readable and debuggable code.
30
+
/// Enforces providing a `message` when creating built-in `Error` objects to
31
+
/// improve readability and debugging.
31
32
///
32
33
/// ### Why is this bad?
33
34
///
35
+
/// Throwing an `Error` without a message, like `throw new Error()`, provides no context
36
+
/// on what went wrong, making debugging harder. A clear error message improves
37
+
/// code clarity and helps developers quickly identify issues.
38
+
///
34
39
/// ### Examples
35
40
///
36
41
/// Examples of **incorrect** code for this rule:
@@ -71,48 +76,37 @@ impl Rule for ErrorMessage {
71
76
return;
72
77
}
73
78
74
-
let constructor_name = &callee.name;
75
-
let message_argument_idx = usize::from(constructor_name.as_str() == "AggregateError");
76
-
77
-
// If message is `SpreadElement` or there is `SpreadElement` before message
78
-
if args
79
-
.iter()
80
-
.enumerate()
81
-
.any(|(i, arg)| i <= message_argument_idx && matches!(arg,Argument::SpreadElement(_)))
0 commit comments