From 59d5d5c6b91784862a875a0df97ed0659100047f Mon Sep 17 00:00:00 2001 From: Arthur Dias Date: Fri, 29 May 2020 23:54:33 -0300 Subject: [PATCH 1/6] Docs: On maxEOF with eol-last (fixes #12742) Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule. --- docs/rules/no-multiple-empty-lines.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index 87b2425e010..1944dba5700 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -94,3 +94,7 @@ var bar = 3; ## When Not To Use It If you do not care about extra blank lines, turn this off. + +## Regarding the Airbnb JavaScript Style Guide `eol-last` rule + +If you wish to use the Airbnb style guide rule regarding ending files with a single newline character (`eol-last`) with this rule, `maxEOF` should be set to 0, as an empty line is actually represented by two newline characters (`\n\n`). There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. \ No newline at end of file From e2faac1df033279cab70d75fe51fccffc1c03bd7 Mon Sep 17 00:00:00 2001 From: Arthur Dias Date: Sat, 30 May 2020 00:28:02 -0300 Subject: [PATCH 2/6] Docs: On maxEOF with eol-last (fixes #12742) Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule. --- docs/rules/no-multiple-empty-lines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index 1944dba5700..b25fb426984 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -97,4 +97,4 @@ If you do not care about extra blank lines, turn this off. ## Regarding the Airbnb JavaScript Style Guide `eol-last` rule -If you wish to use the Airbnb style guide rule regarding ending files with a single newline character (`eol-last`) with this rule, `maxEOF` should be set to 0, as an empty line is actually represented by two newline characters (`\n\n`). There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. \ No newline at end of file +If you wish to use the Airbnb style guide rule regarding ending files with a single newline character (`eol-last`) with this rule, `maxEOF` should be set to 0, as an empty line is actually represented by two newline characters (`\n\n`). There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. From fa4a396893c5e1b05a9309caef1b52c3be0dfb68 Mon Sep 17 00:00:00 2001 From: Arthur Dias Date: Sat, 30 May 2020 15:10:02 -0300 Subject: [PATCH 3/6] Docs: On maxEOF with eol-last (fixes #12742) Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule. --- docs/rules/no-multiple-empty-lines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index b25fb426984..ada47d4d0b6 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -95,6 +95,6 @@ var bar = 3; If you do not care about extra blank lines, turn this off. -## Regarding the Airbnb JavaScript Style Guide `eol-last` rule +## Using It With The `eol-last` Rule -If you wish to use the Airbnb style guide rule regarding ending files with a single newline character (`eol-last`) with this rule, `maxEOF` should be set to 0, as an empty line is actually represented by two newline characters (`\n\n`). There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. +If you wish to use this rule with the `eol-last` core rule regarding ending files with a single newline character, `maxEOF` should be set to 0, as an empty line is actually represented by two newline characters (`\n\n`). There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. From 6ce9e96b6116cbbb2e662b3c422bdaf06fd6ca9e Mon Sep 17 00:00:00 2001 From: Arthur Dias Date: Thu, 4 Jun 2020 16:28:07 -0300 Subject: [PATCH 4/6] Docs: On maxEOF with eol-last (fixes #12742) Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule. --- docs/rules/no-multiple-empty-lines.md | 41 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index ada47d4d0b6..ca888dbee18 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -41,10 +41,10 @@ var bar = 3; ### maxEOF -Examples of **incorrect** code for this rule with the `{ max: 2, maxEOF: 1 }` options: +Examples of **incorrect** code for this rule with the `{ max: 2, maxEOF: 0 }` options: ```js -/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 1 }]*/ +/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/ var foo = 5; @@ -54,16 +54,43 @@ var bar = 3; ``` -Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 1 }` options: +Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 0 }` options: ```js -/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 1 }]*/ +/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/ var foo = 5; var bar = 3; +``` + +**Note**: Although this ensures zero empty lines at the EOF, most editors will still show one empty line at the end, as illustrated below. There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. A true additional line would be represented by `\n\n`. + +**Incorrect**: + +``` +1 /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/⏎ +2 ⏎ +3 var foo = 5;⏎ +4 ⏎ +5 ⏎ +6 var bar = 3;⏎ +7 ⏎ +8 +``` + +**Correct**: + +``` +1 /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/⏎ +2 ⏎ +3 var foo = 5;⏎ +4 ⏎ +5 ⏎ +6 var bar = 3;⏎ +7 ``` ### maxBOF @@ -93,8 +120,4 @@ var bar = 3; ## When Not To Use It -If you do not care about extra blank lines, turn this off. - -## Using It With The `eol-last` Rule - -If you wish to use this rule with the `eol-last` core rule regarding ending files with a single newline character, `maxEOF` should be set to 0, as an empty line is actually represented by two newline characters (`\n\n`). There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. +If you do not care about extra blank lines, turn this off. \ No newline at end of file From 0d47c93b5439c8ea3176a3df597a14eadee90110 Mon Sep 17 00:00:00 2001 From: Arthur Dias Date: Thu, 4 Jun 2020 16:37:16 -0300 Subject: [PATCH 5/6] Docs: On maxEOF with eol-last (fixes #12742) Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule. --- docs/rules/no-multiple-empty-lines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index ca888dbee18..1d9006b89be 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -120,4 +120,4 @@ var bar = 3; ## When Not To Use It -If you do not care about extra blank lines, turn this off. \ No newline at end of file +If you do not care about extra blank lines, turn this off. From 0e8cf5365c36fb62be11ecf2bf3550dff24087c2 Mon Sep 17 00:00:00 2001 From: Arthur Dias Date: Fri, 5 Jun 2020 13:48:02 -0300 Subject: [PATCH 6/6] Docs: On maxEOF with eol-last (fixes #12742) Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule. --- docs/rules/no-multiple-empty-lines.md | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index 1d9006b89be..836cb18e471 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -10,9 +10,9 @@ This rule aims to reduce the scrolling required when reading through your code. This rule has an object option: -* `"max"` (default: `2`) enforces a maximum number of consecutive empty lines. -* `"maxEOF"` enforces a maximum number of consecutive empty lines at the end of files. -* `"maxBOF"` enforces a maximum number of consecutive empty lines at the beginning of files. +- `"max"` (default: `2`) enforces a maximum number of consecutive empty lines. +- `"maxEOF"` enforces a maximum number of consecutive empty lines at the end of files. +- `"maxBOF"` enforces a maximum number of consecutive empty lines at the beginning of files. ### max @@ -23,8 +23,6 @@ Examples of **incorrect** code for this rule with the default `{ "max": 2 }` opt var foo = 5; - - var bar = 3; ``` @@ -35,7 +33,6 @@ Examples of **correct** code for this rule with the default `{ "max": 2 }` optio var foo = 5; - var bar = 3; ``` @@ -48,10 +45,7 @@ Examples of **incorrect** code for this rule with the `{ max: 2, maxEOF: 0 }` op var foo = 5; - var bar = 3; - - ``` Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 0 }` options: @@ -61,12 +55,10 @@ Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 0 }` opti var foo = 5; - var bar = 3; ``` -**Note**: Although this ensures zero empty lines at the EOF, most editors will still show one empty line at the end, as illustrated below. There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. A true additional line would be represented by `\n\n`. - +**Note**: Although this ensures zero empty lines at the EOF, most editors will still show one empty line at the end if the file ends with a line break, as illustrated below. There is no empty line at the end of a file after the last `\n`, although editors may show an additional line. A true additional line would be represented by `\n\n`. **Incorrect**: @@ -100,10 +92,8 @@ Examples of **incorrect** code for this rule with the `{ max: 2, maxBOF: 1 }` op ```js /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxBOF": 1 }]*/ - var foo = 5; - var bar = 3; ``` @@ -114,7 +104,6 @@ Examples of **correct** code for this rule with the `{ max: 2, maxBOF: 1 }` opti var foo = 5; - var bar = 3; ```