no-extra-parens
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"no-extra-parens": "error",
},
},
];This rule is deprecated. Check its documentation for a replacement before enabling it.
a = (b * c);
(a * b) + c;
for (a in (b, c));
for (a in (b));
for (a of (b));
typeof (a);
(Object.prototype.toString.call());
class A {
[(x)] = 1;
}
class B {
x = (y + z);
}const ThisComponent = (<div />)
const ThatComponent = (<div><p /></div>)const ThisComponent = (
<div>
<p />
</div>
)
const ThatComponent = (
<div
prop={true}
/>
)(0).toString();
({}.toString.call());
(function(){}) ? a() : b();
(/^a$/).test(x);
for (a of (b, c));
for (a of b);
for (a in b, c);
for (a in b);
class A {
[x] = 1;
}
class B {
x = y + z;
}while ((foo = bar())) {}
if ((foo = bar())) {}
do; while ((foo = bar()))
for (;(a = b););function a1(b) {
return (b = 1);
}
function a2(b) {
return b ? (c = d) : (c = e);
}
b => (b = 1);
b => b ? (c = d) : (c = e);Examples from the ESLint documentation.
no-extra-parens
eslint
export default [
{
rules: {
"no-extra-parens": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow calls to the Object constructor without an argument
Disallow equal signs explicitly at the beginning of regular expressions
Enforce a maximum depth that callbacks can be nested
Enforce a maximum cyclomatic complexity allowed in a program
Enforce the use of u or v flag on regular expressions