Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 1.4 KB

eol-last.md

File metadata and controls

55 lines (36 loc) · 1.4 KB
规则名 规则类型
eol-last
layout

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.

规则详解

This rule enforces at least one newline (or absence thereof) at the end of non-empty files.

Prior to v0.16.0 this rule also enforced that there was only a single line at the end of the file. If you still want this behavior, consider enabling no-multiple-empty-lines with maxEOF and/or no-trailing-spaces.

此规则的 错误 代码实例:

/*eslint eol-last: ["error", "always"]*/

function doSomething() {
  var foo = 2;
}

此规则的 正确 代码实例:

::: correct

/*eslint eol-last: ["error", "always"]*/

function doSomething() {
  var foo = 2;
}\n

配置项

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
  • "unix" (deprecated) is identical to "always"
  • "windows" (deprecated) is identical to "always", but will use a CRLF character when autofixing

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.