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