i'm getting error when i'm running ESLint on my JavaScript code.
var crslWt = 100;
var totCrslWt = (crslWt/2)-20;
i'm getting error
Gratuitous parentheses around expression no-extra-parens
i'm getting error when i'm running ESLint on my JavaScript code.
var crslWt = 100;
var totCrslWt = (crslWt/2)-20;
i'm getting error
Gratuitous parentheses around expression no-extra-parens
In Visual Studio:
Change the following line:
"no-extra-parens": 1,
to
"no-extra-parens": 0,
It seems you have to enforce option { "nestedBinaryExpressions": false }.
From official documentation:
Examples of correct code for this rule with the "all" and { "nestedBinaryExpressions": false } options:
/* eslint no-extra-parens: ["error", "all", { "nestedBinaryExpressions": false }] */
x = a || (b && c);
x = a + (b * c);
x = (a * b) / c;
Simply remove parentheses around crslWt/2.
/ operator takes precedence over -, therefore parentheses in this case are technically redundant