unicorn/error-message Style
What it does
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.
Why is this bad?
Examples
Examples of incorrect code for this rule:
javascript
throw Error();
throw new TypeError();
Examples of correct code for this rule:
javascript
throw new Error("Unexpected token");
throw new TypeError("Number expected");
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny unicorn/error-message
json
{
"rules": {
"unicorn/error-message": "error"
}
}