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?
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?
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 }]
"allowForLoopAfterthoughts": true
, as explained on the docs: eslint.org/docs/rules/no-plusplus#options –
Destiny You can also write variable += 1
instead, as suggested by ESLint.
You can locate the file location you need to alter on Linux by searching for the keyword using grep, in this case to search for the file containing plusplus when in the folder eslint was installed use
grep -r plusplus
The correct file will be the eslint-config file, in this case it should be: node_modules/eslint-config-airbnb-base/rules/style.js
To disable the setting comment out the no-plusplus line, you can easily re-enable if required:
// 'no-plusplus': 'error',
You can simply write your declared variable += 1 instead, as suggested by ESLint.
varible++ is similar as variable+=1.
© 2022 - 2024 — McMap. All rights reserved.
(function (exports, require, module, __filename, __dirname) { 'no-plusplus': 'off' ^ SyntaxError: Unexpected token :
– Cox