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

"one-var": { "initialized": "never" } does not prevent initialized var declarations from being joined with uninitialized var declarations #2786

Closed
feross opened this issue Jun 18, 2015 · 5 comments · Fixed by DavidKindler/meteor#3
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

@feross
Copy link
Contributor

feross commented Jun 18, 2015

I expect to get an error when using this rule:

{
  "one-var": [2, { "initialized": "never" }]
}

and this code:

var i, j, digits = [0]
console.log(i, j, digits)

Specifically, I expect this error: Split initialized 'var' declarations into multiple statements.

I do get an error if I do:

var digits = [0], digits2 = [0]
console.log(digits, digits2)

I expect "one-var": { "initialized": "never" } to prevent initialized var declarations from being joined with any other var declarations (initialized or uninitialized).

@nzakas nzakas added the triage An ESLint team member will look at this issue soon label Jun 18, 2015
@nzakas
Copy link
Member

nzakas commented Jun 18, 2015

@IanVS Can you confirm?

@dcousens
Copy link

Thanks for filing this @feross.
Can confirm this bug.

@IanVS
Copy link
Member

IanVS commented Jun 18, 2015

Yes, currently the rule only checks within each type. I agree with @feross that this is unexpected. If @nzakas accepts, I will work on a PR.

@IanVS
Copy link
Member

IanVS commented Jun 18, 2015

Had nothing better to do, so I made a quick fix. If this issue is accepted, I'll submit it as a pull request.

@nzakas nzakas 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 18, 2015
@nzakas
Copy link
Member

nzakas commented Jun 18, 2015

Accepted!

@nzakas nzakas closed this as completed in 28ac10a Jun 18, 2015
nzakas added a commit that referenced this issue Jun 18, 2015
Fix: one-var 'never' option for mixed initialization (Fixes #2786)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 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 7, 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 a pull request may close this issue.

4 participants