Skip to content

Commit

Permalink
docs: Remove trailing newline from the code of Playground links (#17641)
Browse files Browse the repository at this point in the history
* Remove trailing newline from Playground links

* Update as per discussion
  • Loading branch information
fasttime committed Oct 13, 2023
1 parent f8e5c30 commit 179929b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
6 changes: 5 additions & 1 deletion docs/.eleventy.js
Expand Up @@ -208,7 +208,11 @@ module.exports = function(eleventyConfig) {
// See https://github.com/eslint/eslint.org/blob/ac38ab41f99b89a8798d374f74e2cce01171be8b/src/playground/App.js#L44
const parserOptionsJSON = tokens[index].info?.split("correct ")[1]?.trim();
const parserOptions = { sourceType: "module", ...(parserOptionsJSON && JSON.parse(parserOptionsJSON)) };
const { content } = tokens[index + 1];

// Remove trailing newline and presentational `⏎` characters (https://github.com/eslint/eslint/issues/17627):
const content = tokens[index + 1].content
.replace(/\n$/u, "")
.replace(/⏎(?=\n)/gu, "");
const state = encodeToBase64(
JSON.stringify({
options: { parserOptions },
Expand Down
3 changes: 2 additions & 1 deletion docs/src/rules/eol-last.md
Expand Up @@ -42,7 +42,8 @@ Examples of **correct** code for this rule:

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

```

:::
Expand Down
37 changes: 10 additions & 27 deletions docs/src/rules/no-multiple-empty-lines.md
Expand Up @@ -59,13 +59,13 @@ Examples of **incorrect** code for this rule with the `{ max: 2, maxEOF: 0 }` op
::: incorrect

```js
/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/

var foo = 5;


var bar = 3;

/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/
var foo = 5;
var bar = 3;

```

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

::: correct

```js
/*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 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**:

::: incorrect

```js
/*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/
var foo = 5;⏎
var bar = 3;⏎

var bar = 3;
```

:::

**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`.

**Correct**:

::: correct
Expand Down

0 comments on commit 179929b

Please sign in to comment.