This page documents the style and formatting rules enforced by the Airbnb ESLint configuration, specifically the rules defined in the style.js module. These rules govern code aesthetics including whitespace, indentation, quotes, semicolons, commas, braces, naming conventions, and line length limits. The rules ensure consistent visual formatting across codebases using the Airbnb style guide.
For the human-readable style guide that these rules implement, see 2.7 For React-specific JSX formatting rules, see 3.3 For the overall ESLint package architecture, see 5
Sources: packages/eslint-config-airbnb-base/rules/style.js1-534
The style rules are defined in a single ESLint configuration module that exports approximately 60 distinct rules. All rules in this module are part of the eslint-config-airbnb-base package and apply to both React and non-React projects.
Sources: packages/eslint-config-airbnb-base/rules/style.js1-534
The style rules use three severity levels: 'error' (fails CI/CD), 'warn' (non-blocking), and 'off' (disabled). The vast majority of style rules are set to 'error', enforcing strict compliance.
| Severity | Count | Notable Rules |
|---|---|---|
'error' | ~55 rules | Most spacing, indentation, quotes, semicolons, naming |
'warn' | 1 rule | func-names |
'off' | ~15 rules | Many marked with TODO comments for future enablement |
Sources: packages/eslint-config-airbnb-base/rules/style.js96 packages/eslint-config-airbnb-base/rules/style.js6 packages/eslint-config-airbnb-base/rules/style.js11 packages/eslint-config-airbnb-base/rules/style.js101 packages/eslint-config-airbnb-base/rules/style.js197-199
These rules enforce consistent spacing around language constructs to improve readability.
| Rule | Configuration | Description |
|---|---|---|
array-bracket-spacing | ['error', 'never'] | No spaces inside array brackets |
block-spacing | ['error', 'always'] | Spaces inside single-line blocks |
computed-property-spacing | ['error', 'never'] | No spaces in computed properties |
object-curly-spacing | ['error', 'always'] | Spaces inside object braces |
space-in-parens | ['error', 'never'] | No spaces inside parentheses |
space-infix-ops | 'error' | Spaces around infix operators |
key-spacing | { beforeColon: false, afterColon: true } | Spacing around object property colons |
comma-spacing | { before: false, after: true } | Space after commas, not before |
Sources: packages/eslint-config-airbnb-base/rules/style.js14 packages/eslint-config-airbnb-base/rules/style.js18 packages/eslint-config-airbnb-base/rules/style.js71 packages/eslint-config-airbnb-base/rules/style.js399 packages/eslint-config-airbnb-base/rules/style.js491 packages/eslint-config-airbnb-base/rules/style.js494 packages/eslint-config-airbnb-base/rules/style.js154 packages/eslint-config-airbnb-base/rules/style.js51
| Rule | Configuration | Purpose |
|---|---|---|
func-call-spacing | ['error', 'never'] | No space between function name and parentheses |
space-before-function-paren | Anonymous: 'always', Named: 'never', AsyncArrow: 'always' | Controls space before function parameters |
keyword-spacing | { before: true, after: true } | Spaces around keywords like if, for, return |
space-before-blocks | 'error' | Space required before opening brace |
Sources: packages/eslint-config-airbnb-base/rules/style.js84 packages/eslint-config-airbnb-base/rules/style.js484-488 packages/eslint-config-airbnb-base/rules/style.js157-165 packages/eslint-config-airbnb-base/rules/style.js480
| Rule | Configuration | Enforcement |
|---|---|---|
no-trailing-spaces | { skipBlankLines: false, ignoreComments: false } | Disallow trailing whitespace |
no-whitespace-before-property | 'error' | Disallow space before property access |
no-mixed-spaces-and-tabs | 'error' | Disallow mixing spaces and tabs |
no-tabs | 'error' | Disallow tab characters entirely |
no-multiple-empty-lines | { max: 1, maxBOF: 0, maxEOF: 0 } | Limit consecutive empty lines |
Sources: packages/eslint-config-airbnb-base/rules/style.js371-374 packages/eslint-config-airbnb-base/rules/style.js392 packages/eslint-config-airbnb-base/rules/style.js314 packages/eslint-config-airbnb-base/rules/style.js365 packages/eslint-config-airbnb-base/rules/style.js322
The indent rule is one of the most complex in the configuration, with specific handling for various language constructs.
| Property | Value | Purpose |
|---|---|---|
| Base indent | 2 | Two spaces per indentation level |
SwitchCase | 1 | Indent case clauses inside switch |
VariableDeclarator | 1 | Indent variable declarations |
outerIIFEBody | 1 | Indent body of IIFE expressions |
FunctionDeclaration.parameters | 1 | Indent function parameters |
FunctionDeclaration.body | 1 | Indent function body |
CallExpression.arguments | 1 | Indent function call arguments |
flatTernaryExpressions | false | Do not flatten ternary indentation |
ignoreComments | false | Apply indentation rules to comments |
The indent rule specifically ignores 15 JSX node types to avoid conflicts with React-specific JSX indentation rules. This is configured in the ignoredNodes array.
Ignored JSX nodes:
JSXElement, JSXElement > *, JSXAttribute, JSXIdentifier, JSXNamespacedNameJSXMemberExpression, JSXSpreadAttribute, JSXExpressionContainerJSXOpeningElement, JSXClosingElement, JSXFragmentJSXOpeningFragment, JSXClosingFragment, JSXText, JSXEmptyExpression, JSXSpreadChildSources: packages/eslint-config-airbnb-base/rules/style.js124-147
| Rule | Configuration | Enforcement |
|---|---|---|
quotes | ['error', 'single', { avoidEscape: true }] | Single quotes, allow double to avoid escapes |
quote-props | ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }] | Quote object keys only when necessary |
jsx-quotes | ['off', 'prefer-double'] | JSX quote preference (disabled in base) |
template-tag-spacing | ['error', 'never'] | No space between template tag and literal |
Sources: packages/eslint-config-airbnb-base/rules/style.js457 packages/eslint-config-airbnb-base/rules/style.js454 packages/eslint-config-airbnb-base/rules/style.js151 packages/eslint-config-airbnb-base/rules/style.js525
| Rule | Configuration | Description |
|---|---|---|
semi | ['error', 'always'] | Semicolons required at statement end |
semi-spacing | { before: false, after: true } | Space after semicolon, not before |
semi-style | ['error', 'last'] | Semicolon at end of line, not beginning |
Sources: packages/eslint-config-airbnb-base/rules/style.js464 packages/eslint-config-airbnb-base/rules/style.js467 packages/eslint-config-airbnb-base/rules/style.js471
| Rule | Configuration | Description |
|---|---|---|
comma-dangle | 'always-multiline' for arrays, objects, imports, exports, functions | Trailing comma required in multiline structures |
comma-spacing | { before: false, after: true } | Space after comma, not before |
comma-style | ['error', 'last'] | Comma at end of line, not beginning |
Sources: packages/eslint-config-airbnb-base/rules/style.js42-48 packages/eslint-config-airbnb-base/rules/style.js51 packages/eslint-config-airbnb-base/rules/style.js54-68
| Rule | Configuration | Description |
|---|---|---|
brace-style | ['error', '1tbs', { allowSingleLine: true }] | One True Brace Style with single-line exception |
padded-blocks | { blocks: 'never', classes: 'never', switches: 'never' } | No padding inside blocks |
nonblock-statement-body-position | ['error', 'beside'] | Statement body beside condition on same line |
Sources: packages/eslint-config-airbnb-base/rules/style.js21 packages/eslint-config-airbnb-base/rules/style.js432-438 packages/eslint-config-airbnb-base/rules/style.js396
| Rule | Configuration | Description |
|---|---|---|
object-curly-newline | { minProperties: 4, multiline: true, consistent: true } | Line breaks for objects with 4+ properties |
object-property-newline | { allowAllPropertiesOnSameLine: true } | Allow all properties on same line |
array-bracket-newline | ['off', 'consistent'] | Disabled - TODO for future |
array-element-newline | ['off', { multiline: true, minItems: 3 }] | Disabled - TODO for future |
Sources: packages/eslint-config-airbnb-base/rules/style.js403-408 packages/eslint-config-airbnb-base/rules/style.js412-414 packages/eslint-config-airbnb-base/rules/style.js6 packages/eslint-config-airbnb-base/rules/style.js11
The max-len rule enforces a 100-character line length with several exceptions:
| Configuration | Value | Purpose |
|---|---|---|
| Maximum length | 100 characters | Base line length limit |
| Tab width | 2 spaces | Character count for tabs |
ignoreUrls | true | URLs can exceed limit |
ignoreComments | false | Comments must respect limit |
ignoreRegExpLiterals | true | Regular expressions can exceed |
ignoreStrings | true | String literals can exceed |
ignoreTemplateLiterals | true | Template literals can exceed |
Sources: packages/eslint-config-airbnb-base/rules/style.js206-212
| Rule | Configuration | Description |
|---|---|---|
eol-last | ['error', 'always'] | Newline required at end of file |
linebreak-style | ['error', 'unix'] | Unix (LF) line endings required |
newline-per-chained-call | { ignoreChainWithDepth: 4 } | Line breaks for method chains >4 deep |
implicit-arrow-linebreak | ['error', 'beside'] | Arrow function body on same line |
function-paren-newline | ['error', 'multiline-arguments'] | Consistent line breaks in function parameters |
Sources: packages/eslint-config-airbnb-base/rules/style.js77 packages/eslint-config-airbnb-base/rules/style.js178 packages/eslint-config-airbnb-base/rules/style.js274 packages/eslint-config-airbnb-base/rules/style.js120 packages/eslint-config-airbnb-base/rules/style.js105
| Rule | Configuration | Description |
|---|---|---|
camelcase | { properties: 'never', ignoreDestructuring: false } | Enforce camelCase naming |
new-cap | { newIsCap: true, capIsNew: false, capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'] } | Constructors must start with capital |
no-underscore-dangle | { allow: [], enforceInMethodNames: true } | Disallow dangling underscores |
Sources: packages/eslint-config-airbnb-base/rules/style.js24 packages/eslint-config-airbnb-base/rules/style.js254-260 packages/eslint-config-airbnb-base/rules/style.js378-383
| Rule | Configuration | Enforcement |
|---|---|---|
func-names | 'warn' | Function expressions should have names (warning only) |
func-name-matching | ['off', 'always'] | Function name should match variable (disabled) |
func-style | ['off', 'expression'] | Disabled - no preference for declaration vs expression |
Sources: packages/eslint-config-airbnb-base/rules/style.js96 packages/eslint-config-airbnb-base/rules/style.js89-92 packages/eslint-config-airbnb-base/rules/style.js101
| Rule | Configuration | Description |
|---|---|---|
spaced-comment | ['error', 'always', { exceptions: ['-', '+'], markers: ['=', '!', '/', ':', '::'] }] | Space after // or /* required |
capitalized-comments | ['off', 'never'] | Comment capitalization not enforced |
line-comment-position | ['off'] | Comment position not enforced |
no-inline-comments | 'off' | Inline comments allowed |
Sources: packages/eslint-config-airbnb-base/rules/style.js507-517 packages/eslint-config-airbnb-base/rules/style.js28-39 packages/eslint-config-airbnb-base/rules/style.js170-174 packages/eslint-config-airbnb-base/rules/style.js288
| Rule | Configuration | Description |
|---|---|---|
no-mixed-operators | Complex group configuration | Require parentheses for mixed operators |
operator-linebreak | ['error', 'before', { overrides: { '=': 'none' } }] | Operator at beginning of line |
operator-assignment | ['error', 'always'] | Use assignment operator shorthand |
space-unary-ops | { words: true, nonwords: false } | Space for word operators, not symbols |
Sources: packages/eslint-config-airbnb-base/rules/style.js296-311 packages/eslint-config-airbnb-base/rules/style.js429 packages/eslint-config-airbnb-base/rules/style.js425 packages/eslint-config-airbnb-base/rules/style.js498-503
| Rule | Configuration | Description |
|---|---|---|
no-nested-ternary | 'error' | Nested ternaries disallowed |
no-unneeded-ternary | { defaultAssignment: false } | Disallow unnecessary ternaries |
multiline-ternary | ['off', 'never'] | Multiline ternary style not enforced |
Sources: packages/eslint-config-airbnb-base/rules/style.js329 packages/eslint-config-airbnb-base/rules/style.js388 packages/eslint-config-airbnb-base/rules/style.js251
| Rule | Configuration | Rationale |
|---|---|---|
no-bitwise | 'error' | Bitwise operators often indicate typos |
no-continue | 'error' | Continue statements reduce clarity |
no-plusplus | 'error' | Increment/decrement operators can be confusing |
no-lonely-if | 'error' | Prefer else if over nested if |
no-multi-assign | 'error' | Chained assignments reduce clarity |
The no-restricted-syntax rule prohibits specific statement types to enforce modern array methods and avoid legacy pitfalls.
Sources: packages/eslint-config-airbnb-base/rules/style.js281 packages/eslint-config-airbnb-base/rules/style.js285 packages/eslint-config-airbnb-base/rules/style.js336 packages/eslint-config-airbnb-base/rules/style.js292 packages/eslint-config-airbnb-base/rules/style.js318 packages/eslint-config-airbnb-base/rules/style.js340-358
| Rule | Configuration | Rationale |
|---|---|---|
no-array-constructor | 'error' | Use array literals instead of new Array() |
no-new-object | 'error' | Use object literals instead of new Object() |
new-parens | 'error' | Require parentheses when invoking constructor |
Sources: packages/eslint-config-airbnb-base/rules/style.js277 packages/eslint-config-airbnb-base/rules/style.js332 packages/eslint-config-airbnb-base/rules/style.js263
The most complex rules are indent (15+ configuration properties), no-restricted-syntax (4 prohibited constructs with custom messages), and spaced-comment (separate configurations for line and block comments).
Sources: packages/eslint-config-airbnb-base/rules/style.js1-534
Refresh this wiki