liveBook · Manning

Linting configuration

As explained in Essential TypeScript 5, Third Edition

A linting configuration is a set of settings that determines which linting rules are enabled, disabled, or otherwise configured.

A linting configuration controls which rules a linter applies. In an .eslintrc file, the rules object maps rule names to values such as 1 or 0, enabling or disabling checks globally. section 6.3.1

Global settings are useful for project-wide preferences, such as accepting let instead of const. They are less suitable for temporary exceptions: a line comment beginning with eslint-disable-line can suppress a named rule for one statement, such as a debugger statement used during investigation. section 6.3.1

Listing 6.12 Disabling a linter rule in the .eslintrc file in the tools folder
{
    "root": true,
    "ignorePatterns": ["node_modules", "dist"],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
      "project": "./tsconfig.json"
    },    
    "plugins": [
      "@typescript-eslint"
    ],
    "extends": [
      "eslint:recommended",
      "plugin:@typescript-eslint/eslint-recommended",
      "plugin:@typescript-eslint/recommended"
    ],
    "rules": {
      "prefer-const": 0
    }
  }

The configuration listing shows an ESLint setup for TypeScript and disables prefer-const with a rules entry. section 6.3.1

Suppressing one warning

debugger; // eslint-disable-line no-debugger section 6.3.1

How Essential TypeScript 5, Third Edition covers it

How deep it goes
Explains numeric rule settings and statement-level comments, but stops short of cataloging available rules.
Examples
Uses an .eslintrc file disabling prefer-const and an index.ts debugger line disabling no-debugger.
What it assumes
Assumes familiarity with linting rules, ESLint configuration files, and TypeScript source files.
What you can do after
Operate/configure ESLint by disabling selected rules globally or suppressing a named warning on one statement.
How it connects
Connects linting configuration with ESLint, linting rules, TypeScript, and debugger statements.

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.