Skip to content

Commit

Permalink
tools: lint js in doc/**/*.md
Browse files Browse the repository at this point in the history
PR-URL: #55904
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
LiviaMedeiros authored and aduh95 committed Nov 26, 2024
1 parent f711a48 commit d093820
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Errors that occur within _Asynchronous APIs_ may be reported in multiple ways:
<!-- eslint-disable no-useless-return -->

```js
const fs = require('fs/promises');
const fs = require('node:fs/promises');

(async () => {
let data;
Expand Down
2 changes: 1 addition & 1 deletion doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ module default import or its corresponding sugar syntax:
```js
import { default as cjs } from 'cjs';
// identical to the above
// Identical to the above
import cjsSugar from 'cjs';

console.log(cjs);
Expand Down
2 changes: 1 addition & 1 deletion doc/api/inspector.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ inspector.Network.requestWillBeSent({
request: {
url: 'https://nodejs.org/en',
method: 'GET',
}
},
});
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ built-in modules and if a name matching a built-in module is added to the cache,
only `node:`-prefixed require calls are going to receive the built-in module.
Use with care!

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

```js
const assert = require('node:assert');
Expand Down
2 changes: 1 addition & 1 deletion doc/api/perf_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ performance.measure('Start to Now');

performance.mark('A');
(async function doSomeLongRunningProcess() {
await new Promise(r => setTimeout(r, 5000));
await new Promise((r) => setTimeout(r, 5000));
performance.measure('A to Now', 'A');

performance.mark('B');
Expand Down
6 changes: 3 additions & 3 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -2107,10 +2107,10 @@ class Test {
constructor() {
finalization.register(this, (ref) => ref.dispose());

// even something like this is highly discouraged
// Even something like this is highly discouraged
// finalization.register(this, () => this.dispose());
}
dispose() {}
}
dispose() {}
}
```
Expand Down
2 changes: 1 addition & 1 deletion doc/api/punycode.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The `punycode` module is a bundled version of the [Punycode.js][] module. It
can be accessed using:

```js
const punycode = require('punycode');
const punycode = require('node:punycode');
```

[Punycode][] is a character encoding scheme defined by RFC 3492 that is
Expand Down
4 changes: 2 additions & 2 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ events (due to incorrect stream implementations) do not cause unexpected
crashes. If this is unwanted behavior then `options.cleanup` should be set to
`true`:

```js
```mjs
await finished(rs, { cleanup: true });
```

Expand Down Expand Up @@ -3926,7 +3926,7 @@ const { StringDecoder } = require('node:string_decoder');
class StringWritable extends Writable {
constructor(options) {
super(options);
this._decoder = new StringDecoder(options && options.defaultEncoding);
this._decoder = new StringDecoder(options?.defaultEncoding);
this.data = '';
}
_write(chunk, encoding, callback) {
Expand Down
2 changes: 1 addition & 1 deletion doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -3281,7 +3281,7 @@ test('snapshot test with default serialization', (t) => {

test('snapshot test with custom serialization', (t) => {
t.assert.snapshot({ value3: 3, value4: 4 }, {
serializers: [(value) => JSON.stringify(value)]
serializers: [(value) => JSON.stringify(value)],
});
});
```
Expand Down
8 changes: 4 additions & 4 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,13 @@ to set the security level to 0 while using the default OpenSSL cipher list, you
const tls = require('node:tls');
const port = 443;

tls.createServer({ciphers: 'DEFAULT@SECLEVEL=0', minVersion: 'TLSv1'}, function (socket) {
tls.createServer({ ciphers: 'DEFAULT@SECLEVEL=0', minVersion: 'TLSv1' }, function(socket) {
console.log('Client connected with protocol:', socket.getProtocol());
socket.end();
this.close();
}).
listen(port, () => {
tls.connect(port, {ciphers: 'DEFAULT@SECLEVEL=0', maxVersion: 'TLSv1'});
})
.listen(port, () => {
tls.connect(port, { ciphers: 'DEFAULT@SECLEVEL=0', maxVersion: 'TLSv1' });
});
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ console.log(trace_events.getEnabledCategories());
```js
'use strict';

const { Session } = require('inspector');
const { Session } = require('node:inspector');
const session = new Session();
session.connect();

Expand Down
2 changes: 1 addition & 1 deletion doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ The mapping between error codes and string messages is platform-dependent.
```js
fs.access('file/that/does/not/exist', (err) => {
const name = util.getSystemErrorMessage(err.errno);
console.error(name); // no such file or directory
console.error(name); // No such file or directory
});
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ is as follows.
Here's an example.

```js
const { GCProfiler } = require('v8');
const { GCProfiler } = require('node:v8');
const profiler = new GCProfiler();
profiler.start();
setTimeout(() => {
Expand Down
8 changes: 4 additions & 4 deletions doc/api/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1622,12 +1622,12 @@ in the outer context.
const vm = require('node:vm');
// An undefined `contextObject` option makes the global object contextified.
let context = vm.createContext();
const context = vm.createContext();
console.log(vm.runInContext('globalThis', context) === context); // false
// A contextified global object cannot be frozen.
try {
vm.runInContext('Object.freeze(globalThis);', context);
} catch(e) {
} catch (e) {
console.log(e); // TypeError: Cannot freeze
}
console.log(vm.runInContext('globalThis.foo = 1; foo;', context)); // 1
Expand All @@ -1652,7 +1652,7 @@ const context = vm.createContext(vm.constants.DONT_CONTEXTIFY);
vm.runInContext('Object.freeze(globalThis);', context);
try {
vm.runInContext('bar = 1; bar;', context);
} catch(e) {
} catch (e) {
console.log(e); // Uncaught ReferenceError: bar is not defined
}
```
Expand Down Expand Up @@ -1681,7 +1681,7 @@ console.log(vm.runInContext('bar;', context)); // 1
Object.freeze(context);
try {
vm.runInContext('baz = 1; baz;', context);
} catch(e) {
} catch (e) {
console.log(e); // Uncaught ReferenceError: baz is not defined
}
```
Expand Down
4 changes: 3 additions & 1 deletion doc/api/worker_threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ markAsUncloneable(anyObject);
const { port1 } = new MessageChannel();
try {
// This will throw an error, because anyObject is not cloneable.
port1.postMessage(anyObject)
port1.postMessage(anyObject);
} catch (error) {
// error.name === 'DataCloneError'
}
Expand Down Expand Up @@ -908,6 +908,8 @@ not preserved. In particular, [`Buffer`][] objects will be read as
plain [`Uint8Array`][]s on the receiving side, and instances of JavaScript
classes will be cloned as plain JavaScript objects.
<!-- eslint-disable no-unused-private-class-members -->
```js
const b = Symbol('b');

Expand Down
5 changes: 1 addition & 4 deletions doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ http.createServer((request, response) => {
const raw = fs.createReadStream('index.html');
// Store both a compressed and an uncompressed version of the resource.
response.setHeader('Vary', 'Accept-Encoding');
let acceptEncoding = request.headers['accept-encoding'];
if (!acceptEncoding) {
acceptEncoding = '';
}
const acceptEncoding = request.headers['accept-encoding'] || '';

const onError = (err) => {
if (err) {
Expand Down
6 changes: 3 additions & 3 deletions doc/changelogs/CHANGELOG_V23.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ will now correctly change as the underlying `ArrayBuffer` size is changed.
```js
const ab = new ArrayBuffer(10, { maxByteLength: 20 });
const buffer = Buffer.from(ab);
console.log(buffer.byteLength); 10
console.log(buffer.byteLength); // 10
ab.resize(15);
console.log(buffer.byteLength); 15
console.log(buffer.byteLength); // 15
ab.resize(5);
console.log(buffer.byteLength); 5
console.log(buffer.byteLength); // 5
```

Contributed by James M Snell in [#55377](https://github.com/nodejs/node/pull/55377).
Expand Down
2 changes: 1 addition & 1 deletion doc/contributing/writing-and-running-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ The arguments of `createBenchmark` are:
source: ['buffer', 'string'],
len: [2048],
n: [50, 2048],
}
},
}, { byGroups: true });
```

Expand Down
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export default [
'**/node_modules/**',
'benchmark/fixtures/**',
'benchmark/tmp/**',
'doc/**/*.js',
'doc/changelogs/CHANGELOG_V1*.md',
'!doc/api_assets/*.js',
'!doc/changelogs/CHANGELOG_V18.md',
'lib/punycode.js',
'test/.tmp.*/**',
Expand Down

0 comments on commit d093820

Please sign in to comment.