eslint error Unary operator '++' used no-plusplus

Solution 1:

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 */

Solution 2:

I got solution of this problem

if we are use i++ in our code eslint give error. For avoiding this type of error we have to use

var foo = 0;
foo += 1;

var bar = 42;
bar -= 1;

for (i = 0; i < l; i += 1) {
    return;
}

Thanks