question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change one-var to support TSLint's "ignore-for-loop"

See original GitHub issue

What 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Jun 23, 2019

Please feel free to create a new issue with your proposal. Thanks!

1reaction
mysticateacommented, Jun 3, 2019

I wonder if it’s the current behavior: online demo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules - ESLint - Pluggable JavaScript Linter
Rules in ESLint are grouped by type to help you understand their purpose. ... Enforce "for" loop update clause moving the counter in...
Read more >
one-var reports error for a variable declared in a for-loop after ...
From my point of view, I am proposing one of the following two changes: Fix the implementation of one-var to treat for loop...
Read more >
"ESLint no-loop-func rule" What to do when loop variables are ...
Just don't use loops. Iterator methods are so much better. uniqueIdentifiers.forEach(function(uid) { this.database.removeFileReference(uid, function (err) ...
Read more >
List of available rules - ESLint - Pluggable JavaScript linter
Rules in ESLint are grouped by category to help you understand their purpose. ... enforce “for” loop update clause moving the counter in...
Read more >
TSLint to ESLint Part 2: tslint-to-eslint-config | Goldblog
tslint-to-eslint-config. Changing from any tool to another needs a good migration strategy. I wrote a nifty little utility appropriately ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found