Require new when creating an error ​
💼 This rule is enabled in the ✅ recommended config.
🔧 This rule is automatically fixable by the --fix CLI option.
While it's possible to create a new error without using the new keyword, it's better to be explicit.
Fail ​
js
const error = Error('unicorn');js
throw TypeError('unicorn');js
throw lib.TypeError('unicorn');Pass ​
js
const error = new Error('unicorn');js
throw new TypeError('unicorn');js
throw new lib.TypeError('unicorn');