space-unary-ops
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"space-unary-ops": "error",
},
},
];This rule is deprecated. Check its documentation for a replacement before enabling it.
typeof!foo;
void{foo:0};
new[foo][0];
delete(foo.bar);
++ foo;
foo --;
- foo;
+ "3";function *foo() {
yield(0)
}async function foo() {
await(bar);
}// Word unary operator "typeof" is followed by a whitespace.
typeof !foo;
// Word unary operator "void" is followed by a whitespace.
void {foo:0};
// Word unary operator "new" is followed by a whitespace.
new [foo][0];
// Word unary operator "delete" is followed by a whitespace.
delete (foo.bar);
// Unary operator "++" is not followed by whitespace.
++foo;
// Unary operator "--" is not preceded by whitespace.
foo--;
// Unary operator "-" is not followed by whitespace.
-foo;
// Unary operator "+" is not followed by whitespace.
+"3";function *foo() {
yield (0)
}async function foo() {
await (bar);
}Examples from the ESLint documentation.
space-unary-ops
eslint
export default [
{
rules: {
"space-unary-ops": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Enforce consistent spacing before or after unary operators in <template>
Require for-in loops to include an if statement
Require var declarations be placed at the top of their containing scope
Require grouped accessor pairs in object literals and classes
Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead