]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-mixed-spaces-and-tabs.md
import 8.41.0 source
[pve-eslint.git] / eslint / docs / src / rules / no-mixed-spaces-and-tabs.md
1 ---
2 title: no-mixed-spaces-and-tabs
3 rule_type: layout
4 further_reading:
5 - https://www.emacswiki.org/emacs/SmartTabs
6 ---
7
8
9
10 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.
11
12 ## Rule Details
13
14 This rule disallows mixed spaces and tabs for indentation.
15
16 Examples of **incorrect** code for this rule:
17
18 ::: incorrect
19
20 ```js
21 /*eslint no-mixed-spaces-and-tabs: "error"*/
22
23 function add(x, y) {
24 // --->..return x + y;
25
26 return x + y;
27 }
28
29 function main() {
30 // --->var x = 5,
31 // --->....y = 7;
32
33 var x = 5,
34 y = 7;
35 }
36 ```
37
38 :::
39
40 Examples of **correct** code for this rule:
41
42 ::: correct
43
44 ```js
45 /*eslint no-mixed-spaces-and-tabs: "error"*/
46
47 function add(x, y) {
48 // --->return x + y;
49 return x + y;
50 }
51 ```
52
53 :::
54
55 ## Options
56
57 This rule has a string option.
58
59 * `"smart-tabs"` allows mixed tabs and spaces when the spaces are used for alignment.
60
61 ### smart-tabs
62
63 Examples of **correct** code for this rule with the `"smart-tabs"` option:
64
65 ::: correct
66
67 ```js
68 /*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
69
70 function main() {
71 // --->var x = 5,
72 // --->....y = 7;
73
74 var x = 5,
75 y = 7;
76 }
77 ```
78
79 :::