Skip to content

Commit 7c882c3

Browse files
committed
tools: add and apply eslint rule no-regex-spaces
1 parent 60a148a commit 7c882c3

12 files changed

+20
-19
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ module.exports = {
137137
'no-path-concat': 'error',
138138
'no-proto': 'error',
139139
'no-redeclare': 'error',
140+
'no-regex-spaces': 'error',
140141
'no-restricted-modules': ['error', 'sys'],
141142
/* eslint-disable max-len */
142143
'no-restricted-properties': [

test/parallel/test-assert-deep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ assert.throws(
10641064
{
10651065
code: 'ERR_ASSERTION',
10661066
name: 'AssertionError [ERR_ASSERTION]',
1067-
message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n /
1067+
message: /a: \[Getter: 5]\n- {3}a: \[Getter: 6]\n {2}/
10681068
}
10691069
);
10701070

test/parallel/test-assert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ assert.throws(
11441144
assert.deepStrictEqual(Array(100).fill(1), 'foobar');
11451145
} catch (err) {
11461146
threw = true;
1147-
assert(/actual: \[Array],\n expected: 'foobar',/.test(inspect(err)));
1147+
assert(/actual: \[Array],\n {2}expected: 'foobar',/.test(inspect(err)));
11481148
}
11491149
assert(threw);
11501150
}

test/parallel/test-debug-usage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ child.stderr.setEncoding('utf8');
1212
const expectedLines = [
1313
/^\(node:\d+\) \[DEP0068\] DeprecationWarning:/,
1414
/^Usage: .*node.* debug script\.js$/,
15-
/^ .*node.* debug <host>:<port>$/
15+
/^ {7}.*node.* debug <host>:<port>$/
1616
];
1717

1818
let actualUsageMessage = '';

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

Lines changed: 1 addition & 1 deletion
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(/^ at/.test(line), `${line} has an unexpected format`);
12+
assert(/^ {4}at/.test(line), `${line} has an unexpected format`);
1313
});
1414
}));
1515

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

Lines changed: 3 additions & 3 deletions
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.ok(/Http2Stream { id/.test(insp));
15-
assert.ok(/ state:/.test(insp));
16-
assert.ok(/ readableState:/.test(insp));
17-
assert.ok(/ writableState:/.test(insp));
15+
assert.ok(/ {2}state:/.test(insp));
16+
assert.ok(/ {2}readableState:/.test(insp));
17+
assert.ok(/ {2}writableState:/.test(insp));
1818
stream.end('ok');
1919
}));
2020
server.listen(0, common.mustCall(() => {

test/parallel/test-internal-errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ common.expectsError(() => {
8686
}, { code: 'TEST_ERROR_1', type: RangeError });
8787
}, {
8888
code: 'ERR_ASSERTION',
89-
message: /\+ type: \[Function: TypeError]\n- type: \[Function: RangeError]/
89+
message: /\+ {3}type: \[Function: TypeError]\n- {3}type: \[Function: RangeError]/
9090
});
9191

9292
common.expectsError(() => {
@@ -98,7 +98,7 @@ common.expectsError(() => {
9898
}, {
9999
code: 'ERR_ASSERTION',
100100
type: assert.AssertionError,
101-
message: /\+ message: 'Error for testing purposes: a',\n- message: \/\^Error/
101+
message: /\+ {3}message: 'Error for testing purposes: a',\n- {3}message: \/\^Error/
102102
});
103103

104104
// Test ERR_INVALID_FD_TYPE

test/parallel/test-repl-definecommand.js

Lines changed: 1 addition & 1 deletion
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(/\n\.say1 help for say1\n/.test(output),
38+
assert(/\n\.say1 {5}help for say1\n/.test(output),
3939
'help for say1 not present');
4040
assert(/\n\.say2\n/.test(output), 'help for say2 not present');
4141
inputStream.write('.say1 node developer\n');

test/parallel/test-repl-underscore.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function testError() {
181181
'Thrown:',
182182
/^{ Error: ENOENT: no such file or directory, scandir '.*nonexistent.*'/,
183183
/Object\.readdirSync/,
184-
/^ errno: -(2|4058),$/,
184+
/^ {2}errno: -(2|4058),$/,
185185
" syscall: 'scandir',",
186186
" code: 'ENOENT',",
187187
" path: '/nonexistent?' }",
@@ -196,8 +196,8 @@ function testError() {
196196
'Thrown:',
197197
'Error: baz',
198198
/setImmediate/,
199-
/^ at/,
200-
/^ at/,
199+
/^ {4}at/,
200+
/^ {4}at/,
201201
];
202202
for (const line of lines) {
203203
const expected = expectedLines.shift();

test/parallel/test-repl.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,10 @@ const errorTests = [
537537
/^{ Error: Cannot find module 'internal\/repl'/,
538538
/^Require stack:/,
539539
/^- <repl>/,
540-
/^ at .*/,
541-
/^ at .*/,
542-
/^ at .*/,
543-
/^ at .*/
540+
/^ {4}at .*/,
541+
/^ {4}at .*/,
542+
/^ {4}at .*/,
543+
/^ {4}at .*/
544544
]
545545
},
546546
// REPL should handle quotes within regexp literal in multiline mode

0 commit comments

Comments
 (0)