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