Change one-var to support TSLint's "ignore-for-loop"
See original GitHub issueWhat rule do you want to change?
https://eslint.org/docs/rules/one-var to support TSLint options “ignore-for-loop” https://palantir.github.io/tslint/rules/one-variable-per-declaration
Does this change cause the rule to produce more or fewer warnings?
Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
new option
Please provide some example code that this change will affect:
Allowed if option "ignore-for-loop": true
for (var i = 0, j = 1, n = 2; i < 50, n < 50; i = i + 3, j = j + 3, n = n + 3){
console.log("variable i: " + i);
console.log("variable j: " + j);
console.log("variable n: " + n);
}
Still warns on
/*eslint one-var: ["error", "always"]*/
/*eslint-env es6*/
function foo() {
var bar,
baz;
let qux,
norf;
}
Example config
"one-var": [
"error",
{
"var": "always-in-loop",
"let": "never",
"const": "never-in-loop"
}
],
What does the rule currently do for this code?
Warns of errors on the use of comma separated variable declarations inside a for loop.
What will the rule do after it’s changed?
Optionally not warn/error for comma separated variable declarations inside a for loop
Are you willing to submit a pull request to implement this change?
Maybe
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top GitHub Comments
Please feel free to create a new issue with your proposal. Thanks!
I wonder if it’s the current behavior: online demo.