liveBook · Manning

Linter rule

As explained in Essential TypeScript 5, Third Edition

A linting rule is a configurable condition that determines whether a linter reports a particular source-code pattern or violation.

A linter rule checks for a particular source-code pattern and reports a warning when the configured condition is met. Useful rules should produce warnings worth addressing; excessive noise can make important problems easier to ignore. section 6.3.1

Configure a rule at the scope where its guidance makes sense:

  • Set a rule to 1 or 0 in the rules section of .eslintrc to enable or disable it across the project. section 6.3.1
  • Use eslint-disable-line followed by rule names to suppress a rule for one statement, such as allowing debugger during investigation. section 6.3.1

Project-wide and local suppression

In tools/.eslintrc, set "prefer-const": 0 when that warning is not useful for the project. In src/index.ts, write debugger; // eslint-disable-line no-debugger to permit debugging on one statement without disabling the rule everywhere.

How Essential TypeScript 5, Third Edition covers it

How deep it goes
Explains numeric configuration values and statement-level suppression, but does not detail rule implementation internals.
Examples
Uses prefer-const in .eslintrc and no-debugger with an eslint-disable-line comment.
What it assumes
Assumes familiarity with linting and source files while demonstrating rule configuration from explicit examples.
What you can do after
Operate ESLint by enabling or disabling rules globally and suppressing selected violations on individual statements.
How it connects
Connects linting rules with ESLint configuration, TypeScript source files, and the debugger keyword.

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 Essential TypeScript 5, Third Edition. The section links point to the parts of the book it draws on.