Skip to content

Commit 885c48b

Browse files
committed
chore: Turn on ESLint for markdown
1 parent 7df580b commit 885c48b

File tree

87 files changed

+2203
-1674
lines changed

Some content is hidden

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

87 files changed

+2203
-1674
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
static/legacy/
33
external/
44
build/
5+
# Top level await isn't supported till ESLint 8
6+
locale/en/blog/release/v17.0.0.md

.eslintrc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,25 @@
99
],
1010
"rules": {
1111
"prettier/prettier": "error"
12-
}
12+
},
13+
"overrides": [
14+
{
15+
"files": ["**/*.md"],
16+
"plugins": ["markdown"],
17+
"processor": "markdown/markdown"
18+
},
19+
{
20+
"files": ["**/*.md/*.js"],
21+
"rules": {
22+
"eqeqeq": "off",
23+
"no-const-assign": "off",
24+
"no-undef":"off",
25+
"no-unused-expressions": "off",
26+
"no-unused-vars": "off",
27+
"node/handle-callback-err": "off",
28+
"node/no-deprecated-api": "off",
29+
"prefer-const": "off"
30+
}
31+
}
32+
]
1333
}

locale/en/blog/release/v12.16.0.md

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ The `assert` module now provides experimental `assert.match()` and
1717
string and matches (or does not match) the provided regular expression:
1818

1919
```js
20-
const assert = require('assert').strict;
20+
const assert = require("assert").strict;
2121

22-
assert.match('I will fail', /pass/);
22+
assert.match("I will fail", /pass/);
2323
// AssertionError [ERR_ASSERTION]: The input did not match the regular ...
2424

25-
assert.doesNotMatch('I will fail', /fail/);
25+
assert.doesNotMatch("I will fail", /fail/);
2626
// AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
2727
```
2828

@@ -89,17 +89,17 @@ to compute the digest between updates:
8989

