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

Update: consecutive option for one-var (fixes #4680) #9994

Merged
merged 4 commits into from Mar 16, 2018

Conversation

aladdin-add
Copy link
Member

@aladdin-add aladdin-add commented Feb 20, 2018

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

[x] Changes an existing rule (template)

What changes did you make? (Give an overview)
fixes #4680

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

@eslint-deprecated eslint-deprecated bot added the triage label Feb 20, 2018
@aladdin-add aladdin-add added enhancement rule accepted and removed triage labels Feb 20, 2018
Copy link
Member

@btmills btmills left a comment

Just a couple minor tweaks, but this looks really good. Nice work @kaicataldo and @aladdin-add!


```js
/*eslint one-var: ["error", "consecutive"]*/
/*eslint-env es6*/
Copy link
Member

@btmills btmills Mar 2, 2018

Choose a reason for hiding this comment

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

The es6 env isn't strictly necessary for this example, though I'm fine keeping it for consistency with all the other examples in this PR.

const declarationCounts = countDeclarations(declarations);
const mixedRequires = declarations.some(isRequire) && !declarations.every(isRequire);
if (isPreviousNodeDeclaration && previousNode.kind === type) {
const previousDeclCounts = previousNode && countDeclarations(previousNode.declarations);
Copy link
Member

@btmills btmills Mar 2, 2018

Choose a reason for hiding this comment

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

Guarding this line with previousNode && looks to be redundant, since lines 307 and 309 above would've thrown if previousNode was falsy.

@@ -36,23 +36,29 @@ String option:

* `"always"` (default) requires one variable declaration per scope
* `"never"` requires multiple variable declarations per scope
* `"consecutive"` allows multiple variable declarations per scope but requires consecutive variables declarations to be combined into a single declaration
Copy link
Member

@btmills btmills Mar 2, 2018

Choose a reason for hiding this comment

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

Nit: "consecutive variables variable declarations"

btmills
btmills approved these changes Mar 3, 2018
Copy link
Member

@btmills btmills left a comment

LGTM 👍

@aladdin-add aladdin-add requested a review from kaicataldo Mar 12, 2018
@ilyavolodin ilyavolodin merged commit 55a1593 into eslint:master Mar 16, 2018
5 checks passed
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 13, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age label Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted archived due to age enhancement rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants