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 eslint bot added the triage label 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*/

This comment has been minimized.

@btmills

btmills Mar 2, 2018
Member

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);

This comment has been minimized.

@btmills

btmills Mar 2, 2018
Member

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

This comment has been minimized.

@btmills

btmills Mar 2, 2018
Member

Nit: "consecutive variables variable declarations"

aladdin-add added 2 commits Mar 3, 2018
@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
5 checks passed
commit-message PR title follows commit message guidelines
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details
release-monitor No patch release is pending
Details
This was referenced Mar 22, 2018
@eslint eslint bot locked and limited conversation to collaborators Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.