Skip to content

Commit 179929b

Browse files
authored
docs: Remove trailing newline from the code of Playground links (#17641)
* Remove trailing newline from Playground links * Update as per discussion
1 parent f8e5c30 commit 179929b

3 files changed

Lines changed: 17 additions & 29 deletions

File tree

docs/.eleventy.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ module.exports = function(eleventyConfig) {
208208
// See https://github.com/eslint/eslint.org/blob/ac38ab41f99b89a8798d374f74e2cce01171be8b/src/playground/App.js#L44
209209
const parserOptionsJSON = tokens[index].info?.split("correct ")[1]?.trim();
210210
const parserOptions = { sourceType: "module", ...(parserOptionsJSON && JSON.parse(parserOptionsJSON)) };
211-
const { content } = tokens[index + 1];
211+
212+
// Remove trailing newline and presentational `⏎` characters (https://github.com/eslint/eslint/issues/17627):
213+
const content = tokens[index + 1].content
214+
.replace(/\n$/u, "")
215+
.replace(/(?=\n)/gu, "");
212216
const state = encodeToBase64(
213217
JSON.stringify({
214218
options: { parserOptions },

docs/src/rules/eol-last.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Examples of **correct** code for this rule:
4242

4343
function doSomething() {
4444
var foo = 2;
45-
}\n
45+
}
46+
4647
```
4748

4849
:::

docs/src/rules/no-multiple-empty-lines.md

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ Examples of **incorrect** code for this rule with the `{ max: 2, maxEOF: 0 }` op
5959
::: incorrect
6060

6161
```js
62-
/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/
63-
64-
var foo = 5;
65-
66-
67-
var bar = 3;
68-
62+
/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/
63+
64+
var foo = 5;
65+
66+
67+
var bar = 3;
68+
6969

7070
```
7171

@@ -75,36 +75,19 @@ Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 0 }` opti
7575

7676
::: correct
7777

78-
```js
79-
/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/
80-
81-
var foo = 5;
82-
83-
84-
var bar = 3;
85-
```
86-
87-
:::
88-
89-
**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`.
90-
91-
**Incorrect**:
92-
93-
::: incorrect
94-
9578
```js
9679
/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/
9780
9881
var foo = 5;⏎
9982
10083
101-
var bar = 3;⏎
102-
103-
84+
var bar = 3;
10485
```
10586

10687
:::
10788

89+
**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`.
90+
10891
**Correct**:
10992

11093
::: correct

0 commit comments

Comments
 (0)