sindresorhus/eslint-plugin-unicorn

`throw-new-error` false positive on decorator calls

Chiusa

#2360 aperta il 16 mag 2024

 (5 commenti) (1 reazione) (0 assegnatari)JavaScript (468 fork)user submission
bughelp wanted

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

after last release throw new error reports any call to function that are PascalCase and contains the word “Error” as invalid.

Example:

const ParseError = () => 0;

// this is reported as invalid
cont result = ParseError();

In my specific case I’m getting the error when using a class decorator to track custom error classes

@RegisterServiceError()
class  SomeError extends BaseError {}

easiest solution would be to at least allow a list of name exceptions to the rule.

Guida contributor