-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Conversation
There was a problem hiding this 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*/ |
There was a problem hiding this comment.
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.
lib/rules/one-var.js
Outdated
const declarationCounts = countDeclarations(declarations); | ||
const mixedRequires = declarations.some(isRequire) && !declarations.every(isRequire); | ||
if (isPreviousNodeDeclaration && previousNode.kind === type) { | ||
const previousDeclCounts = previousNode && countDeclarations(previousNode.declarations); |
There was a problem hiding this comment.
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.
docs/rules/one-var.md
Outdated
@@ -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 |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
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?