Skip to content

eslint/rules/dead-code ​

Dead code: Unused, unreachable, useless, empty or duplicated code. 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.

16 rules, 13 on. Source: lint/eslint/rules/dead-code.mjs.

RuleSettingFilesWhat it checksWhy
no-debuggererrorJS + TSDisallow the use of debugger—
no-empty-patternerrorJS + TSDisallow empty destructuring patterns—
no-self-assignerrorJS + TSDisallow assignments where both sides are exactly the same—
no-unreachableerrorJS + TSDisallow unreachable code after return, throw, continue, and break statementsKept: TypeScript only greys out dead code, allowUnreachableCode: false would also block the dev loop.
no-useless-assignmenterrorJS + TSDisallow variable assignments when the value is not used—
no-emptywarnJS + TSDisallow empty block statements—
no-lone-blocksinfoJS + TSDisallow unnecessary nested blocks—
no-unused-expressionserrorJS + TSDisallow unused expressionsReplaced by the TS version.
sonarjs/no-dead-storeoffJS + TSUnused assignments should be removedOff: duplicate of no-useless-assignment.
sonarjs/no-duplicate-in-compositeoffJS + TSUnion and intersection types should not include duplicated constituentsOff: duplicate of @typescript-eslint/no-duplicate-type-constituents.
sonarjs/no-redundant-jumpwarnJS + TSJump statements should not be redundantSonar way; replaces the core no-useless-return, like SonarQube.
sonarjs/no-redundant-optionalwarnJS + TSOptional property declarations should not use both '?' and 'undefined' syntax—
no-unreachableerrorTSDisallow unreachable code after return, throw, continue, and break statementsKept: TypeScript only greys out dead code, allowUnreachableCode: false would also block the dev loop.
@typescript-eslint/no-unnecessary-qualifiererrorTSDisallow unnecessary namespace qualifiers—
no-unused-expressionsoffTSDisallow unused expressionsReplaced by the TS version.
@typescript-eslint/no-unused-expressionserrorTSDisallow unused expressions—

Generated from the JSDoc of the sources.