unicorn/throw-new-error Style
What it does
Require new
when throwing an error.`
Why is this bad?
While it's possible to create a new error without using the new
keyword, it's better to be explicit.
Examples
Examples of incorrect code for this rule:
javascript
throw Error("🦄");
throw TypeError("unicorn");
throw lib.TypeError("unicorn");
Examples of correct code for this rule:
javascript
throw new Error("🦄");
throw new TypeError("unicorn");
throw new lib.TypeError("unicorn");