Skip to content

Commit b4fea2a

Browse files
committed
doc: add eslint-plugin-markdown
* install eslint-plugin-markdown * add doc/.eslintrc.yaml * add `<!-- eslint-disable rule -->` or `<!-- eslint-disable -->` for the rest of problematic code * .js files in doc folder added to .eslintignore * update Makefile and vcbuild.bat 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 e2c3e47 commit b4fea2a

File tree

219 files changed

+34509
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+34509
-33
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ test/tmp*/
77
tools/eslint
88
node_modules
99
benchmark/tmp/
10+
doc/**/*.js

.eslintrc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
root: true
22

3+
plugins:
4+
- markdown
5+
36
env:
47
node: true
58
es6: true

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,8 @@ bench-ci: bench
855855

856856
jslint:
857857
@echo "Running JS linter..."
858-
$(NODE) tools/eslint/bin/eslint.js --cache --rulesdir=tools/eslint-rules \
859-
benchmark lib test tools
858+
$(NODE) tools/eslint/bin/eslint.js --cache --rulesdir=tools/eslint-rules --ext=.js,.md \
859+
benchmark doc lib test tools
860860

861861
jslint-ci:
862862
@echo "Running JS linter..."

doc/.eslintrc.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rules:
2+
strict: 0
3+
no-restricted-properties: 0
4+
no-undef: 0
5+
no-unused-vars: 0

doc/api/assert.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ Note that `error` can not be a string. If a string is provided as the second
554554
argument, then `error` is assumed to be omitted and the string will be used for
555555
`message` instead. This can lead to easy-to-miss mistakes:
556556

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

doc/api/cluster.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,11 @@ When any of the workers die the cluster module will emit the `'exit'` event.
523523
This can be used to restart the worker by calling `.fork()` again.
524524

525525
```js
526-
cluster.on(
527-
'exit',
528-
(worker, code, signal) => {
529-
console.log('worker %d died (%s). restarting...',
530-
worker.process.pid, signal || code);
531-
cluster.fork();
532-
}
533-
);
526+
cluster.on('exit', (worker, code, signal) => {
527+
console.log('worker %d died (%s). restarting...',
528+
worker.process.pid, signal || code);
529+
cluster.fork();
530+
});
534531
```
535532

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

doc/api/console.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ by extending Node.js' `console` and overriding the `console.assert()` method.
135135
In the following example, a simple module is created that extends and overrides
136136
the default behavior of `console` in Node.js.
137137

138+
<!-- eslint-disable func-name-matching -->
138139
```js
139140
'use strict';
140141

141142
// Creates a simple extension of console with a
142143
// new impl for assert without monkey-patching.
143144
const myConsole = Object.create(console, {
144145
assert: {
145-
value(assertion, message, ...args) {
146+
value: function assert(assertion, message, ...args) {
146147
try {
147148
console.assert(assertion, message, ...args);
148149
} catch (err) {
@@ -276,7 +277,7 @@ prints the result to `stdout`:
276277

277278
```js
278279
console.time('100-elements');
279-
for (let i = 0; i < 100; i++) ;
280+
for (let i = 0; i < 100; i++) {}
280281
console.timeEnd('100-elements');
281282
// prints 100-elements: 225.438ms
282283
```

doc/api/crypto.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ decipher.on('end', () => {
289289
});
290290

291291
const encrypted =
292-
'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
292+
'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
293293
decipher.write(encrypted, 'hex');
294294
decipher.end();
295295
```
@@ -314,7 +314,7 @@ const crypto = require('crypto');
314314
const decipher = crypto.createDecipher('aes192', 'a password');
315315

316316
const encrypted =
317-
'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
317+
'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504';
318318
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
319319
decrypted += decipher.final('utf8');
320320
console.log(decrypted);

doc/api/debugger.md

Lines changed: 1 addition & 0 deletions
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/dns.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ function will contain an array of objects with the following properties:
293293

294294
For example:
295295

296+
<!-- eslint-disable -->
296297
```js
297298
{
298299
flags: 's',
@@ -352,6 +353,7 @@ be an object with the following properties:
352353
* `expire`
353354
* `minttl`
354355

356+
<!-- eslint-disable -->
355357
```js
356358
{
357359
nsname: 'ns.example.com',
@@ -382,6 +384,7 @@ be an array of objects with the following properties:
382384
* `port`
383385
* `name`
384386

387+
<!-- eslint-disable -->
385388
```js
386389
{
387390
priority: 10,

0 commit comments

Comments
 (0)