opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

The Airbnb JavaScript Style Guide: a mostly reasonable approach to JS
GitHub RepoImpressions6

Project Description

View on GitHub

Stop Arguing About JavaScript Style: Let Airbnb's Guide Settle It

You know the drill. You're reviewing a pull request, and someone has used var instead of const. Or they've left a trailing comma where your team's convention says none should exist. Suddenly, a five-line change turns into a twenty-minute debate about style. It's exhausting, and it's a problem that every JavaScript team eventually hits. That's where the Airbnb JavaScript Style Guide comes in—it's a mostly reasonable approach to writing JavaScript that's been battle-tested across one of the largest codebases in the world.

What It Does

The Airbnb JavaScript Style Guide is exactly what it sounds like: a comprehensive, opinionated set of rules for how to write modern JavaScript. But it's more than just a PDF of suggestions. The repository pairs the written guide with ESLint configurations (eslint-config-airbnb and eslint-config-airbnb-base) that automatically enforce these rules in your editor and CI pipeline.

The guide covers everything from the mundane (whitespace, commas, semicolons) to the architectural (classes, modules, iterators). It assumes you're using Babel with babel-preset-airbnb and installing browser shims via airbnb-browser-shims, so it's built for modern ES6+ code, not legacy JavaScript.

The rule sections read like a well-organized textbook. You've got types, references, objects, arrays, destructuring, strings, functions, arrow functions, and on through to testing, performance, and naming conventions. Each rule comes with a clear explanation, code examples showing the "right" way, and—where relevant—a link to the specific ESLint rule that enforces it.

Why It's Cool

What makes this guide stand out isn't just the rules themselves—it's how they're presented and enforced.

Every rule has a "why." This is the killer feature. The guide doesn't just tell you "use const over var"—it explains that this ensures you can't accidentally reassign references, which prevents a whole class of bugs. When you understand the reasoning, you're far more likely to follow the rule consistently, and you can actually defend it in code review.

It's a living document, not a dusty spec. The guide has been updated to include modern JavaScript features like destructuring, arrow functions, and BigInts. It even acknowledges the limitations of polyfills for newer types like symbol and bigint, warning against using them in environments that don't support them natively. That's the kind of practical, real-world awareness you don't get from a generic style guide.

The ESLint integration is the real magic. You don't have to memorize all these rules. You install eslint-config-airbnb, and your editor starts flagging violations as you type. Your CI can fail builds on style violations. The guide transforms from a document people skim to a set of automated checks that run on every commit. That's how you actually get a whole team writing consistent code.

It covers more than just JavaScript. The repo links out to style guides for React, CSS-in-JavaScript, and even Ruby. If you're an Airbnb-style shop across your whole stack, you can standardize everything.

How to Try It

Getting started is straightforward, but you'll want to set up your build for Babel first. Here's the quick path:

  1. Install the ESLint config for your project:
npm install --save-dev eslint-config-airbnb
  1. If you're using React, you'll also want:
npm install --save-dev eslint-config-airbnb-base

Wait, that's backwards. The base config is actually for projects without React. The main eslint-config-airbnb package includes React rules. Pick the one that matches your stack.

  1. Add it to your .eslintrc file:
{
  "extends": "airbnb"
}
  1. Set up Babel with babel-preset-airbnb and install airbnb-browser-shims for polyfills, as the guide assumes you're using them.

  2. Start coding. Your editor will begin flagging violations, and you can work through the guide section by section to understand why each rule exists.

The full guide, with all code examples and explanations, is available right in the repository.

Final Thoughts

This guide isn't for everyone. If you're a solo developer who's happy with your current style, you don't need it. But if you're on a team, or you're hiring, or you're looking to level up your own JavaScript habits, it's invaluable. Having a single, authoritative reference that everyone agrees to follow—and that your tooling enforces automatically—removes an entire category of friction from your workflow.

The best part? You don't have to agree with every single rule. The guide is called "mostly reasonable" for a reason. Even if you fork it or deviate in a few places, you're starting from a solid, thought-out baseline rather than inventing your own conventions from scratch. That's a huge win.

Follow @githubprojects for more developer tools and open source projects.

Back to Projects
Project ID: 3a015574-0c3d-4208-8e50-25206228fe3dLast updated: August 17, 2026 at 03:01 PM