9090
```js
9191
// Calculate a rolling hash.
92-
const crypto = require('crypto');
93-
const hash = crypto.createHash('sha256');
92+
const crypto = require("crypto");
93+
const hash = crypto.createHash("sha256");
9494

95-
hash.update('one');
96-
console.log(hash.copy().digest('hex'));
95+
hash.update("one");
96+
console.log(hash.copy().digest("hex"));
9797

98-
hash.update('two');
99-
console.log(hash.copy().digest('hex'));
98+
hash.update("two");
99+
console.log(hash.copy().digest("hex"));
100100

101-
hash.update('three');
102-
console.log(hash.copy().digest('hex'));
101+
hash.update("three");
102+
console.log(hash.copy().digest("hex"));
103103

104104
// Etc.
105105
```
@@ -127,25 +127,23 @@ Michaël Zasso [#30109](https://github.com/nodejs/node/pull/30109).
127127
The new `EventEmitter.on` static method allows to async iterate over events:
128128

129129
```js
130-
const { on, EventEmitter } = require('events');
130+
const { on, EventEmitter } = require("events");
131131

132132
(async () => {
133-
134133
const ee = new EventEmitter();
135134

136135
// Emit later on
137136
process.nextTick(() => {
138-
ee.emit('foo', 'bar');
139-
ee.emit('foo', 42);
137+
ee.emit("foo", "bar");
138+
ee.emit("foo", 42);
140139
});
141140

142-
for await (const event of on(ee, 'foo')) {
141+
for await (const event of on(ee, "foo")) {
143142
// The execution of this inner block is synchronous and it
144143
// processes one event at a time (even with await). Do not use
145144
// if concurrent execution is required.
146145
console.log(event); // prints ['bar'] [42]
147146
}
148-
149147
})();
150148
```
151149

@@ -164,7 +162,7 @@ myEmitter.on(EventEmitter.errorMonitor, (err) => {
164162
MyMonitoringTool.log(err);
165163
});
166164

167-
myEmitter.emit('error', new Error('whoops!'));
165+
myEmitter.emit("error", new Error("whoops!"));
168166
// Still throws and crashes Node.js
169167
```
170168

@@ -178,8 +176,8 @@ can lead to an unhandled rejection in case of a thrown exception:
178176
```js
179177
const ee = new EventEmitter();
180178

181-
ee.on('something', async (value) => {
182-
throw new Error('kaboom');
179+
ee.on("something", async (value) => {
180+
throw new Error("kaboom");
183181
});
184182
```
185183

@@ -191,18 +189,18 @@ is one, or to the `'error'` event handler if there is none.
191189

192190
```js
193191
const ee1 = new EventEmitter({ captureRejections: true });
194-
ee1.on('something', async (value) => {
195-
throw new Error('kaboom');
192+
ee1.on("something", async (value) => {
193+
throw new Error("kaboom");
196194
});
197195

198-
ee1.on('error', console.log);
196+
ee1.on("error", console.log);
199197

200198
const ee2 = new EventEmitter({ captureRejections: true });
201-
ee2.on('something', async (value) => {
202-
throw new Error('kaboom');
199+
ee2.on("something", async (value) => {
200+
throw new Error("kaboom");
203201
});
204202

205-
ee2[Symbol.for('nodejs.rejection')] = console.log;
203+
ee2[Symbol.for("nodejs.rejection")] = console.log;
206204
```
207205

208206
Setting `EventEmitter.captureRejections = true` will change the default for all
@@ -211,11 +209,11 @@ new instances of `EventEmitter`.
211209
```js
212210
EventEmitter.captureRejections = true;
213211
const ee1 = new EventEmitter();
214-
ee1.on('something', async (value) => {
215-
throw new Error('kaboom');
212+
ee1.on("something", async (value) => {
213+
throw new Error("kaboom");
216214
});
217215

218-
ee1.on('error', console.log);
216+
ee1.on("error", console.log);
219217
```
220218

221219
This is an experimental feature.

locale/en/blog/release/v12.17.0.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,29 @@ HTTP request entering in a server, it will be possible to retrieve this id
5151
without having access the current HTTP request:
5252

5353
```js
54-
const http = require('http');
55-
const { AsyncLocalStorage } = require('async_hooks');
54+
const http = require("http");
55+
const { AsyncLocalStorage } = require("async_hooks");
5656

5757
const asyncLocalStorage = new AsyncLocalStorage();
5858

5959
function logWithId(msg) {
6060
const id = asyncLocalStorage.getStore();
61-
console.log(`${id !== undefined ? id : '-'}: `, msg);
61+
console.log(`${id !== undefined ? id : "-"}: `, msg);
6262
}
6363

6464
let idSeq = 0;
65-
http.createServer((req, res) => {
66-
asyncLocalStorage.run(idSeq++, () => {
67-
logWithId('start');
68-
// Imagine any chain of async operations here.
69-
setImmediate(() => {
70-
logWithId('finish');
71-
res.end();
65+
http
66+
.createServer((req, res) => {
67+
asyncLocalStorage.run(idSeq++, () => {
68+
logWithId("start");
69+
// Imagine any chain of async operations here.
70+
setImmediate(() => {
71+
logWithId("finish");
72+
res.end();
73+
});
7274
});
73-
});
74-
}).listen(8080);
75+
})
76+
.listen(8080);
7577
```
7678

7779
In this example, the `logWithId` function will always know what the current
@@ -156,7 +158,7 @@ myEmitter.on(EventEmitter.errorMonitor, (err) => {
156158
MyMonitoringTool.log(err);
157159
});
158160

159-
myEmitter.emit('error', new Error('whoops!'));
161+
myEmitter.emit("error", new Error("whoops!"));
160162
// Still throws and crashes Node.js
161163
```
162164

@@ -169,7 +171,7 @@ the default behavior that exits the process by installing an
169171
`'uncaughtExceptionMonitor'` listener:
170172

171173
```js
172-
process.on('uncaughtExceptionMonitor', (err, origin) => {
174+
process.on("uncaughtExceptionMonitor", (err, origin) => {
173175
MyMonitoringTool.logSync(err, origin);
174176
});
175177

@@ -205,17 +207,17 @@ The Console constructor (`require('console').Console`) now supports different gr
205207
This is useful in case you want different grouping width than 2 spaces.
206208

207209
```js
208-
const { Console } = require('console');
210+
const { Console } = require("console");
209211
const customConsole = new Console({
210212
stdout: process.stdout,
211213
stderr: process.stderr,
212-
groupIndentation: 10
214+
groupIndentation: 10,
213215
});
214216

215-
customConsole.log('foo');
217+
customConsole.log("foo");
216218
// 'foo'
217219
customConsole.group();
218-
customConsole.log('foo');
220+
customConsole.log("foo");
219221
// 'foo'
220222
```
221223

@@ -227,9 +229,9 @@ It is now possible to limit the length of strings while inspecting objects.
227229
This is possible by passing through the `maxStringLength` option similar to:
228230

229231
```js
230-
const { inspect } = require('util');
232+
const { inspect } = require("util");
231233

232-
const string = inspect(['a'.repeat(1e8)], { maxStringLength: 10 });
234+
const string = inspect(["a".repeat(1e8)], { maxStringLength: 10 });
233235

234236
console.log(string);
235237
// "[ 'aaaaaaaaaa'... 99999990 more characters ]"

locale/en/blog/release/v14.17.0.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ to enable testing it at a larger scale.
2020
With `diagnostics_channel`, Node.js core and module authors can publish contextual data about what they are doing at a given time. This could be the hostname and query string of a mysql query, for example. Just create a named channel with `dc.channel(name)` and call `channel.publish(data)` to send the data to any listeners to that channel.
2121

2222
```js
23-
const dc = require('diagnostics_channel');
24-
const channel = dc.channel('mysql.query');
23+
const dc = require("diagnostics_channel");
24+
const channel = dc.channel("mysql.query");
2525

2626
MySQL.prototype.query = function query(queryString, values, callback) {
2727
// Broadcast query information whenever a query is made
@@ -37,8 +37,8 @@ MySQL.prototype.query = function query(queryString, values, callback) {
3737
Channels are like one big global event emitter but are split into separate objects to ensure they get the best performance. If nothing is listening to the channel, the publishing overhead should be as close to zero as possible. Consuming channel data is as easy as using `channel.subscribe(listener)` to run a function whenever a message is published to that channel.
3838

3939
```js
40-
const dc = require('diagnostics_channel');
41-
const channel = dc.channel('mysql.query');
40+
const dc = require("diagnostics_channel");
41+
const channel = dc.channel("mysql.query");
4242

4343
channel.subscribe(({ query, host }) => {
4444
console.log(`mysql query to ${host}: ${query}`);
@@ -55,7 +55,7 @@ The new `crypto.randomUUID()` method now allows to generate random
5555
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4 UUID strings:
5656

5757
```js
58-
const { randomUUID } = require('crypto');
58+
const { randomUUID } = require("crypto");
5959

6060
console.log(randomUUID());
6161
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'

locale/en/blog/release/v14.2.0.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ that will count each time they are called. Then the `verify` method can be used
1919
to assert that the expected number of calls happened:
2020

2121
```js
22-
const assert = require('assert');
22+
const assert = require("assert");
2323

2424
const tracker = new assert.CallTracker();
2525

@@ -36,7 +36,7 @@ callsotherFunc();
3636

3737
// Calls tracker.verify() and verifies if all tracker.calls() functions have
3838
// been called the right number of times.
39-
process.on('exit', () => {
39+
process.on("exit", () => {
4040
tracker.verify();
4141
});
4242
```
@@ -46,7 +46,7 @@ about the errors, if there are any:
4646

4747
<!-- eslint-disable max-len -->
4848
```js
49-
const assert = require('assert');
49+
const assert = require("assert");
5050

5151
const tracker = new assert.CallTracker();
5252

@@ -77,17 +77,17 @@ The Console constructor (`require('console').Console`) now supports different gr
7777
This is useful in case you want different grouping width than 2 spaces.
7878

7979
```js
80-
const { Console } = require('console');
80+
const { Console } = require("console");
8181
const customConsole = new Console({
8282
stdout: process.stdout,
8383
stderr: process.stderr,
84-
groupIndentation: 10
84+
groupIndentation: 10,
8585
});
8686

87-
customConsole.log('foo');
87+
customConsole.log("foo");
8888
// 'foo'
8989
customConsole.group();
90-
customConsole.log('foo');
90+
customConsole.log("foo");
9191
// 'foo'
9292
```
9393

locale/en/blog/release/v14.5.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Example Usage:
3030
```js
3131
const target = getEventTargetSomehow();
3232

33-
target.addEventListener('foo', (event) => {
34-
console.log('foo event happened!');
33+
target.addEventListener("foo", (event) => {
34+
console.log("foo event happened!");
3535
});
3636
```
3737

locale/en/blog/release/v15.1.0.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ author: Michaël Zasso
1717
With `diagnostics_channel`, Node.js core and module authors can publish contextual data about what they are doing at a given time. This could be the hostname and query string of a mysql query, for example. Just create a named channel with `dc.channel(name)` and call `channel.publish(data)` to send the data to any listeners to that channel.
1818

1919
```js
20-
const dc = require('diagnostics_channel');
21-
const channel = dc.channel('mysql.query');
20+
const dc = require("diagnostics_channel");
21+
const channel = dc.channel("mysql.query");
2222

2323
MySQL.prototype.query = function query(queryString, values, callback) {
2424
// Broadcast query information whenever a query is made
@@ -34,8 +34,8 @@ MySQL.prototype.query = function query(queryString, values, callback) {
3434
Channels are like one big global event emitter but are split into separate objects to ensure they get the best performance. If nothing is listening to the channel, the publishing overhead should be as close to zero as possible. Consuming channel data is as easy as using `channel.subscribe(listener)` to run a function whenever a message is published to that channel.
3535

3636
```js
37-
const dc = require('diagnostics_channel');
38-
const channel = dc.channel('mysql.query');
37+
const dc = require("diagnostics_channel");
38+
const channel = dc.channel("mysql.query");
3939

4040
channel.subscribe(({ query, host }) => {
4141
console.log(`mysql query to ${host}: ${query}`);
@@ -67,11 +67,11 @@ systems.
6767
The resolver will use the v4 local address when making requests to IPv4 DNS servers, and the v6 local address when making requests to IPv6 DNS servers.
6868

6969
```js
70-
const { Resolver } = require('dns');
70+
const { Resolver } = require("dns");
7171

7272
const resolver = new Resolver();
7373

74-
resolver.setLocalAddress('10.1.2.3');
74+
resolver.setLocalAddress("10.1.2.3");
7575
// Equivalent to: resolver.setLocalAddress('10.1.2.3', '::0');
7676
```
7777

0 commit comments

Comments
 (0)