# How to Disable Airbnb ESLint Rules for Legacy Code Sections

> Learn to disable Airbnb ESLint rules for legacy code using the legacy preset or inline comments. Keep your codebase clean and maintainable.

- Repository: [Airbnb/javascript](https://github.com/airbnb/javascript)
- Tags: how-to-guide
- Published: 2026-02-24

---

**Disable Airbnb ESLint rules for legacy code sections by using the `eslint-config-airbnb-base/legacy` preset with ESLint overrides, or apply inline `/* eslint-disable */` comments for specific blocks.**

When migrating older JavaScript projects to the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), you often encounter pre-ES6 code that violates modern rules like `no-var` or `prefer-object-spread`. The `airbnb/javascript` repository provides specific mechanisms to disable these stricter rules for legacy sections without sacrificing code quality elsewhere.

## Use the Legacy Preset for Entire Directories

For folders containing substantial legacy code, configure ESLint to apply a relaxed rule set to those specific paths while maintaining strict Airbnb standards elsewhere.

### Configure Overrides in `.eslintrc`

The `eslint-config-airbnb-base/legacy` preset, defined in [`packages/eslint-config-airbnb-base/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/legacy.js), disables modern-only rules that are inappropriate for older codebases. Combine this with ESLint's `overrides` field to target specific directories:

```json
{
  "extends": ["airbnb/base"],
  "overrides": [
    {
      "files": ["src/legacy/**/*.js"],
      "extends": ["airbnb-base/legacy"],
      "rules": {
        "no-var": "off",
        "prefer-object-spread": "off"
      }
    }
  ]
}

```

This configuration applies the standard Airbnb base rules to your entire project, then relaxes specific requirements only for files matching the `src/legacy/**/*.js` glob pattern.

## Disable Rules Inline for Specific Blocks

When legacy code appears sporadically within modern files, use ESLint directive comments to suppress rules locally without modifying your global configuration.

### Disable Specific Rules

Target individual rules for a code block using `eslint-disable` and `eslint-enable` comments:

```javascript
/* eslint-disable no-var, prefer-const, prefer-object-spread */
// Legacy snippet using pre-ES6 patterns
var old = Object.assign({}, { a: 1 });
var legacyArray = new Array();
/* eslint-enable no-var, prefer-const, prefer-object-spread */

```

The linter ignores the specified rules only between these comment boundaries, preserving enforcement throughout the rest of the file.

### Disable All Rules for a File

For files that require complete exemption from linting:

```javascript
/* eslint-disable */
// Entire file bypasses Airbnb rules
function legacyInit() {
  var x = 1;
  return x;
}
/* eslint-enable */

```

Re-enable specific rules later in the file if needed by using `/* eslint-enable rule-name */`.

## Understand the Legacy Preset Architecture

The Airbnb configuration provides two entry points for legacy support, though one is deprecated.

### Primary Legacy Configuration

The active preset lives in [`packages/eslint-config-airbnb-base/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/legacy.js). This file extends the base rule set and explicitly turns off ES6-specific requirements, making it suitable for ES5 environments or transitional codebases.

### Deprecated Wrapper

A compatibility wrapper exists at [`packages/eslint-config-airbnb/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb/legacy.js) (referenced in older documentation), but it merely points to the base legacy config. Avoid using the top-level `airbnb/legacy` entry in new projects:

```json
{
  "extends": ["airbnb/legacy"]
}

```

Instead, prefer the explicit `airbnb-base/legacy` path shown in the overrides example above.

## Summary

- **Use `eslint-config-airbnb-base/legacy`** via the `overrides` field in `.eslintrc` to relax rules for entire legacy directories like `src/legacy/`.
- **Apply inline `/* eslint-disable */` comments** to suppress specific rules (e.g., `no-var`, `prefer-object-spread`) within modern files containing isolated legacy blocks.
- **Reference [`packages/eslint-config-airbnb-base/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/legacy.js)** for the definitive list of relaxed rules in the Airbnb configuration.
- **Avoid the deprecated `airbnb/legacy` entry point** located at [`packages/eslint-config-airbnb/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb/legacy.js) in favor of the base configuration.

## Frequently Asked Questions

### How do I completely turn off Airbnb ESLint rules for just one folder?

Configure the `overrides` array in your root `.eslintrc` file to target that folder with the `airbnb-base/legacy` preset. This applies a relaxed rule set to that specific path while maintaining strict standards elsewhere:

```json
{
  "overrides": [
    {
      "files": ["legacy-folder/**/*.js"],
      "extends": ["airbnb-base/legacy"]
    }
  ]
}

```

### What is the difference between `airbnb/legacy` and `airbnb-base/legacy`?

The `airbnb/legacy` entry (located in [`packages/eslint-config-airbnb/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb/legacy.js)) is deprecated and simply references the base configuration. The `airbnb-base/legacy` preset (in [`packages/eslint-config-airbnb-base/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/legacy.js)) is the active, maintained configuration that disables modern rules like `no-var` and `prefer-object-spread` for pre-ES6 codebases.

### Can I disable multiple specific Airbnb rules without using the legacy preset?

Yes. Use inline ESLint directive comments to target specific rule violations without switching presets. Wrap the legacy code with `/* eslint-disable rule-name, another-rule */` and close with `/* eslint-enable rule-name, another-rule */` to suppress only those specific violations while keeping other Airbnb rules active.

### Where can I see which rules the legacy preset actually disables?

Inspect the source file [`packages/eslint-config-airbnb-base/legacy.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/legacy.js) in the `airbnb/javascript` repository. This file explicitly lists all modern rules that are turned off or relaxed, including `no-var`, `prefer-object-spread`, and other ES6-specific requirements that are inappropriate for legacy environments.