Content-Length: 308597 | pFad | https://github.com/typescript-eslint/typescript-eslint/issues/3455

15 [no-fallthrough] Lint rule needs type information to avoid false positives e.g. nested switch · Issue #3455 · typescript-eslint/typescript-eslint · GitHub
Skip to content

[no-fallthrough] Lint rule needs type information to avoid false positives e.g. nested switch #3455

Open
@OliverJAsh

Description

@OliverJAsh
  • 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": {
    "no-fallthrough": [2]
  }
}
declare const n: { a: 1; b: 1 | 2 } | { a: 2 };
(() => {
  switch (n.a) {
    case 1: {
      switch (n.b) {
        case 1:
          return 1;
        case 2:
          return 1;
      }
    }
    // ESLint error:
    // Expected a 'break' statement before 'case'.
    case 2: {
      return 2;
    }
  }
})();

Expected Result

No lint error

Actual Result

Lint error (see comment)

Additional Info

I think the TS ESLint plugin needs to provide its own version of no-fallthrough in order to take advantage of type information so we can avoid false positives such as this.

Versions

package version
@typescript-eslint/eslint-plugin latest
@typescript-eslint/parser latest
TypeScript latest
ESLint latest
node latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: new base rule extensionNew base rule extension required to handle a TS specific casepackage: 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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/typescript-eslint/typescript-eslint/issues/3455

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy