space-before-blocks
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"space-before-blocks": "error",
},
},
];This rule is deprecated. Check its documentation for a replacement before enabling it.
if (a){
b();
}
function a(){}
for (;;){
b();
}
try {} catch(a){}
class Foo{
constructor(){}
}if (a) {
b();
}
function a() {}
for (;;) {
b();
}
try {} catch(a) {}function a() {}
try {} catch(a){}
class Foo{
constructor() {}
}if (a) {
b();
}
if (a) {
b();
} else{ /*no error. this is checked by `keyword-spacing` rule.*/
c();
}
class C {
static{} /*no error. this is checked by `keyword-spacing` rule.*/
}
function a() {}
for (;;) {
b();
}
try {} catch(a) {}if (a){
b();
}
function a(){}
for (;;){
b();
}
try{} catch(a){}
class Foo{
constructor(){}
}for (;;) {
// ...
}
describe(function(){
// ...
});
class Foo{
constructor(){}
}Examples from the ESLint documentation.
space-before-blocks
eslint
export default [
{
rules: {
"space-before-blocks": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Enforce the use of variables within the scope they are defined
Require for-in loops to include an if statement
Require var declarations be placed at the top of their containing scope
Disallow the use of alert, confirm, and prompt