A linter rule is a configurable condition that tells a linter when to report a source-code construct. Rules can catch likely mistakes, discourage patterns that make code harder to read, or enforce a team’s style choices. section 1.3.2 section 2.2.3
For example, ESLint’s no-shadow rule reports a variable declared with the same name as one in an outer scope. Shadowing is legal JavaScript, but can make it harder to track which variable a name refers to. Rules can also target mistakes such as unreachable code, library-specific practices, or comment capitalization; some style rules can automatically fix the code. section 1.3.2 section 2.2.3
Listing 2.11 Shadowing a variable
const count = 10; #A
console.log("Outer count:", count);
for (let count = 0; count < 3; count++) { #B
console.log("Inner count:", count); #C
}
console.log("Outer count still:", count);
Compare the outer and loop-local count variables to see the kind of shadowing no-shadow flags. section 2.2.3
Choosing rules involves a tradeoff: more rules can catch more errors and keep style cohesive, but opinionated rules may flag code that is valid and intentional. A project can disable a rule in its ESLint configuration, or an individual use can be exempted with an explanatory comment. Alternatively, code can be rewritten to comply. section 2.2.2





