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

No-unused-expression wrongly lints a comma-separated expression. #2058

Closed
ChiriVulpes opened this issue Jan 17, 2017 · 2 comments · Fixed by #2269 or singapore/lint-condo#263
Closed

Comments

@ChiriVulpes
Copy link

Bug Report

  • TSLint version: 4.3.1
  • TypeScript version: 2.1.5
  • Running TSLint via: Visual Studio Code

TypeScript code being linted

let x: number, y: number;
x = 1, y = 2;

with tslint.json configuration:

{
    "rules": {
		"no-unused-expression": true
	}
}

Actual behavior

Line 2 lints with expected an assignment or function call

Expected behavior

Line 2 contains two assignments, so it should not be linted.

@andy-hanson
Copy link
Contributor

Why not just use x = 1; y = 2;?

@ChiriVulpes
Copy link
Author

Doesn't work on one line if statements.

nchen63 pushed a commit that referenced this issue Mar 10, 2017
Integrate `no-unused-new` into this rule.
[new-rule-option] `allow-new-side-effects` restores the old behaviour to allow `new` for side effects
[bugfix] allow comma separated assignments
Fixes: #2058
[bugfix] allow indirect eval: `(0, eval)("");`
[enhancement] checking for unused new can now use option `allow-fast-null-checks`
Fixes: #1839
[enhancement] find unused comma separated expressions in all locations of the code
[enhancement] find unused expressions inside void expression
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants