I am getting error with my for loop if I used i++
in for loop
var foo = 0;
foo++;
var bar = 42;
bar--;
for (i = 0; i < 1; i++) {
return;
}
One option would be to replace i++
with i+=1
You can also turn that specific eslint rule off (either for the specific line, the file or global configuration). Please consider that this might be not recommended, especially at the file or line level.
The rule name you are looking for is no-plusplus.
Disable it globally
In your eslint config file add the following:
'no-plusplus': 'off' **OR** 'no-plusplus': 0
There is also an option to disable it only for the for loops:
no-plusplus: ["error", { "allowForLoopAfterthoughts": true }]
For further information you can check eslint no-plusplus docs
Disable it at the file level
At the top of your file add the following:
/* eslint-disable no-plusplus */
Disable it for the given line
Just before the for loop, add the following:
/* eslint-disable-next-line no-plusplus */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With