Skip to content

Commit 8c0849d

Browse files
vsemozhetbytMylesBorins
authored andcommitted
doc: conform to rules for eslint-plugin-markdown
Backport-PR-URL: #14067 PR-URL: #12563 Refs: #12557 (comment) Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent 7deb259 commit 8c0849d

32 files changed

+311
-267
lines changed

benchmark/README.md

+22-17
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,43 @@ constructor iterates through the configuration object property values and runs
3434
the test function with each of the combined arguments in spawned processes. For
3535
example, buffers/buffer-read.js has the following configuration:
3636

37+
<!-- eslint-disable strict, no-undef, no-unused-vars -->
3738
```js
3839
var bench = common.createBenchmark(main, {
3940
noAssert: [false, true],
4041
buffer: ['fast', 'slow'],
4142
type: ['UInt8', 'UInt16LE', 'UInt16BE',
42-
'UInt32LE', 'UInt32BE',
43-
'Int8', 'Int16LE', 'Int16BE',
44-
'Int32LE', 'Int32BE',
45-
'FloatLE', 'FloatBE',
46-
'DoubleLE', 'DoubleBE'],
47-
millions: [1]
43+
'UInt32LE', 'UInt32BE',
44+
'Int8', 'Int16LE', 'Int16BE',
45+
'Int32LE', 'Int32BE',
46+
'FloatLE', 'FloatBE',
47+
'DoubleLE', 'DoubleBE'],
48+
millions: [1]
4849
});
4950
```
5051
The runner takes one item from each of the property array value to build a list
5152
of arguments to run the main function. The main function will receive the conf
5253
object as follows:
5354

5455
- first run:
56+
57+
<!-- eslint-skip -->
5558
```js
56-
{ noAssert: false,
57-
buffer: 'fast',
58-
type: 'UInt8',
59-
millions: 1
60-
}
59+
{ noAssert: false,
60+
buffer: 'fast',
61+
type: 'UInt8',
62+
millions: 1
63+
}
6164
```
6265
- second run:
66+
67+
<!-- eslint-skip -->
6368
```js
64-
{
65-
noAssert: false,
66-
buffer: 'fast',
67-
type: 'UInt16LE',
68-
millions: 1
69-
}
69+
{ noAssert: false,
70+
buffer: 'fast',
71+
type: 'UInt16LE',
72+
millions: 1
73+
}
7074
```
7175
...
7276

@@ -122,6 +126,7 @@ buffers/buffer-slice.js.
122126

123127
### The code snippet
124128

129+
<!-- eslint-disable strict, no-undef, no-unused-vars -->
125130
```js
126131
var common = require('../common.js'); // Load the test runner
127132

doc/api/assert.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ are evaluated also:
4343
const assert = require('assert');
4444

4545
const obj1 = {
46-
a : {
47-
b : 1
46+
a: {
47+
b: 1
4848
}
4949
};
5050
const obj2 = {
51-
a : {
52-
b : 2
51+
a: {
52+
b: 2
5353
}
5454
};
5555
const obj3 = {
56-
a : {
57-
b : 1
56+
a: {
57+
b: 1
5858
}
5959
};
6060
const obj4 = Object.create(obj1);
@@ -93,10 +93,10 @@ Second, object comparisons include a strict equality check of their prototypes.
9393
```js
9494
const assert = require('assert');
9595

96-
assert.deepEqual({a:1}, {a:'1'});
96+
assert.deepEqual({ a: 1 }, { a: '1' });
9797
// OK, because 1 == '1'
9898

99-
assert.deepStrictEqual({a:1}, {a:'1'});
99+
assert.deepStrictEqual({ a: 1 }, { a: '1' });
100100
// AssertionError: { a: 1 } deepStrictEqual { a: '1' }
101101
// because 1 !== '1' using strict equality
102102
```
@@ -251,18 +251,18 @@ Tests for any deep inequality. Opposite of [`assert.deepEqual()`][].
251251
const assert = require('assert');
252252

253253
const obj1 = {
254-
a : {
255-
b : 1
254+
a: {
255+
b: 1
256256
}
257257
};
258258
const obj2 = {
259-
a : {
260-
b : 2
259+
a: {
260+
b: 2
261261
}
262262
};
263263
const obj3 = {
264-
a : {
265-
b : 1
264+
a: {
265+
b: 1
266266
}
267267
};
268268
const obj4 = Object.create(obj1);
@@ -297,10 +297,10 @@ Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][].
297297
```js
298298
const assert = require('assert');
299299

