eol-last
Trailing newlines in non-empty files are a common UNIX idiom. Benefits of trailing newlines include the ability to concatenate or append to files as well as output files to the terminal without interfering with shell prompts.
Rule Details
This rule enforces at least one newline (or absence thereof) at the end of non-empty files.
Examples of incorrect code for this rule:
/* eslint @stylistic/eol-last: ["error", "always"] */⏎
⏎
function doSomething() {⏎
var foo = 2;⏎
}Examples of correct code for this rule:
/* eslint @stylistic/eol-last: ["error", "always"] */⏎
⏎
function doSomething() {⏎
var foo = 2;⏎
}⏎This rule is also applicable to CSS, Markdown, JSON files, and other non-JavaScript/TypeScript files parsed by ESLint language plugins such as @eslint/css and @eslint/markdown.
TIP
If you want to enforce that there was only a single line at the end of the file, consider enabling no-multiple-empty-lines with maxEOF and/or no-trailing-spaces.
If you need to enforce a specific linebreak style, use this rule in conjunction with linebreak-style.
Options
This rule has a string option:
"always"(default) enforces that files end with a newline (LF)"never"enforces that files do not end with a newline