ter-indent (ESLint: indent)
enforce consistent indentation
Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.
The string 'tab' or an integer indicating the number of spaces to use per tab.
An object may be provided to fine tune the indentation rules:
"SwitchCase"
(default: 0) enforces indentation level forcase
clauses inswitch
statements"VariableDeclarator"
(default: 1) enforces indentation level forvar
declarators; can also take an object to define separate rules forvar
,let
andconst
declarations."outerIIFEBody"
(default: 1) enforces indentation level for file-level IIFEs."MemberExpression"
(off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)"FunctionDeclaration"
takes an object to define rules for function declarations."parameters"
(off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string"first"
indicating that all parameters of the declaration must be aligned with the first parameter."body"
(default: 1) enforces indentation level for the body of a function expression.
"FunctionExpression"
takes an object to define rules for function declarations."parameters"
(off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string"first"
indicating that all parameters of the declaration must be aligned with the first parameter."body"
(default: 1) enforces indentation level for the body of a function expression.
"CallExpression"
takes an object to define rules for function call expressions."arguments"
(off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string"first"
indicating that all arguments of the expression must be aligned with the first argument.
"ter-indent": [true, "tab"]
"ter-indent": [true, 2]
"ter-indent": [
true,
2,
{
"FunctionExpression": {
"parameters": 1,
"body": 1
}
}
]
{
"type": "array",
"items": [
{
"type": "number",
"minimum": "0"
},
{
"type": "string",
"enum": [
"tab"
]
},
{
"type": "object",
"properties": {
"SwitchCase": {
"type": "number",
"minimum": 0
},
"VariableDeclarator": {
"type": "object",
"properties": {
"var": {
"type": "number",
"minimum": 0
},
"let": {
"type": "number",
"minimum": 0
},
"const": {
"type": "number",
"minimum": 0
}
}
},
"outerIIFEBody": {
"type": "number"
},
"FunctionDeclaration": {
"type": "object",
"properties": {
"parameters": {
"type": "number",
"minimum": 0
},
"body": {
"type": "number",
"minimum": 0
}
}
},
"FunctionExpression": {
"type": "object",
"properties": {
"parameters": {
"type": "number",
"minimum": 0
},
"body": {
"type": "number",
"minimum": 0
}
}
},
"MemberExpression": {
"type": "number"
},
"CallExpression": {
"type": "object",
"properties": {
"arguments": {
"type": "number",
"minimum": 0
}
}
}
},
"additionalProperties": false
}
],
"minLength": 1,
"maxLength": 2
}
TSLint provides the indent
rule but it currently only checks if we are using tabs or spaces.
As of 11/1/2016 there is an open issue to add enhancements to the rule: palantir/tslint#581.