]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-trailing-spaces.md
831ab331a5a3f7d620476bb55421c6e637d801e5
[pve-eslint.git] / eslint / docs / src / rules / no-trailing-spaces.md
1 ---
2 title: no-trailing-spaces
3 layout: doc
4 rule_type: layout
5 ---
6
7
8
9 Sometimes in the course of editing files, you can end up with extra whitespace at the end of lines. These whitespace differences can be picked up by source control systems and flagged as diffs, causing frustration for developers. While this extra whitespace causes no functional issues, many code conventions require that trailing spaces be removed before check-in.
10
11 ## Rule Details
12
13 This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines.
14
15 Examples of **incorrect** code for this rule:
16
17 ::: incorrect
18
19 ```js
20 /*eslint no-trailing-spaces: "error"*/
21
22 var foo = 0;//•••••
23 var baz = 5;//••
24 //•••••
25 ```
26
27 :::
28
29 Examples of **correct** code for this rule:
30
31 ::: correct
32
33 ```js
34 /*eslint no-trailing-spaces: "error"*/
35
36 var foo = 0;
37 var baz = 5;
38 ```
39
40 :::
41
42 ## Options
43
44 This rule has an object option:
45
46 * `"skipBlankLines": false` (default) disallows trailing whitespace on empty lines
47 * `"skipBlankLines": true` allows trailing whitespace on empty lines
48 * `"ignoreComments": false` (default) disallows trailing whitespace in comment blocks
49 * `"ignoreComments": true` allows trailing whitespace in comment blocks
50
51 ### skipBlankLines
52
53 Examples of **correct** code for this rule with the `{ "skipBlankLines": true }` option:
54
55 ::: correct
56
57 ```js
58 /*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/
59
60 var foo = 0;
61 var baz = 5;
62 //•••••
63 ```
64
65 :::
66
67 ### ignoreComments
68
69 Examples of **correct** code for this rule with the `{ "ignoreComments": true }` option:
70
71 ::: correct
72
73 ```js
74 /*eslint no-trailing-spaces: ["error", { "ignoreComments": true }]*/
75
76 //foo•
77 //•••••
78 /**
79 *•baz
80 *••
81 *•bar
82 */
83 ```
84
85 :::