eslint/rules/errors
Errors: throw, try / catch and Error objects. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.
13 rules, 9 on. Source: lint/eslint/rules/errors.mjs.
| Rule | Setting | Files | What it checks | Why |
|---|---|---|---|---|
no-ex-assign | error | JS + TS | Disallow reassigning exceptions in catch clauses | — |
no-unsafe-finally | error | JS + TS | Disallow control flow statements in finally blocks | — |
no-throw-literal | error | JS + TS | Disallow throwing literals as exceptions | Replaced by the TS version. |
no-useless-catch | warn | JS + TS | Disallow unnecessary catch clauses | — |
preserve-caught-error | warn | JS + TS | Disallow losing originally caught error when re-throwing custom errors | — |
sonarjs/no-unthrown-error | off | JS + TS | Errors should not be created without being thrown | Off: duplicate of no-new (which reports any new used for side effects). |
sonarjs/no-useless-catch | off | JS + TS | "catch" clauses should do more than rethrow | Off: duplicate of no-useless-catch. |
sonarjs/in-operator-type-error | error | JS + TS | "in" should not be used with primitive types | — |
sonarjs/no-ignored-exceptions | error | JS + TS | Exceptions should not be ignored | — |
sonarjs/no-reference-error | off | JS + TS | Variables should be defined before being used | Off: not in the Sonar way profile of SonarQube. |
no-throw-literal | off | TS | Disallow throwing literals as exceptions | Replaced by the TS version. |
@typescript-eslint/only-throw-error | error | TS | Disallow throwing non-Error values as exceptions | — |
@typescript-eslint/use-unknown-in-catch-callback-variable | warn | TS | Enforce typing arguments in Promise rejection callbacks as unknown | — |