Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you disable no-plusplus when using eslint?

When using eslint in Visual Studio Code, AirBnB style Ubuntu Linux, no-plusplus is enabled as default so using ++ for example in a for loop will error: [eslint] Unary operator '++' used. (no-plusplus)

How do you disable that setting?

like image 505
Leigh Mathieson Avatar asked Dec 09 '17 13:12

Leigh Mathieson


People also ask

How do I disable a specific ESLint rule?

If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.

How do I disable ESLint block of code?

General case To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console.

How do I ignore warning on ESLint?

disable warnings eslintUse /* eslint-disable */ to ignore all warnings in a file. You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file.


2 Answers

You can just override it in your .eslintrc.js file as follows:

'no-plusplus': 'off' 

or if you don't want to disable it completely but only for for-loops:

'no-plusplus': [2, { allowForLoopAfterthoughts: true }] 
like image 112
koala Avatar answered Sep 18 '22 11:09

koala


You can also write variable += 1 instead, as suggested by ESLint.

like image 42
Fabian von Ellerts Avatar answered Sep 20 '22 11:09

Fabian von Ellerts