November 30, 2025
General

Eslint Config Airbnb Typescript

When working on a TypeScript project, maintaining clean, consistent code can significantly impact productivity and readability. Developers often adopt standardized tools to ensure code quality. One of the most popular configurations for linting in TypeScript projects is the ESLint config Airbnb TypeScript. This setup combines the trusted style rules from Airbnb’s JavaScript guide with TypeScript-specific best practices. Whether you’re working on a personal project or a collaborative codebase, this configuration can help enforce reliable, readable code with minimal friction.

What Is ESLint?

ESLint is a static code analysis tool for identifying problematic patterns in JavaScript and TypeScript code. It’s highly customizable and supports a wide range of plugins and configuration files. Instead of manually checking code for style errors or bad practices, ESLint automates the process, providing real-time feedback and optional automatic fixes.

Why Use ESLint With TypeScript?

TypeScript adds types and extra structure to JavaScript, making code safer and more maintainable. However, it also introduces new syntax and patterns. Using ESLint with TypeScript ensures that your typed code remains clean, adheres to community standards, and avoids common mistakes. It helps identify both syntax errors and logical inconsistencies that may be harder to spot.

The Airbnb JavaScript Style Guide

Airbnb’s style guide is one of the most widely adopted style guides for JavaScript. It provides opinionated rules around formatting, variable naming, spacing, quotation marks, and more. These rules help developers maintain consistency across their codebases. When used with ESLint, Airbnb’s configuration enforces these standards automatically.

Integrating Airbnb With TypeScript

Airbnb’s style guide was initially built for JavaScript, but it can be extended to work with TypeScript by including additional plugins. By combining Airbnb’s base rules with TypeScript ESLint plugins, developers can achieve a balanced setup that respects both stylistic preferences and the needs of a typed language.

Installing ESLint Config Airbnb TypeScript

To use ESLint with Airbnb and TypeScript, you’ll need to install several dependencies. These include the base Airbnb config, the TypeScript ESLint parser and plugin, and other peer dependencies. Below is a typical setup:

npm install --save-dev eslint \ @typescript-eslint/parser \ @typescript-eslint/eslint-plugin \ eslint-config-airbnb-base \ eslint-plugin-import \ eslint-config-airbnb-typescript

Each of these packages serves a role:

  • eslint: The core linter tool.
  • @typescript-eslint/parser: Parses TypeScript code for ESLint to analyze.
  • @typescript-eslint/eslint-plugin: Contains TypeScript-specific linting rules.
  • eslint-config-airbnb-base: The base configuration from Airbnb without React rules.
  • eslint-plugin-import: Helps with sorting and validating imports.
  • eslint-config-airbnb-typescript: Integrates Airbnb rules with TypeScript.

Configuring Youreslintrc File

Once dependencies are installed, configure your ESLint settings by creating a file called.eslintrc.jsor.eslintrc.json. This configuration file tells ESLint how to behave and which rules to apply. A basic configuration might look like this:

module.exports = { parser: '@typescript-eslint/parser', extends: [ 'airbnb-base', 'airbnb-typescript/base' ], parserOptions: { project: './tsconfig.json', }, rules: { // Customize rules here }, };

This setup applies both Airbnb base rules and TypeScript-specific adjustments. The parser options must point to your TypeScript configuration file for full support.

Customizing Rules

Sometimes, Airbnb’s rules may conflict with personal or team preferences. For example, the rule that enforces no semicolons may be too strict. You can override or disable any rule in therulessection:

rules: { 'no-console': 'off', '@typescript-eslint/semi': ['error', 'always'], }

This flexibility allows you to retain the benefits of the Airbnb configuration while tailoring it to your specific needs.

Linting TypeScript Files

To ensure that ESLint analyzes TypeScript files correctly, include the appropriate file extensions in your configuration or your command line usage:

eslint src//.{ts,tsx}

Or add a script to yourpackage.json:

'scripts': { 'lint': 'eslint 'src//.{ts,tsx}'' }

Running this script will lint all TypeScript files in yoursrcfolder and report any violations based on your configuration.

Using ESLint With Prettier

Developers often combine ESLint with Prettier, a code formatter, to handle formatting separately from linting logic. When doing so, you need to disable any formatting rules in ESLint that conflict with Prettier. You can add these dependencies:

npm install --save-dev prettier eslint-config-prettier

And then extend the config in your ESLint settings:

extends: [ 'airbnb-base', 'airbnb-typescript/base', 'prettier' ]

This disables rules that would conflict with Prettier, letting Prettier handle formatting and ESLint focus on code quality.

Benefits of Using ESLint Config Airbnb TypeScript

This combination offers several key benefits:

  • Code Consistency: Ensures that code looks the same across files and contributors.
  • Early Error Detection: Catches syntax and type-related errors before runtime.
  • Customizable: Allows for fine-grained control over rule behavior.
  • Community Tested: Based on widely used and trusted standards.

Common Pitfalls and Solutions

Sometimes, developers encounter issues when setting up ESLint with TypeScript. Common pitfalls include:

  • Missing parserOptions.project: This is required for rules that need type information.
  • Conflicting rules: Combine with Prettier carefully to avoid overlap.
  • File not linted: Make sure your glob patterns include.tsand.tsxfiles.

Understanding the root cause of ESLint errors and adjusting configurations accordingly can save time and avoid frustration.

Setting up ESLint with Airbnb’s style guide and TypeScript support is one of the best ways to ensure high-quality code in modern TypeScript projects. By enforcing strict coding standards and reducing inconsistencies, this setup streamlines development and improves long-term maintainability. The combination of tools like ESLint, Airbnb config, and TypeScript plugins makes it easy to build robust applications with fewer bugs and cleaner syntax.