From 40c195b05e8ae644700f15817ba5704a24d4f402 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 8 May 2026 16:43:57 +0200 Subject: [PATCH] doc: remove unnecessary ` + ```mjs import assert from 'node:assert/strict'; @@ -1720,7 +1720,7 @@ assert.ok(0); // assert.ok(0) ``` - + ```cjs const assert = require('node:assert/strict'); diff --git a/doc/api/console.md b/doc/api/console.md index f0669558abe385..804778bd5fa681 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -240,9 +240,7 @@ added: v8.3.0 Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`. - - -```js +```console > console.count() default: 1 undefined @@ -274,9 +272,7 @@ added: v8.3.0 Resets the internal counter specific to `label`. - - -```js +```console > console.count('abc'); abc: 1 undefined diff --git a/doc/api/crypto.md b/doc/api/crypto.md index e8583803e768b1..91cb32a1b9816f 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -53,8 +53,6 @@ try { } ``` - - When using the lexical ESM `import` keyword, the error can only be caught if a handler for `process.on('uncaughtException')` is registered _before_ any attempt to load the module is made (using, for instance, diff --git a/doc/api/dns.md b/doc/api/dns.md index 5bb0f83b36729e..7ba830048e013d 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -205,14 +205,12 @@ Returns an array of IP address strings, formatted according to [RFC 5952][], that are currently configured for DNS resolution. A string will include a port section if a custom port is used. - - -```js +```json [ - '8.8.8.8', - '2001:4860:4860::8888', - '8.8.8.8:1053', - '[2001:4860:4860::8888]:1053', + "8.8.8.8", + "2001:4860:4860::8888", + "8.8.8.8:1053", + "[2001:4860:4860::8888]:1053", ] ``` @@ -559,8 +557,6 @@ will be present on the object: Here is an example of the `ret` object passed to the callback: - - ```js [ { type: 'A', address: '127.0.0.1', ttl: 299 }, { type: 'CNAME', value: 'example.com' }, @@ -574,7 +570,7 @@ Here is an example of the `ret` object passed to the callback: refresh: 900, retry: 900, expire: 1800, - minttl: 60 } ] + minttl: 60 } ]; ``` DNS server operators may choose not to respond to `ANY` @@ -678,17 +674,15 @@ function will contain an array of objects with the following properties: * `order` * `preference` - - ```js -{ +({ flags: 's', service: 'SIP+D2U', regexp: '', replacement: '_sip._udp.example.com', order: 30, - preference: 100 -} + preference: 100, +}); ``` ## `dns.resolveNs(hostname, callback)` @@ -763,18 +757,16 @@ be an object with the following properties: * `expire` * `minttl` - - ```js -{ +({ nsname: 'ns.example.com', hostmaster: 'root.example.com', serial: 2013101809, refresh: 10000, retry: 2400, expire: 604800, - minttl: 3600 -} + minttl: 3600, +}); ``` ## `dns.resolveSrv(hostname, callback)` @@ -803,15 +795,13 @@ be an array of objects with the following properties: * `port` * `name` - - ```js -{ +({ priority: 10, weight: 5, port: 21223, - name: 'service.example.com' -} + name: 'service.example.com', +}); ``` ## `dns.resolveTlsa(hostname, callback)` @@ -840,15 +830,13 @@ array of objects with these properties: * `match` * `data` - - ```js -{ +({ certUsage: 3, selector: 1, match: 1, - data: [ArrayBuffer] -} + data: [ArrayBuffer], +}); ``` ## `dns.resolveTxt(hostname, callback)` @@ -1081,14 +1069,12 @@ Returns an array of IP address strings, formatted according to [RFC 5952][], that are currently configured for DNS resolution. A string will include a port section if a custom port is used. - - -```js +```json [ - '8.8.8.8', - '2001:4860:4860::8888', - '8.8.8.8:1053', - '[2001:4860:4860::8888]:1053', + "8.8.8.8", + "2001:4860:4860::8888", + "8.8.8.8:1053", + "[2001:4860:4860::8888]:1053" ] ``` @@ -1329,8 +1315,6 @@ present on the object: Here is an example of the result object: - - ```js [ { type: 'A', address: '127.0.0.1', ttl: 299 }, { type: 'CNAME', value: 'example.com' }, @@ -1344,7 +1328,7 @@ Here is an example of the result object: refresh: 900, retry: 900, expire: 1800, - minttl: 60 } ] + minttl: 60 } ]; ``` ### `dnsPromises.resolveCaa(hostname)` @@ -1407,17 +1391,15 @@ of objects with the following properties: * `order` * `preference` - - ```js -{ +({ flags: 's', service: 'SIP+D2U', regexp: '', replacement: '_sip._udp.example.com', order: 30, - preference: 100 -} + preference: 100, +}); ``` ### `dnsPromises.resolveNs(hostname)` @@ -1465,18 +1447,16 @@ following properties: * `expire` * `minttl` - - ```js -{ +({ nsname: 'ns.example.com', hostmaster: 'root.example.com', serial: 2013101809, refresh: 10000, retry: 2400, expire: 604800, - minttl: 3600 -} + minttl: 3600, +}); ``` ### `dnsPromises.resolveSrv(hostname)` @@ -1496,15 +1476,13 @@ the following properties: * `port` * `name` - - ```js -{ +({ priority: 10, weight: 5, port: 21223, - name: 'service.example.com' -} + name: 'service.example.com', +}); ``` ### `dnsPromises.resolveTlsa(hostname)` @@ -1526,15 +1504,13 @@ with these properties: * `match` * `data` - - ```js -{ +({ certUsage: 3, selector: 1, match: 1, - data: [ArrayBuffer] -} + data: [ArrayBuffer], +}); ``` ### `dnsPromises.resolveTxt(hostname)` diff --git a/doc/api/esm.md b/doc/api/esm.md index f6ac6f457b8947..ca1f9e8049603c 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -569,8 +569,6 @@ console.log(cjs === cjsSugar); This Module Namespace Exotic Object can be directly observed either when using `import * as m from 'cjs'` or a dynamic import: - - ```js import * as m from 'cjs'; console.log(m); diff --git a/doc/api/http.md b/doc/api/http.md index 95674770153bf4..65ed90bca83b48 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -39,15 +39,13 @@ property, which is an array of `[key, value, key2, value2, ...]`. For example, the previous message header object might have a `rawHeaders` list like the following: - - -```js -[ 'ConTent-Length', '123456', - 'content-LENGTH', '123', - 'content-type', 'text/plain', - 'CONNECTION', 'keep-alive', - 'Host', 'example.com', - 'accepT', '*/*' ] +```json +[ "ConTent-Length", "123456", + "content-LENGTH", "123", + "content-type", "text/plain", + "CONNECTION", "keep-alive", + "Host", "example.com", + "accepT", "*/*" ] ``` ## Class: `http.Agent` diff --git a/doc/api/http2.md b/doc/api/http2.md index 89579aa9069af6..dcba89fcedec6d 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -4303,10 +4303,8 @@ Accept: text/plain Then `request.url` will be: - - -```js -'/status?name=ryan' +```json +"/status?name=ryan" ``` To parse the url into its parts, `new URL()` can be used: diff --git a/doc/api/module.md b/doc/api/module.md index 79d6c816cae23d..7f47ab0b55e109 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -1128,8 +1128,6 @@ export async function load(url, context, nextLoad) { Unlike synchronous hooks, the asynchronous hooks would not run for these modules loaded in the file that calls `register()`: - - ```mjs // register-hooks.js import { register, createRequire } from 'node:module'; @@ -1137,12 +1135,10 @@ register('./hooks.mjs', import.meta.url); // Asynchronous hooks does not affect modules loaded via custom require() // functions created by module.createRequire(). -const userRequire = createRequire(__filename); +const userRequire = createRequire(import.meta.filename); userRequire('./my-app-2.cjs'); // Hooks won't affect this ``` - - ```cjs // register-hooks.js const { register, createRequire } = require('node:module'); diff --git a/doc/api/modules.md b/doc/api/modules.md index 38cfcf2a4b94ef..5f920ec324bc21 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -262,8 +262,6 @@ the default export in the `.default` property, similar to the results returned b To customize what should be returned by `require(esm)` directly, the ES Module can export the desired value using the string name `"module.exports"`. - - ```mjs // point.mjs export default class Point { @@ -273,7 +271,7 @@ export default class Point { // `distance` is lost to CommonJS consumers of this module, unless it's // added to `Point` as a static property. export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } -export { Point as 'module.exports' } +export { Point as 'module.exports' }; ``` @@ -293,8 +291,6 @@ named exports, the module can make sure that the default export is an object wit named exports attached to it as properties. For example with the example above, `distance` can be attached to the default export, the `Point` class, as a static method. - - ```mjs export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } @@ -303,7 +299,7 @@ export default class Point { static distance = distance; } -export { Point as 'module.exports' } +export { Point as 'module.exports' }; ``` diff --git a/doc/api/os.md b/doc/api/os.md index 9f2aa0390cc56a..6b3bb1ddfa554a 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -94,8 +94,6 @@ The properties included on each object include: * `idle` {number} The number of milliseconds the CPU has spent in idle mode. * `irq` {number} The number of milliseconds the CPU has spent in irq mode. - - ```js [ { @@ -142,7 +140,7 @@ The properties included on each object include: irq: 20, }, }, -] +]; ``` `nice` values are POSIX-only. On Windows, the `nice` values of all processors @@ -298,46 +296,44 @@ The properties available on the assigned network address object include: in CIDR notation. If the `netmask` is invalid, this property is set to `null`. - - -```js +```json { - lo: [ + "lo:": [ { - address: '127.0.0.1', - netmask: '255.0.0.0', - family: 'IPv4', - mac: '00:00:00:00:00:00', - internal: true, - cidr: '127.0.0.1/8' + "address:": "127.0.0.1", + "netmask:": "255.0.0.0", + "family:": "IPv4", + "mac:": "00:00:00:00:00:00", + "internal:": true, + "cidr:": "127.0.0.1/8" }, { - address: '::1', - netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', - family: 'IPv6', - mac: '00:00:00:00:00:00', - scopeid: 0, - internal: true, - cidr: '::1/128' + "address:": "::1", + "netmask:": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + "family:": "IPv6", + "mac:": "00:00:00:00:00:00", + "scopeid:": 0, + "internal:": true, + "cidr:": "::1/128" } ], - eth0: [ + "eth0:": [ { - address: '192.168.1.108', - netmask: '255.255.255.0', - family: 'IPv4', - mac: '01:02:03:0a:0b:0c', - internal: false, - cidr: '192.168.1.108/24' + "address:": "192.168.1.108", + "netmask:": "255.255.255.0", + "family:": "IPv4", + "mac:": "01:02:03:0a:0b:0c", + "internal:": false, + "cidr:": "192.168.1.108/24" }, { - address: 'fe80::a00:27ff:fe4e:66a1', - netmask: 'ffff:ffff:ffff:ffff::', - family: 'IPv6', - mac: '01:02:03:0a:0b:0c', - scopeid: 1, - internal: false, - cidr: 'fe80::a00:27ff:fe4e:66a1/64' + "address:": "fe80::a00:27ff:fe4e:66a1", + "netmask:": "ffff:ffff:ffff:ffff::", + "family:": "IPv6", + "mac:": "01:02:03:0a:0b:0c", + "scopeid:": 1, + "internal:": false, + "cidr:": "fe80::a00:27ff:fe4e:66a1/64" } ] } diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index bd38befcffbedc..e54d19b3aeb9e7 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -2175,8 +2175,6 @@ setTimeout(() => {}, 1000); The following example measures the duration of `require()` operations to load dependencies: - - ```mjs import { performance, PerformanceObserver } from 'node:perf_hooks'; diff --git a/doc/api/process.md b/doc/api/process.md index d8d022799a7016..7a9ade482d63a1 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1057,30 +1057,28 @@ when running the `./configure` script. An example of the possible output looks like: - - -```js +```json { - target_defaults: - { cflags: [], - default_configuration: 'Release', - defines: [], - include_dirs: [], - libraries: [] }, - variables: + "target_defaults": + { "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [] }, + "variables": { - host_arch: 'x64', - napi_build_version: 5, - node_install_npm: 'true', - node_prefix: '', - node_shared_cares: 'false', - node_shared_http_parser: 'false', - node_shared_libuv: 'false', - node_shared_zlib: 'false', - node_use_openssl: 'true', - node_shared_openssl: 'false', - target_arch: 'x64', - v8_use_snapshot: 1 + "host_arch": "x64", + "napi_build_version": 5, + "node_install_npm": "true", + "node_prefix": "", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_zlib": "false", + "node_use_openssl": "true", + "node_shared_openssl": "false", + "target_arch": "x64", + "v8_use_snapshot": 1 } } ``` @@ -1562,20 +1560,18 @@ See environ(7). An example of this object looks like: - - -```js +```json { - TERM: 'xterm-256color', - SHELL: '/usr/local/bin/bash', - USER: 'maciej', - PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', - PWD: '/Users/maciej', - EDITOR: 'vim', - SHLVL: '1', - HOME: '/Users/maciej', - LOGNAME: 'maciej', - _: '/usr/local/bin/node' + "TERM": "xterm-256color", + "SHELL": "/usr/local/bin/bash", + "USER": "maciej", + "PATH": "~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin", + "PWD": "/Users/maciej", + "EDITOR": "vim", + "SHLVL": "1", + "HOME": "/Users/maciej", + "LOGNAME": "maciej", + "_": "/usr/local/bin/node" } ``` @@ -1704,10 +1700,8 @@ Results in `process.execArgv`: And `process.argv`: - - -```js -['/usr/local/bin/node', 'script.js', '--version'] +```json +["/usr/local/bin/node", "script.js", "--version"] ``` Refer to [`Worker` constructor][] for the detailed behavior of worker @@ -1724,10 +1718,8 @@ added: v0.1.100 The `process.execPath` property returns the absolute pathname of the executable that started the Node.js process. Symbolic links, if any, are resolved. - - -```js -'/usr/local/bin/node' +```json +"/usr/local/bin/node" ``` ## `process.execve(file[, args[, env]])` @@ -3359,15 +3351,13 @@ tarball. * `'Hydrogen'` for the 18.x LTS line beginning with 18.12.0. For other LTS Release code names, see [Node.js Changelog Archive](https://github.com/nodejs/node/blob/HEAD/doc/changelogs/CHANGELOG_ARCHIVE.md) - - -```js +```json { - name: 'node', - lts: 'Hydrogen', - sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz', - headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz', - libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib' + "name": "node", + "lts": "Hydrogen", + "sourceUrl": "https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz", + "headersUrl": "https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz", + "libUrl": "https://nodejs.org/download/release/v18.12.0/win-x64/node.lib" } ``` diff --git a/doc/api/stream.md b/doc/api/stream.md index 1c661ce44b383e..5e30121673b7a1 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -3658,8 +3658,6 @@ of the four basic stream classes (`stream.Writable`, `stream.Readable`, `stream.Duplex`, or `stream.Transform`), making sure they call the appropriate parent class constructor: - - ```js const { Writable } = require('node:stream'); diff --git a/doc/api/v8.md b/doc/api/v8.md index f025b03ec495dc..24a88167148ef8 100644 --- a/doc/api/v8.md +++ b/doc/api/v8.md @@ -54,14 +54,12 @@ following properties: * `external_script_source_size` {number} * `cpu_profiler_metadata_size` {number} - - -```js +```json { - code_and_metadata_size: 212208, - bytecode_and_metadata_size: 161368, - external_script_source_size: 1410794, - cpu_profiler_metadata_size: 0, + "code_and_metadata_size": 212208, + "bytecode_and_metadata_size": 161368, + "external_script_source_size": 1410794, + "cpu_profiler_metadata_size": 0 } ``` @@ -267,24 +265,22 @@ buffers and external strings. `total_allocated_bytes` The value of total allocated bytes since the Isolate creation - - -```js +```json { - total_heap_size: 7326976, - total_heap_size_executable: 4194304, - total_physical_size: 7326976, - total_available_size: 1152656, - used_heap_size: 3476208, - heap_size_limit: 1535115264, - malloced_memory: 16384, - peak_malloced_memory: 1127496, - does_zap_garbage: 0, - number_of_native_contexts: 1, - number_of_detached_contexts: 0, - total_global_handles_size: 8192, - used_global_handles_size: 3296, - external_memory: 318824 + "total_heap_size": 7326976, + "total_heap_size_executable": 4194304, + "total_physical_size": 7326976, + "total_available_size": 1152656, + "used_heap_size": 3476208, + "heap_size_limit": 1535115264, + "malloced_memory": 16384, + "peak_malloced_memory": 1127496, + "does_zap_garbage": 0, + "number_of_native_contexts": 1, + "number_of_detached_contexts": 0, + "total_global_handles_size": 8192, + "used_global_handles_size": 3296, + "external_memory": 318824 } ``` diff --git a/doc/api/vm.md b/doc/api/vm.md index 1b7394928065db..4e6cca38002111 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -1103,8 +1103,6 @@ import foo from 'foo'; import source Foo from 'foo'; ``` - - The `modules` array must contain two references to the same instance, because the two module requests are identical but in two phases. @@ -1146,8 +1144,6 @@ import withAttrs from '../with-attrs.ts' with { arbitraryAttr: 'attr-val' }; import source Module from 'wasm-mod.wasm'; ``` - - The value of the `sourceTextModule.moduleRequests` will be: ```js diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index ce47645977be35..eb78058eb58e4c 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -1392,8 +1392,6 @@ 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. - - ```js const b = Symbol('b'); @@ -1404,7 +1402,7 @@ class Foo { this.c = 3; } - get d() { return 4; } + get d() { return this.#a + 3; } } const { port1, port2 } = new MessageChannel(); diff --git a/doc/api/zlib.md b/doc/api/zlib.md index ce296a07ac6c05..fc295417ba6ca3 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -454,10 +454,8 @@ From `zlib/zconf.h`, modified for Node.js usage: The memory requirements for deflate are (in bytes): - - ```js -(1 << (windowBits + 2)) + (1 << (memLevel + 9)) +(1 << (windowBits + 2)) + (1 << (memLevel + 9)); ``` That is: 128K for `windowBits` = 15 + 128K for `memLevel` = 8 diff --git a/doc/contributing/erm-guidelines.md b/doc/contributing/erm-guidelines.md index b35e7d1bb2d98d..d57acbb8bba282 100644 --- a/doc/contributing/erm-guidelines.md +++ b/doc/contributing/erm-guidelines.md @@ -280,25 +280,25 @@ The `Symbol.dispose` method should return `undefined` and the `Symbol.asyncDispose` method should return a `Promise` that resolves to `undefined`. - + ```js -[Symbol.dispose]() { - return void this.dispose(); - // or - this.dispose(); - // or - return; - // or - // no return -} +class MyIterable { + [Symbol.dispose]() { + this.dispose(); + // or + return; + // or + // no return + } + + async [Symbol.asyncDispose]() { + await this.dispose(); + // or -async [Symbol.asyncDispose]() { - await this.dispose(); - // or - return; - // or - // no return + // or + // no return + } } ``` @@ -312,21 +312,21 @@ directly. For example: - + ```js // Do something like this: -function dispose() { ... } +function dispose() { /* ... */ } return { dispose, - [Symbol.dispose]() { this.dispose(); } + [Symbol.dispose]() { this.dispose(); }, }; // Rather than this: -function dispose() { ... } +function dispose() { /* ... */ } return { dispose, - [Symbol.dispose]: dispose + [Symbol.dispose]: dispose, }; ``` diff --git a/doc/contributing/maintaining/maintaining-icu.md b/doc/contributing/maintaining/maintaining-icu.md index 00992258ae2611..e83aa8a5b0c407 100644 --- a/doc/contributing/maintaining/maintaining-icu.md +++ b/doc/contributing/maintaining/maintaining-icu.md @@ -132,8 +132,6 @@ make test-ci Also running - - ```js new Intl.DateTimeFormat('es', { month: 'long' }).format(new Date(9E8)); ``` @@ -159,8 +157,6 @@ make * Test this newly default-generated Node.js - - ```js process.versions.icu; new Intl.DateTimeFormat('es', { month: 'long' }).format(new Date(9E8)); diff --git a/doc/contributing/using-internal-errors.md b/doc/contributing/using-internal-errors.md index b24c96d9ccd243..db63abfe28a41f 100644 --- a/doc/contributing/using-internal-errors.md +++ b/doc/contributing/using-internal-errors.md @@ -65,17 +65,15 @@ It is possible to create multiple derived classes by providing additional arguments. The other ones will be exposed as properties of the main class: - - ```js E('EXAMPLE_KEY', 'Error message', TypeError, RangeError); // In another module +const assert = require('node:assert'); const { EXAMPLE_KEY } = require('internal/errors').codes; -// TypeError -throw new EXAMPLE_KEY(); -// RangeError -throw new EXAMPLE_KEY.RangeError(); + +assert.throws(() => { throw new EXAMPLE_KEY(); }, { name: 'TypeError' }); +assert.throws(() => { throw new EXAMPLE_KEY.RangeError(); }, { name: 'RangeError' }); ``` ## Documenting new errors