Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt

Use this file to discover all available pages before exploring further.

Creating an error without a message produces an exception that is nearly useless in logs and stack traces. This rule requires a non-empty string message whenever you instantiate a built-in Error or one of its subclasses.
Recommendedrecommended · ☑️ unopinionated
Fixable
Suggestions

Examples

throw new Error();
throw new Error('');   // empty string not allowed
throw new TypeError();

const error = new AggregateError(errors);       // missing second argument
const error = new SuppressedError(error, suppressed); // missing third argument

Covered constructors

All built-in error constructors are covered, including:
  • Error
  • TypeError, RangeError, ReferenceError, SyntaxError, URIError, EvalError
  • AggregateError — message is the second argument (after the errors iterable)
  • SuppressedError — message is the third argument
If the message value is a variable whose content cannot be statically determined, the rule does not report it — it only flags missing arguments, empty string literals, and statically known non-string values such as arrays or objects.

Build docs developers (and LLMs) love