About this project
Airbnb JavaScript Style Guide — “A mostly reasonable approach to JavaScript.” This repository is a well-known set of conventions for writing clean, consistent JavaScript, especially modern ES6+ code. It is maintained alongside an ESLint configuration package (`eslint-config-airbnb`) and a base variant (`eslint-config-airbnb-base`).
The guide assumes usage of Babel and recommends accompanying packages such as `babel-preset-airbnb` and `airbnb-browser-shims` for polyfills.
The guide is organized into short, numbered sections with rationale and code examples showing “bad” vs. “good” patterns. Covered topics include:
- Types and references: prefer `const`, use `let` when reassignment is needed, avoid `var`.
- Objects and arrays: literal syntax, shorthand, spreads, and safe property access.
- Destructuring for objects and arrays.
- Strings: single quotes, template literals for interpolation, avoid `eval()`.
- Functions: named expressions, IIFE wrapping, never declaring functions inside blocks, using rest parameters instead of `arguments`.
- Arrow functions, classes and constructors, modules, iterators and generators.
- Properties, variables, hoisting, comparison operators and equality, blocks, control statements.
- Comments, whitespace, commas, semicolons.
- Type casting and coercion, naming conventions, accessors, events.
- jQuery usage notes, ECMAScript 5 compatibility, ES6+ styles, standard library, testing, and performance.
- Resources, community links, translations, contributors, and license.
Each rule is accompanied by applicable ESLint rule names where relevant, making the guide useful both as documentation and as a baseline for automated linting. It also links to related style guides: ES5 (deprecated), React, CSS-in-JavaScript, CSS & Sass, and Ruby. The repository has been translated into a number of languages and is widely referenced in the JavaScript community.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.