liveBook · Manning

Linter rule

As explained in "Looks Good to Me"

A linting rule is a configured criterion that a linter applies to source code to detect a particular pattern or violation.

A linter rule is a configured check for one pattern or violation in source code. Linters scan code during development and flag rule violations before review, while teams choose each rule’s granularity and severity. section 5.3.2

Rules turn a team style guide into consistently enforced decisions. Use them to automate judgments such as brace placement, unused variables, duplicate imports, equality checks, alerts, or console usage; begin with warnings when adopting unfamiliar rules, then promote proven rules to errors. section 5.2.1 section 5.3.2

Choose the rule’s role deliberately:

  • Prefer dedicated formatters for formatting because linting tools are slower and less consistent at that job. section 5.3.2
  • Add or adjust a rule when an obvious issue escapes prechecks repeatedly, especially after it recurs more than three times. section 4.4.4

Make a boolean check direct

A no-unneeded-ternary rule can flag `let thingToCheck = input === 3 ? true : false;`. The simpler `let thingToCheck = input === 3;` expresses the same check directly.

How "Looks Good to Me" covers it

How deep it goes
Defines rule scope, granularity, and severity with practical configurations, but does not explain linter internals.
Examples
Uses Stroustrup braces, no-var, duplicate-import, equality, console, and unnecessary-ternary checks as concrete examples.
What it assumes
Assumes source-code and team-style familiarity while introducing rules as the building blocks of automated enforcement.
What you can do after
Apply it via ESLint to enforce selected checks, tune warning or error severity, and reduce recurring review issues.
How it connects
Connects style guides, linting, formatting tools, code review, and JavaScript language migration.

Also explained in

Compare how 4 books explain linter rule →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of "Looks Good to Me". The section links point to the parts of the book it draws on.