]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/eol-last.md
bump version to 8.41.0-3
[pve-eslint.git] / eslint / docs / src / rules / eol-last.md
1 ---
2 title: eol-last
3 rule_type: layout
4 ---
5
6
7
8 Trailing newlines in non-empty files are a common UNIX idiom. Benefits of
9 trailing newlines include the ability to concatenate or append to files as well
10 as output files to the terminal without interfering with shell prompts.
11
12 ## Rule Details
13
14 This rule enforces at least one newline (or absence thereof) at the end
15 of non-empty files.
16
17 Prior to v0.16.0 this rule also enforced that there was only a single line at
18 the end of the file. If you still want this behavior, consider enabling
19 [no-multiple-empty-lines](no-multiple-empty-lines) with `maxEOF` and/or
20 [no-trailing-spaces](no-trailing-spaces).
21
22 Examples of **incorrect** code for this rule:
23
24 ::: incorrect
25
26 ```js
27 /*eslint eol-last: ["error", "always"]*/
28
29 function doSomething() {
30 var foo = 2;
31 }
32 ```
33
34 :::
35
36 Examples of **correct** code for this rule:
37
38 ::: correct
39
40 ```js
41 /*eslint eol-last: ["error", "always"]*/
42
43 function doSomething() {
44 var foo = 2;
45 }\n
46 ```
47
48 :::
49
50 ## Options
51
52 This rule has a string option:
53
54 * `"always"` (default) enforces that files end with a newline (LF)
55 * `"never"` enforces that files do not end with a newline
56 * `"unix"` (deprecated) is identical to "always"
57 * `"windows"` (deprecated) is identical to "always", but will use a CRLF character when autofixing
58
59 **Deprecated:** The options `"unix"` and `"windows"` are deprecated. If you need to enforce a specific linebreak style, use this rule in conjunction with `linebreak-style`.