Skip to content

Latest commit

 

History

History
21 lines (13 loc) · 302 Bytes

throw-new-error.md

File metadata and controls

21 lines (13 loc) · 302 Bytes

Require new when throwing an error

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

This rule is fixable.

Fail

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

Pass

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