indent
This rule enforces consistent indentation.
How to use
module.exports = {
rules: {
"@html-eslint/indent": "error",
},
};
Rule Details
Options
This rule has a mixed option:
For 4-space indentation (default option):
{
"@html-eslint/indent": ["error", 4]
}Or, for tabbed indentation:
{
"@html-eslint/indent": ["error", "tab"]
}Examples of incorrect code for this rule with the default option:
<html>
<body></body>
</html>Examples of correct code for this rule:
<html>
<body></body>
</html>
number (default: 4)
If the option is number it means the number of spaces for indentation.
{
"@html-eslint/indent": ["error", 2]
}Examples of incorrect code for this rule with the
2 option:
<html>
<body></body>
</html>Examples of correct code for this rule with the
2 option:
<html>
<body></body>
</html>
tab
If the option is "tab" it enforces tab-based indentation.
{
"@html-eslint/indent": ["error", "tab"]
}Examples of incorrect code for this rule:
<html>
<body></body>
</html>Examples of correct code for this rule:
<html>
<body></body>
</html>
Customizing options
This rule has an object option:
{
"@html-eslint/indent": [
"error",
2,
{
"Attribute": 2,
"tagChildrenIndent": {
"html": 0,
"div": 1
// ...
}
}
]
}Attribute(default: 1): Specifies the attribute indentation level. e.g. indent of 2 spaces withAttributeset to2will indent the attributes with4spaces (2 x 2).tagChildrenIndent(default:{}): Specifies the indent increment of the child tags of the specified tag. e.g. For example,"tagChildrenIndent": { "html": 0 }will set the<html/>tag children to 0 indent (2 x 0).