Last modified: Jul 20, 2025 By Alexander Williams
Install ESLint Airbnb Config in Node.js
ESLint is a popular JavaScript linter. It helps maintain code quality. Airbnb's ESLint config is widely used. It enforces consistent coding standards.
This guide will show you how to install eslint-config-airbnb in Node.js. You'll also learn to configure it properly.
Prerequisites
Before installing, ensure you have:
- Node.js installed (v14 or higher recommended)
- npm or yarn package manager
- A Node.js project setup
If you need to set up ESLint first, see our guide on How to Install ESLint in Node.js.
Installation Steps
Follow these steps to install Airbnb's ESLint config:
1. Install Required Packages
Run this command in your project directory:
npx install-peerdeps --dev eslint-config-airbnb
This installs:
eslint-config-airbnb
- All required peer dependencies
- Development dependencies only
2. Verify Installation
Check your package.json
. You should see new devDependencies:
"devDependencies": {
"eslint": "^8.0.0",
"eslint-config-airbnb": "^19.0.0",
"eslint-plugin-import": "^2.25.0",
"eslint-plugin-jsx-a11y": "^6.5.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0"
}
Configuration
After installation, configure ESLint to use Airbnb's rules.
1. Create ESLint Config File
Create .eslintrc.json
in your project root:
{
"extends": "airbnb",
"rules": {
// Add custom rules here
}
}
2. Add Script to package.json
Add a lint script for easy execution:
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
Usage Examples
Here's how to use the configured ESLint:
Basic Linting
Run this command to lint all files:
npm run lint
Auto-fix Issues
Many issues can be fixed automatically:
npm run lint:fix
Troubleshooting
Common issues and solutions:
Peer Dependency Warnings
If you see peer dependency warnings:
npm install --save-dev eslint@^8.0.0 eslint-plugin-react@^7.28.0
React Version Conflicts
For React projects, ensure compatibility. Check our guide on Express installation for similar setup patterns.
Customizing Rules
You can override Airbnb's rules. Edit .eslintrc.json
:
{
"extends": "airbnb",
"rules": {
"no-console": "off",
"indent": ["error", 4]
}
}
Conclusion
Installing eslint-config-airbnb improves code quality. It enforces consistent JavaScript style. The setup process is straightforward.
Remember to regularly update the packages. For more Node.js tips, see our guide on installing dotenv.
Happy coding with Airbnb's JavaScript style guide!