Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-extra-semi does not handle empty if blocks #6386

Closed
fb55 opened this issue Jun 12, 2016 · 4 comments
Closed

no-extra-semi does not handle empty if blocks #6386

fb55 opened this issue Jun 12, 2016 · 4 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@fb55
Copy link

fb55 commented Jun 12, 2016

What version of ESLint are you using?

2.12.0

What parser (default, Babel-ESLint, etc.) are you using?

Default

Please show your full configuration:

{"extends": "eslint:recommended"}

What did you do? Please include the actual source code causing the issue.

if(arr[0] === "1");
else if(arr[0] === "2"){
    ...
}

What did you expect to happen?

Nothing.

What actually happened? Please include the actual, raw output from ESLint.

  31:48  error  Unnecessary semicolon  no-extra-semi

Also, when using --fix, the semicolon is removed, which leads to invalid code.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 12, 2016
@michaelficarra
Copy link
Member

This rule simply warns on all empty statements. You can use an empty block ({}) or some effect-free expression (0) instead.

@fb55
Copy link
Author

fb55 commented Jun 12, 2016

That's right, but --fix still produces invalid code, which IMHO should never happen.

@michaelficarra
Copy link
Member

You're right, that is an issue.

@mysticatea
Copy link
Member

No, that rule has exceptions by the parent node type:

allowedParentTypes = ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"];

But the exception list does not include IfStatement.
Maybe it should include IfStatement.

@mysticatea mysticatea added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jun 12, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants