Skip to content

Commit 4518fdd

Browse files
Trotttargos
authored andcommitted
tools,lib,test: enable ESLint no-regex-spaces rule
PR-URL: #41463 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]>
1 parent 1f4369a commit 4518fdd

12 files changed

+23
-22
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ module.exports = {
215215
'no-path-concat': 'error',
216216
'no-proto': 'error',
217217
'no-redeclare': ['error', { 'builtinGlobals': false }],
218+
'no-regex-spaces': 'error',
218219
'no-restricted-modules': ['error', 'sys'],
219220
/* eslint-disable max-len */
220221
'no-restricted-properties': [

lib/internal/util/inspect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const strEscapeSequencesReplacerSingle = /[\x00-\x1f\x5c\x7f-\x9f]|[\ud800-\udbf
188188
const keyStrRegExp = /^[a-zA-Z_][a-zA-Z_0-9]*$/;
189189
const numberRegExp = /^(0|[1-9][0-9]*)$/;
190190

191-
const coreModuleRegExp = /^ at (?:[^/\\(]+ \(|)node:(.+):\d+:\d+\)?$/;
191+
const coreModuleRegExp = /^ {4}at (?:[^/\\(]+ \(|)node:(.+):\d+:\d+\)?$/;
192192
const nodeModulesRegExp = /[/\\]node_modules[/\\](.+?)(?=[/\\])/g;
193193

194194
const classRegExp = /^(\s+[^(]*?)\s*{/;

test/parallel/test-assert-deep.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ assert.throws(
11251125
{
11261126
code: 'ERR_ASSERTION',
11271127
name: 'AssertionError',
1128-
message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n /
1128+
message: /a: \[Getter: 5]\n- {3}a: \[Getter: 6]\n {2}/
11291129
}
11301130
);
11311131

test/parallel/test-assert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ assert.throws(
12471247
assert.deepStrictEqual(Array(100).fill(1), 'foobar');
12481248
} catch (err) {
12491249
threw = true;
1250-
assert.match(inspect(err), /actual: \[Array],\n expected: 'foobar',/);
1250+
assert.match(inspect(err), /actual: \[Array],\n {2}expected: 'foobar',/);
12511251
}
12521252
assert(threw);
12531253
}

test/parallel/test-debugger-address.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function launchTarget(...args) {
6565
.then(() => {
6666
assert.match(
6767
cli.output,
68-
/> 3 \+\+x;/,
68+
/> 3 {3}\+\+x;/,
6969
'marks the 3rd line');
7070
})
7171
.then(() => cleanup())

test/parallel/test-events-uncaught-exception-stack.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ process.on('uncaughtException', common.mustCall((err) => {
99
const lines = err.stack.split('\n');
1010
assert.strictEqual(lines[0], 'Error');
1111
lines.slice(1).forEach((line) => {
12-
assert.match(line, /^ at/);
12+
assert.match(line, /^ {4}at/);
1313
});
1414
}));
1515

test/parallel/test-http2-stream-client.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ server.on('stream', common.mustCall((stream) => {
1212
assert.strictEqual(stream.aborted, false);
1313
const insp = util.inspect(stream);
1414
assert.match(insp, /Http2Stream {/);
15-
assert.match(insp, / state:/);
16-
assert.match(insp, / readableState:/);
17-
assert.match(insp, / writableState:/);
15+
assert.match(insp, / {2}state:/);
16+
assert.match(insp, / {2}readableState:/);
17+
assert.match(insp, / {2}writableState:/);
1818
stream.end('ok');
1919
}));
2020
server.listen(0, common.mustCall(() => {

test/parallel/test-repl-definecommand.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ r.defineCommand('say2', function() {
3535
});
3636

3737
inputStream.write('.help\n');
38-
assert.match(output, /\n\.say1 help for say1\n/);
38+
assert.match(output, /\n\.say1 {5}help for say1\n/);
3939
assert.match(output, /\n\.say2\n/);
4040
inputStream.write('.say1 node developer\n');
4141
assert.ok(output.startsWith('hello node developer\n'),

test/parallel/test-repl-underscore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function testError() {
179179
// The sync error, with individual property echoes
180180
/^Uncaught Error: ENOENT: no such file or directory, scandir '.*nonexistent\?'/,
181181
/Object\.readdirSync/,
182-
/^ errno: -(2|4058),$/,
182+
/^ {2}errno: -(2|4058),$/,
183183
" syscall: 'scandir',",
184184
" code: 'ENOENT',",
185185
" path: '/nonexistent?'",

test/parallel/test-repl.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,10 @@ const errorTests = [
571571
/^Uncaught Error: Cannot find module 'internal\/repl'/,
572572
/^Require stack:/,
573573
/^- <repl>/,
574-
/^ at .*/,
575-
/^ at .*/,
576-
/^ at .*/,
577-
/^ at .*/,
574+
/^ {4}at .*/,
575+
/^ {4}at .*/,
576+
/^ {4}at .*/,
577+
/^ {4}at .*/,
578578
" code: 'MODULE_NOT_FOUND',",
579579
" requireStack: [ '<repl>' ]",
580580
'}',
@@ -776,12 +776,12 @@ const errorTests = [
776776
' group: [Function: group],',
777777
' groupEnd: [Function: groupEnd],',
778778
' table: [Function: table],',
779-
/ debug: \[Function: (debug|log)],/,
780-
/ info: \[Function: (info|log)],/,
781-
/ dirxml: \[Function: (dirxml|log)],/,
782-
/ error: \[Function: (error|warn)],/,
783-
/ groupCollapsed: \[Function: (groupCollapsed|group)],/,
784-
/ Console: \[Function: Console],?/,
779+
/ {2}debug: \[Function: (debug|log)],/,
780+
/ {2}info: \[Function: (info|log)],/,
781+
/ {2}dirxml: \[Function: (dirxml|log)],/,
782+
/ {2}error: \[Function: (error|warn)],/,
783+
/ {2}groupCollapsed: \[Function: (groupCollapsed|group)],/,
784+
/ {2}Console: \[Function: Console],?/,
785785
...process.features.inspector ? [
786786
' profile: [Function: profile],',
787787
' profileEnd: [Function: profileEnd],',

test/sequential/test-debugger-pid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function launchTarget(...args) {
4444
.then(() => {
4545
assert.match(
4646
cli.output,
47-
/> 3 \+\+x;/,
47+
/> 3 {3}\+\+x;/,
4848
'marks the 3rd line');
4949
})
5050
.then(() => cleanup())

test/tick-processor/test-tick-processor-unknown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const base = require('./tick-processor-base.js');
1414
// Unknown checked for to prevent flakiness, if pattern is not found,
1515
// then a large number of unknown ticks should be present
1616
base.runTest({
17-
pattern: /LazyCompile.*\[eval]:1|.*% UNKNOWN/,
17+
pattern: /LazyCompile.*\[eval]:1|.*% {2}UNKNOWN/,
1818
code: `function f() {
1919
for (let i = 0; i < 1000000; i++) {
2020
i++;

0 commit comments

Comments
 (0)