nonblock-statement-body-position
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"nonblock-statement-body-position": "error",
},
},
];This rule is deprecated. Check its documentation for a replacement before enabling it.
Enforce the location of single-line statements
if (foo)
bar();
else
baz();
while (foo)
bar();
for (let i = 1; i < foo; i++)
bar();
do
bar();
while (foo)if (foo) bar();
else baz();
while (foo) bar();
for (let i = 1; i < foo; i++) bar();
do bar(); while (foo)if (foo)
bar();
while (foo) bar();if (foo) bar();
else baz();
while (foo) bar();
for (let i = 1; i < foo; i++) bar();
do bar(); while (foo)
if (foo) { // block statements are always allowed with this rule
bar();
} else {
baz();
}if (foo)
bar();
else
baz();
while (foo)
bar();
for (let i = 1; i < foo; i++)
bar();
do
bar();
while (foo)
if (foo) {
// Although the second `if` statement is on the same line as the `else`, this is a very common
// pattern, so it's not checked by this rule.
} else if (bar) {
}if (foo) bar();
while (foo)
bar();Examples from the ESLint documentation.
nonblock-statement-body-position
eslint
export default [
{
rules: {
"nonblock-statement-body-position": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Require return statements to either always or never specify values
Disallow dangling underscores in identifiers
Disallow variable declarations from shadowing variables declared in the outer scope