Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

prefer-switch: missing some cases #2685

Closed
ikatyang opened this issue May 4, 2017 · 0 comments · Fixed by #2686 or singapore/lint-condo#298
Closed

prefer-switch: missing some cases #2685

ikatyang opened this issue May 4, 2017 · 0 comments · Fixed by #2686 or singapore/lint-condo#298

Comments

@ikatyang
Copy link
Contributor

ikatyang commented May 4, 2017

Bug Report

  • TSLint version: 5.2.0
  • TypeScript version: 2.3.2
  • Running TSLint via: CLI & vscode-tslint

TypeScript code being linted

declare const x: any;

if (x === 1 || x === 2 || x === 3) {}
if (x === 1 || x === 2 || x === -3) {}
if (x === 1 || x === 2 || x === null) {}
if (x === 1 || x === 2 || x === true) {}
if (x === 1 || x === 2 || x === false) {}
if (x === 1 || x === 2 || x === `123`) {}

with tslint.json configuration:

{
    "rules": {
        "prefer-switch": [true]
    }
}

Actual behavior

if (x === 1 || x === 2 || x === 3) {} // error message
if (x === 1 || x === 2 || x === -3) {} // no error message
if (x === 1 || x === 2 || x === null) {} // no error message
if (x === 1 || x === 2 || x === true) {} // no error message
if (x === 1 || x === 2 || x === false) {} // no error message
if (x === 1 || x === 2 || x === `123`) {} // no error message

Expected behavior

if (x === 1 || x === 2 || x === 3) {} // error message
if (x === 1 || x === 2 || x === -3) {} // error message
if (x === 1 || x === 2 || x === null) {} // error message
if (x === 1 || x === 2 || x === true) {} // error message
if (x === 1 || x === 2 || x === false) {} // error message
if (x === 1 || x === 2 || x === `123`) {} // error message
nchen63 pushed a commit that referenced this issue May 5, 2017
[bugfix] `prefer-switch`: add missing checks for some expressions
Fixes: #2685
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant