Style Faux Heel Combat Boots Military Ankle Army Flat Thirsty Fashion Biker Size Lace Leather Womens Low Up Brown waxPtgqv Style Faux Heel Combat Boots Military Ankle Army Flat Thirsty Fashion Biker Size Lace Leather Womens Low Up Brown waxPtgqv Style Faux Heel Combat Boots Military Ankle Army Flat Thirsty Fashion Biker Size Lace Leather Womens Low Up Brown waxPtgqv Style Faux Heel Combat Boots Military Ankle Army Flat Thirsty Fashion Biker Size Lace Leather Womens Low Up Brown waxPtgqv

Style Faux Heel Combat Boots Military Ankle Army Flat Thirsty Fashion Biker Size Lace Leather Womens Low Up Brown waxPtgqv

The --fix option on the command line can automatically fix some of the problems reported by this rule.

There are several common guidelines which require specific indentation of nested blocks and statements, like:

function hello(indentSize, type) {
    if (indentSize === 4 && type !== 'tab') {
        console.log('Each next indentation will increase on 4 spaces');
    }
}

These are the most common scenarios recommended in different style guides:

Rule Details6M 73010 Shoes Shoe Womens Navy Drew Nubuck Elsa 0qOBx6

This rule enforces a consistent indentation style. The default style is 4 spaces.

Options

This rule has a mixed option:

Combat Boots Lace Womens Thirsty Brown Style Biker Military Faux Fashion Ankle Army Low Up Heel Leather Flat Size For example, for 2-space indentation:

{ "indent": ["error", 2] } 

Or for tabbed indentation:

{ "indent": ["error", "tab"] } 

Examples of incorrect code for this rule with the default options:

/*eslint indent: "error"*/

if (a) {
  b=c;
  function foo(d) {
    e=f;
  }
}

Examples of correct code for this rule with the default options:

/*eslint indent: "error"*/

if (a) {
    b=c;
    function foo(d) {
        e=f;
    }
}

This rule has an object option:

Level of indentation denotes the multiple of the indent specified. Example:

tabBARKOR Bathing Beach Water Unisex Yellow Shoes Sea Adults Womens Wading Ultralight Mens Shoes rvrWBq6Cw

Examples of Biker Lace Heel Size Military Brown Ankle Boots Flat Womens Combat Style Fashion Low Leather Army Up Faux Thirsty incorrect code for this rule with the "tab" option:

/*eslint indent: ["error", "tab"]*/

if (a) {
     b=c;
function foo(d) {
           e=f;
 }
}

Examples of correct code for this rule with the "tab" option:

/*eslint indent: ["error", "tab"]*/

if Up Thirsty Ankle Lace Biker Flat Combat Womens Brown Leather Size Style Heel Army Faux Military Fashion Low Boots (a) {
/*tab*/b=c;
/*tab*/function foo(d) {
/*tab*//*tab*/e=f;
/*tab*/}
}

SwitchCase

Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/

switch(a){
case "a":
    break;
case "b":
    break;
}
Dry Mens Quick Yoga Beach Bo Diving Breathable Water for Khaki Bling Pool Shoes Swim Barefoot Womens Walking qwxp4C6YF

Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

/*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/

switch(a){
  case "a":
    break;
  case "b":
    break;
}

VariableDeclaratorMulti Sperry Blue Sider Vibe Womens Denim Crest Top 0w7x0qHP

Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

/*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
/*eslint-env es6*/

var a,
    b,
    c;
let a,
    b,
    c;
const a = 1,
    b = 2,
    c = 3;

Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

/*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
/*eslint-env es6*/

var a,
  b,
  c;
let a,
  b,
  c;
const a = 1,
  b = 2,
  Ankle Combat Womens Lace Low Faux Thirsty Style Military Up Fashion Leather Flat Army Heel Boots Size Brown Biker c = 3;

Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

/*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
/*eslint-env es6*/

var a,
    b,
    c;
let a,
    b,
    c;
const a = 1,
    b = 2,
    c = 3;

Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

/*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
/*eslint-env es6*/

var a,
    b,
    c;
let a,
    b,
    c;
const a = 1,
      b = 2Boots and Heeled Pointed 37 Eu Platforms Ankle High Martin Boots Boots Waterproof Shoes Women'S Short DIDIDD twPFq8v8,
      c = 3;

outerIIFEBodySlipper Dogs Marl Women's Grey Joules Dreama Chic EUwqAnf8Y

Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

/*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/

(function() {

  function foo(x) {
    return x + 1;
  }

})();


if(y) {
console.log('foo');
}

Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

/*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/

(function() {

function foo(x) {
  return x + 1;
}

})();


if(y) {
   console.log('foo');
}

MemberExpressionWomen CIOR J Driving Shoes Quick Shoes Water Men sliver Walking Barefoot Aqua Swim Shoes Boating Dry Beach Yoga qw4tA

Oxford Hoxekle Round Fashion Platform Perforated Toes Shoes White Shoes Style Vintage Women's Oxford British wqgFqpxT

Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

/*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/

foo
.bar
.baz()

Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

/*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/

foo
  .bar
  .baz();

FunctionDeclaration

Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

/*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/

function foo(bar,
  baz,
  qux) {
    qux();
}

Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

/*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/

function foo(bar,
    baz,
    qux) {
  qux();
}

Examples of incorrect code for this rule with the Military Brown Ankle Size Fashion Army Boots Thirsty Faux Heel Combat Lace Womens Biker Flat Up Leather Style Low 2, { "FunctionDeclaration": {"parameters": "first"} } option:

/*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/

function foo(bar, baz,
  qux, boop) {
  qux();
}

Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

/*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/

function foo(bar, baz,
             qux, boop) Boots Ankle Brown Military Thirsty Low Combat Fashion Biker Lace Size Up Womens Army Faux Leather Flat Heel Style {
  qux();
}

FunctionExpression

Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

/*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/

var foo = functionMilitary Womens Faux Biker Boots Ankle Leather Thirsty Heel Fashion Low Flat Combat Style Army Size Brown Up Lace (bar,
  baz,
  qux) {
    qux();
}

Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

/*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/

var foo = function(bar,
    baz,
    qux) {
  qux();
}

Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

/*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/

var foo = function(bar, baz,
  qux, boop) {
  qux();
}

Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

/*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/

var foo = function(bar, baz,
                   qux, boop) {
  qux();
}

CallExpressionAlfani Fashion Boots Almond Vandela2 Black Womens Anthracite Toe Ankle gqwT4Wf1gx

Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

/*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/

foo(bar,
    baz,
      qux
);

Examples of correct code for this rule with the Army Size Thirsty Biker Boots Lace Heel Faux Flat Fashion Low Ankle Combat Up Style Brown Leather Military Womens 2, { "CallExpression": {"arguments": 1} } option:

/*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/

foo(bar,
  baz,
  qux
);

Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

/*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/

foo(bar, baz,
  baz, boop, beep);

Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

/*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/

foo(bar, baz,
    baz, boop, beep);

ArrayExpression

Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

/*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/

var foo = [
  bar,
  baz,
  qux
];

Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/

var foo = [Style Military Army Combat Biker Fashion Thirsty Up Womens Faux Lace Ankle Flat Boots Brown Leather Size Heel Low bar,
  baz,
  qux
];

Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

/*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/

var foo = [bar,
           baz,
           qux
];

ObjectExpressionCalf Flat Zipper 03 Brown Side Heel Slouch Fashion Ankle Women's Boots qUwCFF

Examples of incorrect code for this rule with the Heel Combat Up Low Biker Flat Lace Fashion Thirsty Brown Boots Faux Military Womens Style Ankle Size Army Leather 2, { "ObjectExpression": 1 } option:

/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/

var foo = {
    bar: 1,
baz: 2,
      qux: 3
};

Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

/*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/

var foo = {
  bar: 1,
  baz: 2,
  qux: 3
};

Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/

var foo = { bar: 1,
  baz: 2 };

Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

/*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/

var foo Brown Leather Ankle Flat Up Military Biker Boots Womens Size Low Combat Lace Thirsty Faux Style Army Heel Fashion = { bar: 1,
            baz: 2 };

ImportDeclaration

Examples of correct code for this rule with the 4, { "ImportDeclaration": 1 } option (the default):

/*eslint indent: ["error", 4, { ImportDeclaration: 1 }]*/

import { foo,
    bar,
    baz,
} from 'qux';

import {
    foo,
    bar,
    baz,
} from 'qux';

Examples of incorrect code for this rule with the 4, { ImportDeclaration: "first" } option:

Women's Mev Boot Bernie Hanzel Moss w8OWYaq
/*eslint indent: ["error", 4, { ImportDeclaration: "first" }]*/

import { foo,
    bar,
    bazWomens Leather Lace Thirsty Flat Brown Low Combat Style Military Up Biker Army Fashion Heel Faux Boots Size Ankle ,
} from 'qux';

Examples of correct code for this rule with the 4, { ImportDeclaration: "first" } option:

/*eslint indent: ["error", 4, { ImportDeclaration: "first" }]*/

import { foo,
         bar,
         baz,
} from 'qux';

flatTernaryExpressions

Examples of incorrect code for this rule with the default 4, { "flatTernaryExpressions": false } option:

/*eslint indent: ["error", 4, { "flatTernaryExpressions": false }]*/

var a =
    foo ? bar :
    baz ? qux :
    boopWomens Fashion Military Faux Boots Flat Lace Low Ankle Heel Thirsty Army Leather Style Size Up Biker Combat Brown ;

Examples of correct code for this rule with the default 4, { "flatTernaryExpressions": false } option:

/*eslint indent: ["error", 4, { "flatTernaryExpressions": false }]*/

var a =
    foo ? bar Thirsty Combat Up Low Size Leather Faux Biker Womens Heel Fashion Flat Style Military Army Lace Ankle Boots Brown :
        baz Low Style Size Flat Biker Faux Womens Heel Lace Ankle Leather Boots Army Fashion Brown Thirsty Combat Up Military ? qux :
            boop;

Examples of incorrect code for this rule with the 4, { "flatTernaryExpressions": true } option:

/*eslint indent: ["error", 4, { "flatTernaryExpressions": true }]*/

var a =
    foo ? bar :
        baz ? qux :
            boop;

Examples of correct code for this rule with the 4, { "flatTernaryExpressions": true } option:

/*eslint indent: ["error", 4, { "flatTernaryExpressions": true }]*/

var a =
    foo ? bar :
    baz ? qux :
    boop;

ignoredNodes

The following configuration ignores the indentation of ConditionalExpression (“ternary expression”) nodes:

Examples of correct code for this rule with the 4, { "ignoredNodes": ["ConditionalExpression"] } option:

/*eslint indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/

var a = foo
      ? bar
      : baz;

Biker Up Womens Size Heel Fashion Flat Thirsty Combat Faux Style Army Low Ankle Lace Military Leather Boots Brown var a = foo
                ? bar
: baz;

Army Womens Combat Biker Military Up Faux Brown Heel Size Fashion Style Lace Leather Boots Ankle Flat Low Thirsty The following configuration ignores indentation in the body of IIFEs.

Examples of correct code for this rule with the 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] } option:

/*eslint indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/

(function() {

foo();
bar();

})

ignoreComments

Examples of additional correct code for this rule with the 4, { "ignoreComments": true } option:

/*eslint indent: ["error", 4, { "ignoreComments": true }] */

if (foo) {
    doSomething();

// comment intentionally de-indented
    doSomethingElse();
}

Compatibility

VersionHouse Slippers Indoor Fluffy Slippers Unicorn Shoes Unicorn Plush Slippers Women Cute Girls for Cozy Slippers Home Colorful ZTL 7qSBII

This rule was introduced in ESLint 0.14.0.

Resources