Airbnb Base ESLint Config for TypeScript

1.1.0 · maintenance · verified Sun Apr 19

This package provides an ESLint configuration that extends the popular Airbnb Base JavaScript style guide with support for TypeScript. It integrates `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` to enable linting TypeScript code according to Airbnb's rules. The current stable version is 1.1.0, last updated in April 2020. This config focuses solely on TypeScript and base JavaScript rules, differentiating it from other Airbnb TypeScript configurations that might include React-specific rules. It requires manual installation of its peer dependencies.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to configure `.eslintrc.js` to extend `airbnb-base-typescript`, set up the TypeScript parser with `parserOptions.project`, and lists the required `npm install` command. It also includes an example `tsconfig.json`.

{
  // .eslintrc.js (or .eslintrc.cjs)
  "root": true,
  "env": {
    "node": true,
    "es2020": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "project": "./tsconfig.json" // IMPORTANT: Adjust path to your tsconfig.json
  },
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "airbnb-base-typescript"
  ],
  "rules": {
    // Add or override rules here, for example:
    // "no-console": "warn"
  }
}

// To install the necessary packages:
// npm install --save-dev \
//   eslint \
//   eslint-config-airbnb-base-typescript \
//   eslint-plugin-import \
//   @typescript-eslint/eslint-plugin \
//   @typescript-eslint/parser

// Example tsconfig.json (must include files to be linted):
// {
//   "compilerOptions": {
//     "target": "es2020",
//     "module": "commonjs",
//     "strict": true,
//     "esModuleInterop": true,
//     "forceConsistentCasingInFileNames": true
//   },
//   "include": ["src/**/*.ts", "test/**/*.ts"]
// }

// To run ESLint:
// npx eslint --ext .js,.ts .

view raw JSON →