Skip to content

Commit 8651895

Browse files
authored
docs: Fix tabs in rule examples (#17653)
* Different ways to handle tabs * Option to remove Playground links * use tabs with `markdownlint-disable` comments * add missing `eslint` comments * Apply review suggestions * Remove comments from `no-mixed-spaces-and-tabs`
1 parent 3aec1c5 commit 8651895

File tree

5 files changed

+57
-34
lines changed

5 files changed

+57
-34
lines changed

docs/src/rules/indent-legacy.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,23 @@ function foo(d) {
140140

141141
Examples of **correct** code for this rule with the `"tab"` option:
142142

143+
<!-- markdownlint-capture -->
144+
<!-- markdownlint-disable MD010 -->
143145
::: correct
144146

145147
```js
146148
/*eslint indent-legacy: ["error", "tab"]*/
147149

148150
if (a) {
149-
/*tab*/b=c;
150-
/*tab*/function foo(d) {
151-
/*tab*//*tab*/e=f;
152-
/*tab*/}
151+
b=c;
152+
function foo(d) {
153+
e=f;
154+
}
153155
}
154156
```
155157

156158
:::
159+
<!-- markdownlint-restore -->
157160

158161
### SwitchCase
159162

docs/src/rules/indent.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,23 @@ function foo(d) {
141141

142142
Examples of **correct** code for this rule with the `"tab"` option:
143143

144+
<!-- markdownlint-capture -->
145+
<!-- markdownlint-disable MD010 -->
144146
::: correct
145147

146148
```js
147149
/*eslint indent: ["error", "tab"]*/
148150

149151
if (a) {
150-
/*tab*/b=c;
151-
/*tab*/function foo(d) {
152-
/*tab*//*tab*/e=f;
153-
/*tab*/}
152+
b=c;
153+
function foo(d) {
154+
e=f;
155+
}
154156
}
155157
```
156158

157159
:::
160+
<!-- markdownlint-restore -->
158161

159162
### ignoredNodes
160163

docs/src/rules/max-len.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,36 @@ var foo = {
6969

7070
Examples of **incorrect** code for this rule with the default `{ "tabWidth": 4 }` option:
7171

72+
<!-- markdownlint-capture -->
73+
<!-- markdownlint-disable MD010 -->
7274
::: incorrect
7375

7476
```js
7577
/*eslint max-len: ["error", { "code": 80, "tabWidth": 4 }]*/
7678

77-
\t \t var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };
79+
var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };
7880
```
7981

8082
:::
83+
<!-- markdownlint-restore -->
8184

8285
Examples of **correct** code for this rule with the default `{ "tabWidth": 4 }` option:
8386

87+
<!-- markdownlint-capture -->
88+
<!-- markdownlint-disable MD010 -->
8489
::: correct
8590

8691
```js
8792
/*eslint max-len: ["error", { "code": 80, "tabWidth": 4 }]*/
8893

89-
\t \t var foo = {
90-
\t \t \t \t "bar": "This is a bar.",
91-
\t \t \t \t "baz": { "qux": "This is a qux" }
92-
\t \t };
94+
var foo = {
95+
"bar": "This is a bar.",
96+
"baz": { "qux": "This is a qux" }
97+
};
9398
```
9499

95100
:::
101+
<!-- markdownlint-restore -->
96102

97103
### comments
98104

@@ -203,7 +209,8 @@ Examples of **correct** code for this rule with the `ignorePattern` option:
203209
::: correct
204210

205211
```js
206-
/*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(" }]*/
212+
/*eslint max-len:
213+
["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(" }]*/
207214

208215
var dep = require('really/really/really/really/really/really/really/really/long/module');
209216
```

docs/src/rules/no-mixed-spaces-and-tabs.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,42 @@ This rule disallows mixed spaces and tabs for indentation.
1515

1616
Examples of **incorrect** code for this rule:
1717

18+
<!-- markdownlint-capture -->
19+
<!-- markdownlint-disable MD010 -->
1820
::: incorrect
1921

2022
```js
2123
/*eslint no-mixed-spaces-and-tabs: "error"*/
2224

2325
function add(x, y) {
24-
// --->..return x + y;
25-
26-
return x + y;
26+
return x + y;
2727
}
2828

2929
function main() {
30-
// --->var x = 5,
31-
// --->....y = 7;
32-
33-
var x = 5,
34-
y = 7;
30+
var x = 5,
31+
y = 7;
3532
}
3633
```
3734

3835
:::
36+
<!-- markdownlint-restore -->
3937

4038
Examples of **correct** code for this rule:
4139

40+
<!-- markdownlint-capture -->
41+
<!-- markdownlint-disable MD010 -->
4242
::: correct
4343

4444
```js
4545
/*eslint no-mixed-spaces-and-tabs: "error"*/
4646

4747
function add(x, y) {
48-
// --->return x + y;
49-
return x + y;
48+
return x + y;
5049
}
5150
```
5251

5352
:::
53+
<!-- markdownlint-restore -->
5454

5555
## Options
5656

@@ -62,18 +62,18 @@ This rule has a string option.
6262

6363
Examples of **correct** code for this rule with the `"smart-tabs"` option:
6464

65+
<!-- markdownlint-capture -->
66+
<!-- markdownlint-disable MD010 -->
6567
::: correct
6668

6769
```js
6870
/*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
6971

7072
function main() {
71-
// --->var x = 5,
72-
// --->....y = 7;
73-
74-
var x = 5,
75-
y = 7;
73+
var x = 5,
74+
y = 7;
7675
}
7776
```
7877

7978
:::
79+
<!-- markdownlint-restore -->

docs/src/rules/no-tabs.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,33 @@ This rule looks for tabs anywhere inside a file: code, comments or anything else
1212

1313
Examples of **incorrect** code for this rule:
1414

15+
<!-- markdownlint-capture -->
16+
<!-- markdownlint-disable MD010 -->
1517
::: incorrect
1618

1719
```js
18-
var a \t= 2;
20+
/* eslint no-tabs: "error" */
21+
22+
var a = 2;
1923

2024
/**
21-
* \t\t it's a test function
25+
* it's a test function
2226
*/
2327
function test(){}
2428

25-
var x = 1; // \t test
29+
var x = 1; // test
2630
```
2731

2832
:::
33+
<!-- markdownlint-restore -->
2934

3035
Examples of **correct** code for this rule:
3136

3237
::: correct
3338

3439
```js
40+
/* eslint no-tabs: "error" */
41+
3542
var a = 2;
3643

3744
/**
@@ -54,19 +61,22 @@ This rule has an optional object option with the following properties:
5461

5562
Examples of **correct** code for this rule with the `allowIndentationTabs: true` option:
5663

64+
<!-- markdownlint-capture -->
65+
<!-- markdownlint-disable MD010 -->
5766
::: correct
5867

5968
```js
6069
/* eslint no-tabs: ["error", { allowIndentationTabs: true }] */
6170

6271
function test() {
63-
\tdoSomething();
72+
doSomething();
6473
}
6574

66-
\t// comment with leading indentation tab
75+
// comment with leading indentation tab
6776
```
6877

6978
:::
79+
<!-- markdownlint-restore -->
7080

7181
## When Not To Use It
7282

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy