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?
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.
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.
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.
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 }]
You can also write variable += 1
instead, as suggested by ESLint.
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