liveBook · Manning

Linting

As explained in "Looks Good to Me"

A software tool that analyzes source code to detect stylistic, structural, or potential quality problems without executing the program.

A linter inspects source code for potential or realized faults without running it. It catches code smells such as deprecated-method calls, undeclared variables, unused variables, debugging statements, and violations of language or team conventions before review. section 5.3.2 section 4.4.4

Linters scan code through rules, with each rule usually checking one concern. Teams choose the rules’ granularity and severity, then run linting during development or as a precheck so reviewers can focus on higher-stakes questions. section 5.3.2 section 5.3

Use linting as one part of a broader quality workflow:

  • Pair it with formatting, static analysis, and automated testing; these mechanisms overlap but address different automated checks. section 5.3
  • Keep obvious issues out of pull requests by running linting before submission and during development. section 4.4.4 section 5.3.2
  • Monitor repeated escapes from the linter; recurring problems may justify a new rule or an adjusted precheck. section 4.4.4
  • Prefer dedicated formatters for formatting enforcement because linting tools may be slower and less consistent at that job. section 5.3.2

A small rule with a visible payoff

A JavaScript team used ESLint rules including no-console, no-var, eqeqeq, and no-unneeded-ternary. The last rule favors the direct check `let thingToCheck = input === 3;` over the unnecessarily complicated `let thingToCheck = input === 3 ? true : false;`. During an ES6 migration, the team initially classified rules as warnings. section 5.3.2

Listing 5.7 ESLint Rules used by Adrienne’s team
"rules": {
    no-var: "error",           #1
    no-duplicate-imports: "error",   #2
    no-await-in-loop: "error",       #3
    eqeqeq: "error",                #4
    no-alert: "error",              #5
    no-console: "error",           #6
    no-unneeded-ternary: "error"    #7
}

Browse the complete ESLint rule set used by the team, including severity-marked checks for variables, imports, loops, equality, alerts, console calls, and ternaries. section 5.3.2

How "Looks Good to Me" covers it

How deep it goes
Defines rule-based fault detection, severity choices, and tool boundaries, while leaving rule policy to each team.
Examples
Uses ESLint checks for console calls, variables, imports, equality, alerts, loops, and unnecessary ternaries.
What you can do after
Apply linting via ESLint to detect and fix recurring code problems before review.
How it connects
Connects linting with formatting, static analysis, automated testing, style guides, prechecks, and code review.

Also explained in

Compare how 8 books explain linting →

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.