Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 611 Bytes

throw-new-error.md

File metadata and controls

35 lines (24 loc) · 611 Bytes

Require new when throwing an error

This rule is part of the recommended config.

🔧 This rule is auto-fixable.

While it's possible to create a new error without using the new keyword, it's better to be explicit.

Fail

throw Error();
throw TypeError('unicorn');
throw lib.TypeError();

Pass

throw new Error();
throw new TypeError('unicorn');
throw new lib.TypeError();