validateIndentation

Validates indentation for switch statements and block statements

Types: Integer, String or Object

Values:

  • Integer: A positive number of spaces
  • String: "\t" for tab indentation
  • Object:
    • value: (required) the same effect as the non-object values
    • includeEmptyLines (deprecated): (default: false) require empty lines to be indented
    • 'allExcept' array of exceptions:
      • 'comments' ignores comments
      • 'emptyLines' ignore empty lines, included by default

JSHint: indent

Example

"validateIndentation": "\t"
Valid example for mode 2
if (a) {
  b=c;
  function(d) {
    e=f;
  }
}
Invalid example for mode 2
if (a) {
   b=c;
function(d) {
       e=f;
}
}
Valid example for mode "\t"
if (a) {
    b=c;
    function(d) {
        e=f;
    }
}
Invalid example for mode "\t"
if (a) {
     b=c;
function(d) {
           e=f;
 }
}
Valid example for mode { "value": "\t", "allExcept": ["emptyLines"] }
if (a) {
    b=c;
    function(d) {
        e=f;
    }

} // single tab character on previous line
Invalid example for mode { "value": "\t", "allExcept": ["emptyLines"] } }
if (a) {
    b=c;
    function(d) {
        e=f;
    }

} // no tab character on previous line
Valid example for mode { "value": "\t", "allExcept": ["comments"] }
if (a) {
    b=c;
//    e=f
}
Rule source
Test source