Skip to content

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.

RuleSettingFilesWhat it checksWhy
no-ex-assignerrorJS + TSDisallow reassigning exceptions in catch clauses—
no-unsafe-finallyerrorJS + TSDisallow control flow statements in finally blocks—
no-throw-literalerrorJS + TSDisallow throwing literals as exceptionsReplaced by the TS version.
no-useless-catchwarnJS + TSDisallow unnecessary catch clauses—
preserve-caught-errorwarnJS + TSDisallow losing originally caught error when re-throwing custom errors—
sonarjs/no-unthrown-erroroffJS + TSErrors should not be created without being thrownOff: duplicate of no-new (which reports any new used for side effects).
sonarjs/no-useless-catchoffJS + TS"catch" clauses should do more than rethrowOff: duplicate of no-useless-catch.
sonarjs/in-operator-type-errorerrorJS + TS"in" should not be used with primitive types—
sonarjs/no-ignored-exceptionserrorJS + TSExceptions should not be ignored—
sonarjs/no-reference-erroroffJS + TSVariables should be defined before being usedOff: not in the Sonar way profile of SonarQube.
no-throw-literaloffTSDisallow throwing literals as exceptionsReplaced by the TS version.
@typescript-eslint/only-throw-errorerrorTSDisallow throwing non-Error values as exceptions—
@typescript-eslint/use-unknown-in-catch-callback-variablewarnTSEnforce typing arguments in Promise rejection callbacks as unknown—

Generated from the JSDoc of the sources.