Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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;
    }
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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 */
over 4 years ago · Santiago Trujillo Report

0

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

over 4 years ago · Santiago Trujillo Report

0

As you can see this is a linting error. Either write the code like this,

foo += 1;

and

i += 1

Or turn that eslint rule off. (not a good idea);

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!