]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | # disallow all tabs (no-tabs) |
2 | ||
3 | Some style guides don't allow the use of tab characters at all, including within comments. | |
4 | ||
5 | ## Rule Details | |
6 | ||
7 | This rule looks for tabs anywhere inside a file: code, comments or anything else. | |
8 | ||
9 | Examples of **incorrect** code for this rule: | |
10 | ||
11 | ```js | |
12 | var a \t= 2; | |
13 | ||
14 | /** | |
15 | * \t\t it's a test function | |
16 | */ | |
17 | function test(){} | |
18 | ||
19 | var x = 1; // \t test | |
20 | ``` | |
21 | ||
22 | Examples of **correct** code for this rule: | |
23 | ||
24 | ```js | |
25 | var a = 2; | |
26 | ||
27 | /** | |
28 | * it's a test function | |
29 | */ | |
30 | function test(){} | |
31 | ||
32 | var x = 1; // test | |
33 | ``` | |
34 | ||
35 | ### Options | |
36 | ||
37 | This rule has an optional object option with the following properties: | |
38 | ||
39 | * `allowIndentationTabs` (default: false): If this is set to true, then the rule will not report tabs used for indentation. | |
40 | ||
41 | #### allowIndentationTabs | |
42 | ||
43 | Examples of **correct** code for this rule with the `allowIndentationTabs: true` option: | |
44 | ||
45 | ```js | |
46 | /* eslint no-tabs: ["error", { allowIndentationTabs: true }] */ | |
47 | ||
48 | function test() { | |
49 | \tdoSomething(); | |
50 | } | |
51 | ||
52 | \t// comment with leading indentation tab | |
53 | ``` | |
54 | ||
55 | ## When Not To Use It | |
56 | ||
57 | If you have established a standard where having tabs is fine, then you can disable this rule. | |
58 | ||
59 | ## Compatibility | |
60 | ||
61 | * **JSCS**: [disallowTabs](https://jscs-dev.github.io/rule/disallowTabs) |