This page documents the peer dependency model used by the Airbnb ESLint configuration packages. It explains the specific plugins required, version compatibility requirements, and the rationale for using peer dependencies over standard dependencies. This architecture ensures that consuming projects maintain control over their dependency tree while preventing version conflicts in the ESLint plugin ecosystem.
The Airbnb ESLint packages (eslint-config-airbnb and eslint-config-airbnb-base) utilize npm's peer dependency mechanism. Unlike standard dependencies, peer dependencies are not automatically installed by the package manager when the config is installed. Instead, the consuming project is responsible for providing these dependencies at the top level.
This model is critical for ESLint configurations because:
node_modules tree can lead to unpredictable linting behavior or runtime errors.node_modules where a config might bring in a version of a plugin that conflicts with one already used by the project.The following diagram maps the logical requirements of the Airbnb configurations to the specific package identifiers and versions defined in the codebase.
Diagram: Peer Dependency Architecture
Sources: packages/eslint-config-airbnb/package.json87-93 packages/eslint-config-airbnb-base/package.json82-85
The full Airbnb configuration requires five peer dependencies to support React, Hooks, and Accessibility linting:
| Peer Dependency | Version Requirement | Purpose |
|---|---|---|
eslint | ^7.32.0 || ^8.2.0 | Core linting engine |
eslint-plugin-import | ^2.30.0 | ES6+ import/export validation |
eslint-plugin-react | ^7.36.1 | React-specific linting rules |
eslint-plugin-react-hooks | ^5.1.0 | Enforces the "Rules of Hooks" |
eslint-plugin-jsx-a11y | ^6.10.0 | Static AST checker for accessibility in JSX |
Sources: packages/eslint-config-airbnb/package.json87-93
The base configuration requires only the core engine and import plugin:
| Peer Dependency | Version Requirement | Purpose |
|---|---|---|
eslint | ^7.32.0 || ^8.2.0 | Core linting engine |
eslint-plugin-import | ^2.30.0 | ES6+ import/export validation |
Sources: packages/eslint-config-airbnb-base/package.json82-85
The project maintains a strict compatibility matrix. Support for ESLint 8 was introduced in eslint-config-airbnb v19.0.0 and eslint-config-airbnb-base v15.0.0, which also marked the dropping of support for ESLint versions earlier than 7.
| Config Version | ESLint Support | Key Changes |
|---|---|---|
| v19.0.0+ | ^7.32.0 || ^8.2.0 | Support for ESLint 8; drop ESLint < 7 packages/eslint-config-airbnb/CHANGELOG.md23 |
| v18.2.0 | Added ESLint 7 support | packages/eslint-config-airbnb/CHANGELOG.md45 |
| v18.0.0 | Added ESLint 6 support | Drop ESLint 4 packages/eslint-config-airbnb/CHANGELOG.md73 |
The configurations define specific Node.js engines to ensure the underlying plugins and ESLint versions function correctly:
^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0 packages/eslint-config-airbnb/package.json94-96^10.12.0 || >=12.0.0 packages/eslint-config-airbnb-base/package.json86-88Internal rule files in the Airbnb configurations are mapped directly to these peer-dependent plugins. The exports field in package.json defines how these rule sets are accessed.
This diagram shows how the Airbnb package exports relate to the required peer plugins.
Diagram: Export to Plugin Mapping
Sources: packages/eslint-config-airbnb/package.json6-15 packages/eslint-config-airbnb-base/package.json6-18
To ensure that the configurations are valid against the peer dependencies they require, the repository lists these same packages under devDependencies. This allows the maintainers to run tests and linting within the monorepo itself.
The following scripts are used to ensure version integrity before a release:
node ./test/requires ensures that all required rule files and their associated plugins can be resolved. packages/eslint-config-airbnb/package.json20eslint-find-rules --unused is run during prepublishOnly to ensure the config is up-to-date with the latest plugin versions. packages/eslint-config-airbnb/package.json22pretest script runs npm run lint, which utilizes the devDependencies versions of ESLint and the plugins. packages/eslint-config-airbnb/package.json24While plugins are peer dependencies, eslint-config-airbnb has a direct dependency on eslint-config-airbnb-base.
eslint-config-airbnb-base: ^15.0.0 packages/eslint-config-airbnb/package.json69confusing-browser-globals: ^1.0.11 packages/eslint-config-airbnb-base/package.json90Sources: packages/eslint-config-airbnb/package.json68-70 packages/eslint-config-airbnb-base/package.json89-91
Refresh this wiki