eslint-config-airbnb-base/rules/style
Indentation and whitespace
indent — 2-space indentation
indent — 2-space indentation
switch case clauses are indented one level from the switch keyword. JSX nodes are excluded from this rule (handled separately by react/jsx-indent).no-tabs — disallow tab characters
no-tabs — disallow tab characters
no-trailing-spaces — disallow trailing whitespace
no-trailing-spaces — disallow trailing whitespace
no-multiple-empty-lines — limit consecutive blank lines
no-multiple-empty-lines — limit consecutive blank lines
eol-last — require newline at end of file
eol-last — require newline at end of file
linebreak-style — require Unix line endings
linebreak-style — require Unix line endings
\n (LF) line endings are allowed. CRLF (\r\n) line endings are rejected. Configure your editor and Git to use LF on all platforms.Quotes and semicolons
quotes — single quotes
quotes — single quotes
semi — require semicolons
semi — require semicolons
semi-style: last, so semicolons belong at the end of a line, not the beginning.jsx-quotes — double quotes in JSX attributes
jsx-quotes — double quotes in JSX attributes
eslint-config-airbnb React rule set.Naming conventions
camelcase — require camelCase identifiers
camelcase — require camelCase identifiers
properties: 'never'). Destructured variables are not required to be renamed.new-cap — require PascalCase for constructors
new-cap — require PascalCase for constructors
new must start with a capital letter. Functions starting with a capital letter must be called with new. Exceptions: Immutable.Map, Immutable.Set, Immutable.List.no-underscore-dangle — disallow dangling underscores
no-underscore-dangle — disallow dangling underscores
#private fields.Commas and object literals
comma-dangle — require trailing commas in multiline literals
comma-dangle — require trailing commas in multiline literals
always-multiline)Trailing commas are required in multiline arrays, objects, imports, exports, and function parameters. Single-line literals do not require trailing commas.comma-style — last comma
comma-style — last comma
object-curly-spacing — require spaces inside braces
object-curly-spacing — require spaces inside braces
always)Object literals and destructuring patterns must have spaces after { and before }.quote-props — only quote properties when necessary
quote-props — only quote properties when necessary
as-needed)Object property keys must not be quoted unless they are not valid identifiers (e.g., reserved words or hyphenated strings).Line length and line breaks
max-len — 100-character line limit
max-len — 100-character line limit
newline-per-chained-call — newline for deeply chained calls
newline-per-chained-call — newline for deeply chained calls
function-paren-newline — consistent line breaks in function arguments
function-paren-newline — consistent line breaks in function arguments
multiline-arguments)If any argument in a function call spans multiple lines, all arguments must each be on their own line.Control flow and operators
no-nested-ternary — disallow nested ternary expressions
no-nested-ternary — disallow nested ternary expressions
if statements.no-mixed-operators — disallow mixing operator groups
no-mixed-operators — disallow mixing operator groups
no-plusplus — disallow ++ and --
no-plusplus — disallow ++ and --
++ and -- unary operators interact with automatic semicolon insertion in non-obvious ways. Use += 1 and -= 1 instead.no-restricted-syntax — ban for-in and for-of loops
no-restricted-syntax — ban for-in and for-of loops
| Syntax | Reason |
|---|---|
for...in | Iterates the prototype chain; use Object.keys/values/entries |
for...of | Requires regenerator-runtime; prefer array iteration methods |
| Labeled statements | Hard to maintain; essentially GOTO |
with statement | Makes code unpredictable; disallowed in strict mode |
prefer-exponentiation-operator — use ** instead of Math.pow
prefer-exponentiation-operator — use ** instead of Math.pow
Variable declarations
one-var — one declaration per statement
one-var — one declaration per statement
never)Each variable must be declared in its own statement rather than grouping multiple declarations with commas.prefer-object-spread — prefer spread over Object.assign
prefer-object-spread — prefer spread over Object.assign