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.
// it's initialized and never reassigned.
let a = 3;
console.log(a);
let b;
b = 0;
console.log(b);
class C {
static {
let a;
a = 0;
console.log(a);
}
}
// `i` is redefined (not reassigned) on each loop step.
for (let i in [1, 2, 3]) {
console.log(i);
}
// `a` is redefined (not reassigned) on each loop step.
for (let a of [1, 2, 3]) {
console.log(a);
}// using const.
const a = 0;
// it's never initialized.
let b;
console.log(b);
// it's reassigned after initialized.
let c;
c = 0;
c = 1;
console.log(c);
// it's initialized in a different block from the declaration.
let d;
if (true) {
d = 0;
}
console.log(d);
// it's initialized in a different scope.
let e;
class C {
#x;
static {
e = obj => obj.#x;
}
}
// it's initialized at a place that we cannot write a variable declaration.
let f;
if (true) f = 0;
// …Popular · 1 of 14
Require const declarations for variables that are never reassigned after declared
// it's initialized and never reassigned.
let a = 3;
console.log(a);
let b;
b = 0;
console.log(b);
class C {
static {
let a;
a = 0;
console.log(a);
}
}
// `i` is redefined (not reassigned) on each loop step.
for (let i in [1, 2, 3]) {
console.log(i);
}
// `a` is redefined (not reassigned) on each loop step.
for (let a of [1, 2, 3]) {
console.log(a);
}// using const.
const a = 0;
// it's never initialized.
let b;
console.log(b);
// it's reassigned after initialized.
let c;
c = 0;
c = 1;
console.log(c);
// it's initialized in a different block from the declaration.
let d;
if (true) {
d = 0;
}
console.log(d);
// it's initialized in a different scope.
let e;
class C {
#x;
static {
e = obj => obj.#x;
}
}
// it's initialized at a place that we cannot write a variable declaration.
let f;
if (true) f = 0;
// …