300-
assert.notDeepEqual({a:1}, {a:'1'});
300+
assert.notDeepEqual({a: 1}, {a: '1'});
301301
// AssertionError: { a: 1 } notDeepEqual { a: '1' }
302302

303-
assert.notDeepStrictEqual({a:1}, {a:'1'});
303+
assert.notDeepStrictEqual({a: 1}, {a: '1'});
304304
// OK
305305
```
306306

@@ -466,7 +466,7 @@ assert.throws(
466466
throw new Error('Wrong value');
467467
},
468468
function(err) {
469-
if ( (err instanceof Error) && /value/.test(err) ) {
469+
if ((err instanceof Error) && /value/.test(err)) {
470470
return true;
471471
}
472472
},
@@ -478,6 +478,7 @@ Note that `error` can not be a string. If a string is provided as the second
478478
argument, then `error` is assumed to be omitted and the string will be used for
479479
`message` instead. This can lead to easy-to-miss mistakes:
480480

481+
<!-- eslint-disable assert-throws-arguments -->
481482
```js
482483
// THIS IS A MISTAKE! DO NOT DO THIS!
483484
assert.throws(myFunction, 'missing foo', 'did not throw with expected message');

doc/api/buffer.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ Example: Copy an ASCII string into a `Buffer`, one byte at a time
886886
const str = 'Node.js';
887887
const buf = Buffer.allocUnsafe(str.length);
888888

889-
for (let i = 0; i < str.length ; i++) {
889+
for (let i = 0; i < str.length; i++) {
890890
buf[i] = str.charCodeAt(i);
891891
}
892892

@@ -994,7 +994,7 @@ byte 16 through byte 19 into `buf2`, starting at the 8th byte in `buf2`
994994
const buf1 = Buffer.allocUnsafe(26);
995995
const buf2 = Buffer.allocUnsafe(26).fill('!');
996996

997-
for (let i = 0 ; i < 26 ; i++) {
997+
for (let i = 0; i < 26; i++) {
998998
// 97 is the decimal ASCII value for 'a'
999999
buf1[i] = i + 97;
10001000
}
@@ -1011,7 +1011,7 @@ overlapping region within the same `Buffer`
10111011
```js
10121012
const buf = Buffer.allocUnsafe(26);
10131013

1014-
for (let i = 0 ; i < 26 ; i++) {
1014+
for (let i = 0; i < 26; i++) {
10151015
// 97 is the decimal ASCII value for 'a'
10161016
buf[i] = i + 97;
10171017
}
@@ -1781,7 +1781,7 @@ one byte from the original `Buffer`
17811781
```js
17821782
const buf1 = Buffer.allocUnsafe(26);
17831783

1784-
for (let i = 0 ; i < 26 ; i++) {
1784+
for (let i = 0; i < 26; i++) {
17851785
// 97 is the decimal ASCII value for 'a'
17861786
buf1[i] = i + 97;
17871787
}
@@ -1930,7 +1930,7 @@ Examples:
19301930
```js
19311931
const buf1 = Buffer.allocUnsafe(26);
19321932

1933-
for (let i = 0 ; i < 26 ; i++) {
1933+
for (let i = 0; i < 26; i++) {
19341934
// 97 is the decimal ASCII value for 'a'
19351935
buf1[i] = i + 97;
19361936
}
@@ -1974,9 +1974,9 @@ const json = JSON.stringify(buf);
19741974
console.log(json);
19751975

19761976
const copy = JSON.parse(json, (key, value) => {
1977-
return value && value.type === 'Buffer'
1978-
? Buffer.from(value.data)
1979-
: value;
1977+
return value && value.type === 'Buffer' ?
1978+
Buffer.from(value.data) :
1979+
value;
19801980
});
19811981

19821982
// Prints: <Buffer 01 02 03 04 05>

doc/api/child_process.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ the process is spawned. The default options are:
188188
const defaults = {
189189
encoding: 'utf8',
190190
timeout: 0,
191-
maxBuffer: 200*1024,
191+
maxBuffer: 200 * 1024,
192192
killSignal: 'SIGTERM',
193193
cwd: null,
194194
env: null
@@ -868,13 +868,17 @@ as in this example:
868868
'use strict';
869869
const spawn = require('child_process').spawn;
870870

871-
const child = spawn('sh', ['-c',
872-
`node -e "setInterval(() => {
871+
const child = spawn(
872+
'sh',
873+
[
874+
'-c',
875+
`node -e "setInterval(() => {
873876
console.log(process.pid, 'is alive')
874877
}, 500);"`
875878
], {
876879
stdio: ['inherit', 'inherit', 'inherit']
877-
});
880+
}
881+
);
878882

879883
setTimeout(() => {
880884
child.kill(); // does not terminate the node process in the shell

doc/api/cluster.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,14 @@ When any of the workers die the cluster module will emit the `'exit'` event.
511511
This can be used to restart the worker by calling `.fork()` again.
512512

513513
```js
514-
cluster.on('exit', (worker, code, signal) => {
515-
console.log('worker %d died (%s). restarting...',
516-
worker.process.pid, signal || code);
517-
cluster.fork();
518-
});
514+
cluster.on(
515+
'exit',
516+
(worker, code, signal) => {
517+
console.log('worker %d died (%s). restarting...',
518+
worker.process.pid, signal || code);
519+
cluster.fork();
520+
}
521+
);
519522
```
520523

521524
See [child_process event: 'exit'][].

doc/api/console.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ the default behavior of `console` in Node.js.
130130
// new impl for assert without monkey-patching.
131131
const myConsole = Object.create(console, {
132132
assert: {
133-
value: function assert(assertion, message, ...args) {
133+
value(assertion, message, ...args) {
134134
try {
135135
console.assert(assertion, message, ...args);
136136
} catch (err) {
@@ -253,9 +253,7 @@ prints the result to `stdout`:
253253

254254
```js
255255
console.time('100-elements');
256-
for (let i = 0; i < 100; i++) {
257-
;
258-
}
256+
for (let i = 0; i < 100; i++) ;
259257
console.timeEnd('100-elements');
260258
// prints 100-elements: 225.438ms
261259
```

doc/api/crypto.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ decipher.on('end', () => {
280280
// Prints: some clear text data
281281
});
282282

283-
const encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
283+
const encrypted =
284+
'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
284285
decipher.write(encrypted, 'hex');
285286
decipher.end();
286287
```
@@ -304,7 +305,8 @@ Example: Using the [`decipher.update()`][] and [`decipher.final()`][] methods:
304305
const crypto = require('crypto');
305306
const decipher = crypto.createDecipher('aes192', 'a password');
306307

307-
const encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
308+
const encrypted =
309+
'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
308310
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
309311
decrypted += decipher.final('utf8');
310312
console.log(decrypted);

doc/api/debugger.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ inspection are possible.
2626
Inserting the statement `debugger;` into the source code of a script will
2727
enable a breakpoint at that position in the code:
2828

29+
<!-- eslint-disable no-debugger -->
2930
```js
3031
// myscript.js
3132
global.x = 5;

doc/api/dgram.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ server.on('message', (msg, rinfo) => {
2020
});
2121

2222
server.on('listening', () => {
23-
var address = server.address();
23+
const address = server.address();
2424
console.log(`server listening ${address.address}:${address.port}`);
2525
});
2626

@@ -146,7 +146,7 @@ server.on('message', (msg, rinfo) => {
146146
});
147147

148148
server.on('listening', () => {
149-
var address = server.address();
149+
const address = server.address();
150150
console.log(`server listening ${address.address}:${address.port}`);
151151
});
152152

doc/api/dns.md

+3
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ will contain an array of objects with the following properties:
268268

269269
For example:
270270

271+
<!-- eslint-skip -->
271272
```js
272273
{
273274
flags: 's',
@@ -306,6 +307,7 @@ be an object with the following properties:
306307
* `expire`
307308
* `minttl`
308309

310+
<!-- eslint-skip -->
309311
```js
310312
{
311313
nsname: 'ns.example.com',
@@ -332,6 +334,7 @@ be an array of objects with the following properties:
332334
* `port`
333335
* `name`
334336

337+
<!-- eslint-skip -->
335338
```js
336339
{
337340
priority: 10,

doc/api/domain.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function handleRequest(req, res) {
162162
setTimeout(() => {
163163
// Whoops!
164164
flerb.bark();
165-
});
165+
}, timeout);
166166
break;
167167
default:
168168
res.end('ok');

doc/api/fs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ synchronous counterparts are of this type.
218218
For a regular file [`util.inspect(stats)`][] would return a string very
219219
similar to this:
220220

221-
```txt
221+
```
222222
Stats {
223223
dev: 2114,
224224
ino: 48064969,

0 commit comments

Comments
 (0)