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

Fix: no-var should fix ForStatement.init #7993

Merged
merged 2 commits into from Feb 3, 2017
Merged

Conversation

mysticatea
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix (template)

Tell us about your environment

  • ESLint Version: 3.14.1
  • Node Version: 6.9.4
  • npm Version: 3.8.8

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

  • default

Please show your full configuration:

  • nothing

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

for (var i = 0; i < 10; ++i) {
    foo(i)
}
$ eslint test.js --env es6 --rule no-var:error --fix --no-eslintrc --no-ignore

What did you expect to happen?

The var declaration is fixed then no errors.

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

path/to/test.js
  1:6  error  Unexpected var, use let or const instead  no-var

✖ 1 problem (1 error, 0 warnings)

What changes did you make? (Give an overview)

I changed no-var rule to fix var declarations at ForStatement.init.

Is there anything you'd like reviewers to focus on?

Nothing in particular.

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Jan 28, 2017
@mention-bot
Copy link

@mysticatea, thanks for your PR! By analyzing the history of the files in this pull request, we identified @alangpierce, @vitorbal and @not-an-aardvark to be potential reviewers.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current implementation can change the behavior of some code:

for (var i = 0, i = 0; false;);

// gets fixed to

for (let i = 0, i = 0; false;); // syntax error
var i = 0;
for (var i = 1; false;);
console.log(i); // => 1

// gets fixed to

var i = 0;
for (let i = 1; false;);
console.log(i); // => 0

@mysticatea
Copy link
Member Author

@not-an-aardvark No. This PR does not change those cases. This is a revision of #7962; it removes ForStatement.init from ignored cases that #7962 added.

@not-an-aardvark
Copy link
Member

Oh, I see. LGTM then.

I'll look into those cases in a separate PR.

@eslintbot
Copy link

LGTM

@mysticatea
Copy link
Member Author

I rebased to resolve conflicts and just added tests for those cases.

@ilyavolodin ilyavolodin merged commit d6b6ba1 into master Feb 3, 2017
@mysticatea mysticatea deleted the no-var/for-init branch February 16, 2017 16:53
@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

Successfully merging this pull request may close these issues.

None yet

7 participants