Skip to content

Commit 2c11d6e

Browse files
tools: lint js in doc/**/*.md
PR-URL: nodejs#55904 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent f4cd4d9 commit 2c11d6e

19 files changed

+31
-34
lines changed

doc/api/errors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Errors that occur within _Asynchronous APIs_ may be reported in multiple ways:
6161
<!-- eslint-disable no-useless-return -->
6262

6363
```js
64-
const fs = require('fs/promises');
64+
const fs = require('node:fs/promises');
6565

6666
(async () => {
6767
let data;

doc/api/esm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ module default import or its corresponding sugar syntax:
511511
512512
```js
513513
import { default as cjs } from 'cjs';
514-
// identical to the above
514+
// Identical to the above
515515
import cjsSugar from 'cjs';
516516

517517
console.log(cjs);

doc/api/inspector.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ inspector.Network.requestWillBeSent({
505505
request: {
506506
url: 'https://nodejs.org/en',
507507
method: 'GET',
508-
}
508+
},
509509
});
510510
```
511511

doc/api/modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ built-in modules and if a name matching a built-in module is added to the cache,
890890
only `node:`-prefixed require calls are going to receive the built-in module.
891891
Use with care!
892892

893-
<!-- eslint-disable node-core/no-duplicate-requires -->
893+
<!-- eslint-disable node-core/no-duplicate-requires, no-restricted-syntax -->
894894

895895
```js
896896
const assert = require('node:assert');

doc/api/perf_hooks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ performance.measure('Start to Now');
2828

2929
performance.mark('A');
3030
(async function doSomeLongRunningProcess() {
31-
await new Promise(r => setTimeout(r, 5000));
31+
await new Promise((r) => setTimeout(r, 5000));
3232
performance.measure('A to Now', 'A');
3333

3434
performance.mark('B');

doc/api/process.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2111,10 +2111,10 @@ class Test {
21112111
constructor() {
21122112
finalization.register(this, (ref) => ref.dispose());
21132113

2114-
// even something like this is highly discouraged
2114+
// Even something like this is highly discouraged
21152115
// finalization.register(this, () => this.dispose());
2116-
}
2117-
dispose() {}
2116+
}
2117+
dispose() {}
21182118
}
21192119
```
21202120

doc/api/punycode.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The `punycode` module is a bundled version of the [Punycode.js][] module. It
2121
can be accessed using:
2222

2323
```js
24-
const punycode = require('punycode');
24+
const punycode = require('node:punycode');
2525
```
2626

2727
[Punycode][] is a character encoding scheme defined by RFC 3492 that is

doc/api/stream.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ events (due to incorrect stream implementations) do not cause unexpected
315315
crashes. If this is unwanted behavior then `options.cleanup` should be set to
316316
`true`:
317317

318-
```js
318+
```mjs
319319
await finished(rs, { cleanup: true });
320320
```
321321

@@ -3926,7 +3926,7 @@ const { StringDecoder } = require('node:string_decoder');
39263926
class StringWritable extends Writable {
39273927
constructor(options) {
39283928
super(options);
3929-
this._decoder = new StringDecoder(options && options.defaultEncoding);
3929+
this._decoder = new StringDecoder(options?.defaultEncoding);
39303930
this.data = '';
39313931
}
39323932
_write(chunk, encoding, callback) {

doc/api/test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3283,7 +3283,7 @@ test('snapshot test with default serialization', (t) => {
32833283

32843284
test('snapshot test with custom serialization', (t) => {
32853285
t.assert.snapshot({ value3: 3, value4: 4 }, {
3286-
serializers: [(value) => JSON.stringify(value)]
3286+
serializers: [(value) => JSON.stringify(value)],
32873287
});
32883288
});
32893289
```

doc/api/tls.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,13 @@ to set the security level to 0 while using the default OpenSSL cipher list, you
465465
const tls = require('node:tls');
466466
const port = 443;
467467

468-
tls.createServer({ciphers: 'DEFAULT@SECLEVEL=0', minVersion: 'TLSv1'}, function (socket) {
468+
tls.createServer({ ciphers: 'DEFAULT@SECLEVEL=0', minVersion: 'TLSv1' }, function(socket) {
469469
console.log('Client connected with protocol:', socket.getProtocol());
470470
socket.end();
471471
this.close();
472-
}).
473-
listen(port, () => {
474-
tls.connect(port, {ciphers: 'DEFAULT@SECLEVEL=0', maxVersion: 'TLSv1'});
472+
})
473+
.listen(port, () => {
474+
tls.connect(port, { ciphers: 'DEFAULT@SECLEVEL=0', maxVersion: 'TLSv1' });
475475
});
476476
```
477477

doc/api/tracing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ console.log(trace_events.getEnabledCategories());
245245
```js
246246
'use strict';
247247

248-
const { Session } = require('inspector');
248+
const { Session } = require('node:inspector');
249249
const session = new Session();
250250
session.connect();
251251

doc/api/util.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ The mapping between error codes and string messages is platform-dependent.
513513
```js
514514
fs.access('file/that/does/not/exist', (err) => {
515515
const name = util.getSystemErrorMessage(err.errno);
516-
console.error(name); // no such file or directory
516+
console.error(name); // No such file or directory
517517
});
518518
```
519519

doc/api/v8.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ is as follows.
12961296
Here's an example.
12971297

12981298
```js
1299-
const { GCProfiler } = require('v8');
1299+
const { GCProfiler } = require('node:v8');
13001300
const profiler = new GCProfiler();
13011301
profiler.start();
13021302
setTimeout(() => {

doc/api/vm.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1622,12 +1622,12 @@ in the outer context.
16221622
const vm = require('node:vm');
16231623
16241624
// An undefined `contextObject` option makes the global object contextified.
1625-
let context = vm.createContext();
1625+
const context = vm.createContext();
16261626
console.log(vm.runInContext('globalThis', context) === context); // false
16271627
// A contextified global object cannot be frozen.
16281628
try {
16291629
vm.runInContext('Object.freeze(globalThis);', context);
1630-
} catch(e) {
1630+
} catch (e) {
16311631
console.log(e); // TypeError: Cannot freeze
16321632
}
16331633
console.log(vm.runInContext('globalThis.foo = 1; foo;', context)); // 1
@@ -1652,7 +1652,7 @@ const context = vm.createContext(vm.constants.DONT_CONTEXTIFY);
16521652
vm.runInContext('Object.freeze(globalThis);', context);
16531653
try {
16541654
vm.runInContext('bar = 1; bar;', context);
1655-
} catch(e) {
1655+
} catch (e) {
16561656
console.log(e); // Uncaught ReferenceError: bar is not defined
16571657
}
16581658
```
@@ -1681,7 +1681,7 @@ console.log(vm.runInContext('bar;', context)); // 1
16811681
Object.freeze(context);
16821682
try {
16831683
vm.runInContext('baz = 1; baz;', context);
1684-
} catch(e) {
1684+
} catch (e) {
16851685
console.log(e); // Uncaught ReferenceError: baz is not defined
16861686
}
16871687
```

doc/api/worker_threads.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ markAsUncloneable(anyObject);
220220
const { port1 } = new MessageChannel();
221221
try {
222222
// This will throw an error, because anyObject is not cloneable.
223-
port1.postMessage(anyObject)
223+
port1.postMessage(anyObject);
224224
} catch (error) {
225225
// error.name === 'DataCloneError'
226226
}
@@ -910,6 +910,8 @@ not preserved. In particular, [`Buffer`][] objects will be read as
910910
plain [`Uint8Array`][]s on the receiving side, and instances of JavaScript
911911
classes will be cloned as plain JavaScript objects.
912912

913+
<!-- eslint-disable no-unused-private-class-members -->
914+
913915
```js
914916
const b = Symbol('b');
915917

doc/api/zlib.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ http.createServer((request, response) => {
190190
const raw = fs.createReadStream('index.html');
191191
// Store both a compressed and an uncompressed version of the resource.
192192
response.setHeader('Vary', 'Accept-Encoding');
193-
let acceptEncoding = request.headers['accept-encoding'];
194-
if (!acceptEncoding) {
195-
acceptEncoding = '';
196-
}
193+
const acceptEncoding = request.headers['accept-encoding'] || '';
197194

198195
const onError = (err) => {
199196
if (err) {

doc/changelogs/CHANGELOG_V23.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ will now correctly change as the underlying `ArrayBuffer` size is changed.
176176
```js
177177
const ab = new ArrayBuffer(10, { maxByteLength: 20 });
178178
const buffer = Buffer.from(ab);
179-
console.log(buffer.byteLength); 10
179+
console.log(buffer.byteLength); // 10
180180
ab.resize(15);
181-
console.log(buffer.byteLength); 15
181+
console.log(buffer.byteLength); // 15
182182
ab.resize(5);
183-
console.log(buffer.byteLength); 5
183+
console.log(buffer.byteLength); // 5
184184
```
185185

186186
Contributed by James M Snell in [#55377](https://github.com/nodejs/node/pull/55377).

doc/contributing/writing-and-running-benchmarks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ The arguments of `createBenchmark` are:
538538
source: ['buffer', 'string'],
539539
len: [2048],
540540
n: [50, 2048],
541-
}
541+
},
542542
}, { byGroups: true });
543543
```
544544

eslint.config.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export default [
4343
'**/node_modules/**',
4444
'benchmark/fixtures/**',
4545
'benchmark/tmp/**',
46-
'doc/**/*.js',
4746
'doc/changelogs/CHANGELOG_V1*.md',
48-
'!doc/api_assets/*.js',
4947
'!doc/changelogs/CHANGELOG_V18.md',
5048
'lib/punycode.js',
5149
'test/.tmp.*/**',

0 commit comments

Comments
 (0)