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: handle one-var with no semicolon (fixes #10330) #10371

Merged
merged 5 commits into from
May 23, 2018

Conversation

malcolmsgroves
Copy link
Contributor

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

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

#10330

What changes did you make? (Give an overview)
The fixer function for one-var can now handle semicolon-less style. The fixer checks if the previous token is actually a semicolon, and if not it just inserts the comma after the previous token instead of replacing it. Should be easy to understand from the edits.

Is there anything you'd like reviewers to focus on?
Based on the existing tests and my understanding of fixer functions, I only changed

var a
var b

to

var a,
 b

instead of

var a, b

Is this the right call?

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label May 17, 2018
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.

LGTM, thanks for contributing!

@not-an-aardvark not-an-aardvark 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 May 18, 2018
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Small nitpick: I think the prevSemi ought to be renamed at this point, maybe to something like prevToken. But that shouldn't be a blocker.

@aladdin-add
Copy link
Member

LGTM. thanks! Personally I prefer having some more tests for regression:

code: "var i = 0\n j",
code: "var i\n j = 0",
code: "var i = 0\n j = 0",

@not-an-aardvark not-an-aardvark merged commit 8b7a70c into eslint:master May 23, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 21, 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 Nov 21, 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

4 participants