Skip to content

Commit 4b79612

Browse files
authored
docs: add missing correct/incorrect containers (#16087)
1 parent 09f6acb commit 4b79612

30 files changed

+464
-0
lines changed

docs/src/rules/camelcase.md

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ function UNSAFE_componentWillMount() {
319319

320320
:::
321321

322+
::: correct
323+
322324
```js
323325
/*eslint camelcase: ["error", {allow: ["^UNSAFE_"]}]*/
324326

@@ -331,6 +333,8 @@ function UNSAFE_componentWillMount() {
331333
}
332334
```
333335

336+
:::
337+
334338
## When Not To Use It
335339

336340
If you have established coding standards using a different naming convention (separating words with underscores), turn this rule off.

docs/src/rules/func-name-matching.md

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class C {
3131

3232
:::
3333

34+
::: incorrect
35+
3436
```js
3537
/*eslint func-name-matching: ["error", "never"] */
3638

@@ -46,6 +48,8 @@ class C {
4648
}
4749
```
4850

51+
:::
52+
4953
Examples of **correct** code for this rule:
5054

5155
::: correct
@@ -95,6 +99,8 @@ module['exports'] = function foo(name) {};
9599

96100
:::
97101

102+
::: correct
103+
98104
```js
99105
/*eslint func-name-matching: ["error", "never"] */
100106
/*eslint-env es6*/
@@ -137,6 +143,8 @@ module.exports = function foo(name) {};
137143
module['exports'] = function foo(name) {};
138144
```
139145

146+
:::
147+
140148
## Options
141149

142150
This rule takes an optional string of "always" or "never" (when omitted, it defaults to "always"), and an optional options object with two properties `considerPropertyDescriptor` and `includeCommonJSModuleExports`.

docs/src/rules/key-spacing.md

+4
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ var obj = {
290290

291291
:::
292292

293+
::: correct
294+
293295
```js
294296
/*eslint key-spacing: ["error", {
295297
"align": {
@@ -305,6 +307,8 @@ var obj = {
305307
}
306308
```
307309

310+
:::
311+
308312
### align and multiLine
309313

310314
The `multiLine` and `align` options can differ, which allows for fine-tuned control over the `key-spacing` of your files. `align` will **not** inherit from `multiLine` if `align` is configured as an object.

docs/src/rules/max-lines-per-function.md

+16
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ function foo() {
8787

8888
:::
8989

90+
::: incorrect
91+
9092
```js
9193
/*eslint max-lines-per-function: ["error", 2]*/
9294
function foo() {
@@ -95,6 +97,10 @@ function foo() {
9597
}
9698
```
9799

100+
:::
101+
102+
::: incorrect
103+
98104
```js
99105
/*eslint max-lines-per-function: ["error", 2]*/
100106
function foo() {
@@ -104,6 +110,8 @@ function foo() {
104110
}
105111
```
106112

113+
:::
114+
107115
Examples of **correct** code for this rule with a max value of `3`:
108116

109117
::: correct
@@ -117,6 +125,8 @@ function foo() {
117125

118126
:::
119127

128+
::: correct
129+
120130
```js
121131
/*eslint max-lines-per-function: ["error", 3]*/
122132
function foo() {
@@ -125,6 +135,10 @@ function foo() {
125135
}
126136
```
127137

138+
:::
139+
140+
::: correct
141+
128142
```js
129143
/*eslint max-lines-per-function: ["error", 3]*/
130144
function foo() {
@@ -134,6 +148,8 @@ function foo() {
134148
}
135149
```
136150

151+
:::
152+
137153
### skipBlankLines
138154

139155
Examples of **incorrect** code for this rule with the `{ "skipBlankLines": true }` option:

docs/src/rules/max-lines.md

+16
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,28 @@ var a,
4848

4949
:::
5050

51+
::: incorrect
52+
5153
```js
5254
/*eslint max-lines: ["error", 2]*/
5355

5456
var a,
5557
b,c;
5658
```
5759

60+
:::
61+
62+
::: incorrect
63+
5864
```js
5965
/*eslint max-lines: ["error", 2]*/
6066
// a comment
6167
var a,
6268
b,c;
6369
```
6470

71+
:::
72+
6573
Examples of **correct** code for this rule with a max value of `2`:
6674

6775
::: correct
@@ -74,18 +82,26 @@ var a,
7482

7583
:::
7684

85+
::: correct
86+
7787
```js
7888
/*eslint max-lines: ["error", 2]*/
7989

8090
var a, b, c;
8191
```
8292

93+
:::
94+
95+
::: correct
96+
8397
```js
8498
/*eslint max-lines: ["error", 2]*/
8599
// a comment
86100
var a, b, c;
87101
```
88102

103+
:::
104+
89105
### skipBlankLines
90106

91107
Examples of **incorrect** code for this rule with the `{ "skipBlankLines": true }` option:

docs/src/rules/no-class-assign.md

+20
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ A = 0;
3636

3737
:::
3838

39+
::: incorrect
40+
3941
```js
4042
/*eslint no-class-assign: "error"*/
4143
/*eslint-env es6*/
@@ -44,6 +46,10 @@ A = 0;
4446
class A { }
4547
```
4648

49+
:::
50+
51+
::: incorrect
52+
4753
```js
4854
/*eslint no-class-assign: "error"*/
4955
/*eslint-env es6*/
@@ -55,6 +61,10 @@ class A {
5561
}
5662
```
5763

64+
:::
65+
66+
::: incorrect
67+
5868
```js
5969
/*eslint no-class-assign: "error"*/
6070
/*eslint-env es6*/
@@ -67,6 +77,8 @@ let A = class A {
6777
}
6878
```
6979

80+
:::
81+
7082
Examples of **correct** code for this rule:
7183

7284
::: correct
@@ -81,6 +93,8 @@ A = 0; // A is a variable.
8193

8294
:::
8395

96+
::: correct
97+
8498
```js
8599
/*eslint no-class-assign: "error"*/
86100
/*eslint-env es6*/
@@ -92,6 +106,10 @@ let A = class {
92106
}
93107
```
94108

109+
:::
110+
111+
::: correct
112+
95113
```js
96114
/*eslint no-class-assign: 2*/
97115
/*eslint-env es6*/
@@ -103,6 +121,8 @@ class A {
103121
}
104122
```
105123

124+
:::
125+
106126
## When Not To Use It
107127

108128
If you don't want to be notified about modifying variables of class declarations, you can safely disable this rule.

docs/src/rules/no-compare-neg-zero.md

+4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ if (x === 0) {
3939

4040
:::
4141

42+
::: correct
43+
4244
```js
4345
/* eslint no-compare-neg-zero: "error" */
4446

4547
if (Object.is(x, -0)) {
4648
// doSomething()...
4749
}
4850
```
51+
52+
:::

docs/src/rules/no-const-assign.md

+16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ a = 1;
3030

3131
:::
3232

33+
::: incorrect
34+
3335
```js
3436
/*eslint no-const-assign: "error"*/
3537
/*eslint-env es6*/
@@ -38,6 +40,10 @@ const a = 0;
3840
a += 1;
3941
```
4042

43+
:::
44+
45+
::: incorrect
46+
4147
```js
4248
/*eslint no-const-assign: "error"*/
4349
/*eslint-env es6*/
@@ -46,6 +52,8 @@ const a = 0;
4652
++a;
4753
```
4854

55+
:::
56+
4957
Examples of **correct** code for this rule:
5058

5159
::: correct
@@ -60,6 +68,8 @@ console.log(a);
6068

6169
:::
6270

71+
::: correct
72+
6373
```js
6474
/*eslint no-const-assign: "error"*/
6575
/*eslint-env es6*/
@@ -69,6 +79,10 @@ for (const a in [1, 2, 3]) { // `a` is re-defined (not modified) on each loop st
6979
}
7080
```
7181

82+
:::
83+
84+
::: correct
85+
7286
```js
7387
/*eslint no-const-assign: "error"*/
7488
/*eslint-env es6*/
@@ -78,6 +92,8 @@ for (const a of [1, 2, 3]) { // `a` is re-defined (not modified) on each loop st
7892
}
7993
```
8094

95+
:::
96+
8197
## When Not To Use It
8298

8399
If you don't want to be notified about modifying variables that are declared using `const` keyword, you can safely disable this rule.

docs/src/rules/no-continue.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ for(i = 0; i < 10; i++) {
4646

4747
:::
4848

49+
::: incorrect
50+
4951
```js
5052
/*eslint no-continue: "error"*/
5153

@@ -61,6 +63,8 @@ labeledLoop: for(i = 0; i < 10; i++) {
6163
}
6264
```
6365

66+
:::
67+
6468
Examples of **correct** code for this rule:
6569

6670
::: correct

docs/src/rules/no-eval.md

+8
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,28 @@ this.eval("var a = 0");
146146

147147
:::
148148

149+
::: correct
150+
149151
```js
150152
/*eslint no-eval: "error"*/
151153
/*eslint-env browser*/
152154

153155
window.eval("var a = 0");
154156
```
155157

158+
:::
159+
160+
::: correct
161+
156162
```js
157163
/*eslint no-eval: "error"*/
158164
/*eslint-env node*/
159165

160166
global.eval("var a = 0");
161167
```
162168

169+
:::
170+
163171
## Known Limitations
164172

165173
* This rule is warning every `eval()` even if the `eval` is not global's.

docs/src/rules/no-extra-strict.md

+4
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ Examples of **correct** code for this rule:
5555

5656
:::
5757

58+
::: correct
59+
5860
```js
5961
(function () {
6062
"use strict";
6163
var foo = true;
6264
}());
6365
```
66+
67+
:::

0 commit comments

Comments
 (0)