Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 512 Bytes

error-message.md

File metadata and controls

39 lines (27 loc) · 512 Bytes

Enforce passing a message value when throwing a built-in error

This rule enforces a message value to be passed in when throwing an instance of a built-in Error object, which leads to more readable and debuggable code.

Fail

throw Error();
throw Error('');
throw new TypeError();
const error = new Error();
throw error;

Pass

throw Error('Foo');
throw new TypeError('Foo');
const error = new Error('Foo');
throw error;