oxc/missing-throw Correctness
What it does
Checks whether the throw
keyword is missing in front of a new
expression.
Why is this bad?
The throw
keyword is required in front of a new
expression to throw an error. Omitting it is usually a mistake.
Example
Examples of incorrect code for this rule:
javascript
function foo() {
throw Error();
}
const foo = () => {
new Error();
};
Examples of correct code for this rule:
javascript
function foo() {
throw new Error();
}
const foo = () => {
throw new Error();
};
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny oxc/missing-throw
json
{
"rules": {
"oxc/missing-throw": "error"
}
}