Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite1e305d

Browse files
authored
docs: fixlinebreak-style examples (#18262)
fix `linebreak-style` examples
1 parent113f51e commite1e305d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

‎docs/src/rules/linebreak-style.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var a = 'a', // \n
5252
functionfoo(params) {// \n
5353
// do stuff \n
5454
}// \n
55+
5556
```
5657

5758
:::
@@ -66,6 +67,7 @@ Examples of **incorrect** code for this rule with the `"windows"` option:
6667
/*eslint linebreak-style: ["error", "windows"]*/
6768

6869
var a='a';// \n
70+
6971
```
7072

7173
:::
@@ -75,14 +77,15 @@ Examples of **correct** code for this rule with the `"windows"` option:
7577
::: correct
7678

7779
```js
78-
/*eslint linebreak-style: ["error", "windows"]*/
79-
80+
/*eslint linebreak-style: ["error", "windows"]*/// \r\n
81+
// \r\n
8082
var a='a',// \r\n
8183
b='b';// \r\n
8284
// \r\n
8385
functionfoo(params) {// \r\n
8486
// do stuff \r\n
8587
}// \r\n
88+
8689
```
8790

8891
:::

‎docs/tools/code-block-utils.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
functiondocsExampleCodeToParsableCode(code){
1515
returncode
1616

17-
//Remove trailing newline and presentational `⏎` characters
18-
.replace(/(?=\n)/gu,"")
17+
//Code blocks always contain an extra line break at the end, so remove it.
18+
.replace(/\n$/u,"")
1919

20-
// Code blocks always contain extra line breaks, so remove them.
21-
.replace(/\n$/u,"");
20+
// Replace LF line breaks with CRLF after `\r\n` sequences.
21+
.replace(/(?<=\\r\\n)\n/gu,"\r\n")
22+
23+
// Remove presentational `⏎` characters at the end of lines.
24+
.replace(/(?=\n)/gu,"");
2225
}
2326

2427
module.exports={

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp