Rules
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
// Variable declaration in a nested block, and a variable declaration after other statements:
function doSomething() {
if (true) {
var first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomethingElse() {
for (var i=0; i<10; i++) {}
}function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomethingElse() {
var i;
for (i=0; i<10; i++) {}
}Popular · 1 of 50
Require var declarations be placed at the top of their containing scope
// Variable declaration in a nested block, and a variable declaration after other statements:
function doSomething() {
if (true) {
var first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomethingElse() {
for (var i=0; i<10; i++) {}
}function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomethingElse() {
var i;
for (i=0; i<10; i++) {}
}