Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Latest commit

 

History

History
77 lines (62 loc) · 2.16 KB

terNoMixedSpacesAndTabsRule.md

File metadata and controls

77 lines (62 loc) · 2.16 KB

ter-no-mixed-spaces-and-tabs (ESLint: no-mixed-spaces-and-tabs)

rule_source test_source

disallow mixed spaces and tabs for indentation (recommended)

Rationale

Using only one of tabs or spaces for indentation leads to more consistent editor behavior, cleaner diffs in version control, and easier programmatic manipulation.

Config

This rule takes an object argument with an optional type property which can be set to:

  • spaces enforces consistent spaces for indentation.
  • tabs enforces consistent tabs for indentation.

If the above is not provided, the rule will enforce either all tabs or all spaces on each line, although different lines may differ between tabs and spaces.

Optionally, a smartTabs boolean property can be specified. If set to true, smart tabs allow mixing tabs and spaces if tabs are used for indentation and spaces for alignment, eg.

function main() {
// --->const a = 1,
// --->......b = 2;

    const a = 1,
          b = 2;
}

Examples

"ter-no-mixed-spaces-and-tabs": { "type": "tabs" }
"ter-no-mixed-spaces-and-tabs": { "type": "spaces" }
"ter-no-mixed-spaces-and-tabs": { "smartTabs": true }
"ter-no-mixed-spaces-and-tabs": { "type": "tabs", "smartTabs": true }

Schema

{
  "type": "array",
  "items": [
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "tabs",
            "spaces"
          ]
        },
        "smartTabs": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    }
  ],
  "minLength": 0,
  "maxLength": 1
}