tslint-consistent-codestyle icon indicating copy to clipboard operation
tslint-consistent-codestyle copied to clipboard

feature request: naming-convention - set rule for `for` loop control variables

Open libinvarghese opened this issue 5 years ago • 1 comments
trafficstars

I would like to set a different for naming-convention rules for control variables defined in for loop.

For instance:

function fooBar() {
  for (let i = 0, j = 10; i < 10; i++, j--) {
    let _local = 2;
    console.log (`${i} ${_local*i} => ${j} ${_local*j);
 }
}

With the below tslint.json setting, tslint warns variable name must have leading underscore (naming-convention) for loop control variables i & j

"naming-convention": [
      true,
      {
        "type": "variable",
        "modifiers": "local",
        "leadingUnderscore": "require"
      }
]

I would like to add a new convention rule for overriding control variables defines in for loop.

libinvarghese avatar Dec 13 '19 15:12 libinvarghese

I would advise to add a new type loopControlVariable

libinvarghese avatar Dec 13 '19 15:12 libinvarghese