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

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 An ESLint team member will look at this issue soon label Feb 20, 2018
@aladdin-add aladdin-add added enhancement This change enhances an existing feature of ESLint 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 Feb 20, 2018
Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

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

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

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

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"

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@aladdin-add aladdin-add requested a review from kaicataldo March 12, 2018 09:59
This was referenced Mar 22, 2018
@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 This issue has been archived; please open a new issue for any further discussion label Sep 13, 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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSCS modifications to one-var
4 participants