]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-trailing-spaces.md
bump version to 8.4.0-3
[pve-eslint.git] / eslint / docs / rules / no-trailing-spaces.md
1 # disallow trailing whitespace at the end of lines (no-trailing-spaces)
2
3 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.
4
5 ## Rule Details
6
7 This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines.
8
9 Examples of **incorrect** code for this rule:
10
11 ```js
12 /*eslint no-trailing-spaces: "error"*/
13
14 var foo = 0;//•••••
15 var baz = 5;//••
16 //•••••
17 ```
18
19 Examples of **correct** code for this rule:
20
21 ```js
22 /*eslint no-trailing-spaces: "error"*/
23
24 var foo = 0;
25 var baz = 5;
26 ```
27
28 ## Options
29
30 This rule has an object option:
31
32 * `"skipBlankLines": false` (default) disallows trailing whitespace on empty lines
33 * `"skipBlankLines": true` allows trailing whitespace on empty lines
34 * `"ignoreComments": false` (default) disallows trailing whitespace in comment blocks
35 * `"ignoreComments": true` allows trailing whitespace in comment blocks
36
37 ### skipBlankLines
38
39 Examples of **correct** code for this rule with the `{ "skipBlankLines": true }` option:
40
41 ```js
42 /*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/
43
44 var foo = 0;
45 var baz = 5;
46 //•••••
47 ```
48
49 ### ignoreComments
50
51 Examples of **correct** code for this rule with the `{ "ignoreComments": true }` option:
52
53 ```js
54 /*eslint no-trailing-spaces: ["error", { "ignoreComments": true }]*/
55
56 //foo•
57 //•••••
58 /**
59 *•baz
60 *••
61 *•bar
62 */
63 ```