JavaScript lets you call error constructors withoutDocumentation 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.
new — Error('oops') and new Error('oops') both produce an Error instance. Using new is more explicit and consistent with how other objects are constructed, making the intent immediately clear.
| Recommended | ✅ recommended · ☑️ unopinionated |
| Fixable | 🔧 |
| Suggestions | — |
/^(?:[A-Z][\da-z]*)*Error$/ — covering built-ins like TypeError, RangeError, and SyntaxError, as well as custom error classes like ValidationError or HttpError.
No configuration options
This rule has no configuration options. It automatically fixes violations by inserting thenew keyword before the call expression.