]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-mixed-spaces-and-tabs.md
ba34dbe49294cb755d25ec927ff0f4cb93eff945
[pve-eslint.git] / eslint / docs / rules / no-mixed-spaces-and-tabs.md
1 # disallow mixed spaces and tabs for indentation (no-mixed-spaces-and-tabs)
2
3 Most code conventions require either tabs or spaces be used for indentation. As such, it's usually an error if a single line of code is indented with both tabs and spaces.
4
5 ## Rule Details
6
7 This rule disallows mixed spaces and tabs for indentation.
8
9 Examples of **incorrect** code for this rule:
10
11 ```js
12 /*eslint no-mixed-spaces-and-tabs: "error"*/
13
14 function add(x, y) {
15 // --->..return x + y;
16
17 return x + y;
18 }
19
20 function main() {
21 // --->var x = 5,
22 // --->....y = 7;
23
24 var x = 5,
25 y = 7;
26 }
27 ```
28
29 Examples of **correct** code for this rule:
30
31 ```js
32 /*eslint no-mixed-spaces-and-tabs: "error"*/
33
34 function add(x, y) {
35 // --->return x + y;
36 return x + y;
37 }
38 ```
39
40 ## Options
41
42 This rule has a string option.
43
44 * `"smart-tabs"` allows mixed tabs and spaces when the spaces are used for alignment.
45
46 ### smart-tabs
47
48 Examples of **correct** code for this rule with the `"smart-tabs"` option:
49
50 ```js
51 /*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
52
53 function main() {
54 // --->var x = 5,
55 // --->....y = 7;
56
57 var x = 5,
58 y = 7;
59 }
60 ```
61
62
63 ## Further Reading
64
65 * [Smart Tabs](https://www.emacswiki.org/emacs/SmartTabs)