Skip to content

[switch-exhaustiveness-check] add support for "no default" comment #2631

Closed
@chimericdream

Description

@chimericdream
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/switch-exhaustiveness-check": "warn"
  }
}
enum SomeKind {
    Kind1,
    Kind2,
    Kind3,
    Kind4,
}

const foo: SomeKind = determineKind();

// Kind1 and Kind3 need some extra logic for whatever reason
switch (foo) {
    case SomeKind.Kind1:
        // some special logic for this kind
        break;

    case SomeKind.Kind3:
        // some special logic for this kind
        break;

    /* no default */
}

Expected Result

Similar to the core ESLint rule default-case, I would expect the linter to see that I have explicitly stated that no more cases are needed.

Actual Result

I get a warning that the switch/case doesn't cover the full enum.

Versions

package version
@typescript-eslint/eslint-plugin 4.3.0
@typescript-eslint/parser 4.3.0
TypeScript 4.0.3
ESLint 7.10.0
node 14.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions