Skip to content

Commit 249acd5

Browse files
Trottrichardlau
authored andcommitted
debugger: reduce scope of eslint disable comment
Current code masks setInterval and setTimeout with promisified versions. This can be confusing to read and causes lint errors. Replace masking with use of pSetInterval and pSetTimeout instead. Move disabling of lint rule from entire file to the one remaining line (after the above changes) that still needs it. PR-URL: #38946 Backport-PR-URL: #39446 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 0ef5e08 commit 249acd5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/internal/inspector/_inspect.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
* IN THE SOFTWARE.
2121
*/
2222

23-
// TODO(aduh95): remove restricted syntax errors
24-
/* eslint-disable no-restricted-syntax */
25-
2623
'use strict';
2724

2825
const {
@@ -56,10 +53,10 @@ const {
5653
AbortController,
5754
} = require('internal/abort_controller');
5855

59-
const setTimeout = util.promisify(require('timers').setTimeout);
60-
async function* setInterval(delay) {
56+
const pSetTimeout = util.promisify(require('timers').setTimeout);
57+
async function* pSetInterval(delay) {
6158
while (true) {
62-
await setTimeout(delay);
59+
await pSetTimeout(delay);
6360
yield;
6461
}
6562
}
@@ -89,13 +86,13 @@ async function portIsFree(host, port, timeout = 9999) {
8986
const ac = new AbortController();
9087
const { signal } = ac;
9188

92-
setTimeout(timeout).then(() => ac.abort());
89+
pSetTimeout(timeout).then(() => ac.abort());
9390

94-
const asyncIterator = setInterval(retryDelay);
91+
const asyncIterator = pSetInterval(retryDelay);
9592
while (true) {
9693
await asyncIterator.next();
9794
if (signal.aborted) {
98-
throw new StartupError(
95+
throw new StartupError( // eslint-disable-line no-restricted-syntax
9996
`Timeout (${timeout}) waiting for ${host}:${port} to be free`);
10097
}
10198
const error = await new Promise((resolve) => {
@@ -255,7 +252,7 @@ class NodeInspector {
255252
return;
256253
} catch (error) {
257254
debuglog('connect failed', error);
258-
await setTimeout(1000);
255+
await pSetTimeout(1000);
259256
}
260257
}
261258
this.stdout.write(' failed to connect, please retry\n');

0 commit comments

Comments
 (0)