◐ Shell
clean mode source ↗

tools: lint js in `doc/**/*.md` · nodejs/node@312bb4d

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;

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
Original file line numberDiff line numberDiff line change

@@ -889,7 +889,7 @@ built-in modules and if a name matching a built-in module is added to the cache,

889889

only `node:`-prefixed require calls are going to receive the built-in module.

890890

Use with care!

891891
892-

<!-- eslint-disable node-core/no-duplicate-requires -->

892+

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

893893
894894

```js

895895

const assert = require('node:assert');

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');

Original file line numberDiff line numberDiff line change

@@ -2099,10 +2099,10 @@ class Test {

20992099

constructor() {

21002100

finalization.register(this, (ref) => ref.dispose());

21012101
2102-

// even something like this is highly discouraged

2102+

// Even something like this is highly discouraged

21032103

// finalization.register(this, () => this.dispose());

2104-

}

2105-

dispose() {}

2104+

}

2105+

dispose() {}

21062106

}

21072107

```

21082108
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

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

@@ -3916,7 +3916,7 @@ const { StringDecoder } = require('node:string_decoder');

39163916

class StringWritable extends Writable {

39173917

constructor(options) {

39183918

super(options);

3919-

this._decoder = new StringDecoder(options && options.defaultEncoding);

3919+

this._decoder = new StringDecoder(options?.defaultEncoding);

39203920

this.data = '';

39213921

}

39223922

_write(chunk, encoding, callback) {

Original file line numberDiff line numberDiff line change

@@ -3256,7 +3256,7 @@ test('snapshot test with default serialization', (t) => {

32563256
32573257

test('snapshot test with custom serialization', (t) => {

32583258

t.assert.snapshot({ value3: 3, value4: 4 }, {

3259-

serializers: [(value) => JSON.stringify(value)]

3259+

serializers: [(value) => JSON.stringify(value)],

32603260

});

32613261

});

32623262

```

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
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