Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add and apply eslint rule no-regex-spaces #26409

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
tools: add and apply eslint rule no-regex-spaces
  • Loading branch information
gengjiawen committed Mar 3, 2019
commit 7c882c3961b0be0366ddad3af2306158b26e5403
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ module.exports = {
'no-path-concat': 'error',
'no-proto': 'error',
'no-redeclare': 'error',
'no-regex-spaces': 'error',
'no-restricted-modules': ['error', 'sys'],
/* eslint-disable max-len */
'no-restricted-properties': [
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ assert.throws(
{
code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]',
message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n /
message: /a: \[Getter: 5]\n- {3}a: \[Getter: 6]\n {2}/
}
);

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ assert.throws(
assert.deepStrictEqual(Array(100).fill(1), 'foobar');
} catch (err) {
threw = true;
assert(/actual: \[Array],\n expected: 'foobar',/.test(inspect(err)));
assert(/actual: \[Array],\n {2}expected: 'foobar',/.test(inspect(err)));
}
assert(threw);
}
2 changes: 1 addition & 1 deletion test/parallel/test-debug-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ child.stderr.setEncoding('utf8');
const expectedLines = [
/^\(node:\d+\) \[DEP0068\] DeprecationWarning:/,
/^Usage: .*node.* debug script\.js$/,
/^ .*node.* debug <host>:<port>$/
/^ {7}.*node.* debug <host>:<port>$/
];

let actualUsageMessage = '';
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-events-uncaught-exception-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process.on('uncaughtException', common.mustCall((err) => {
const lines = err.stack.split('\n');
assert.strictEqual(lines[0], 'Error');
lines.slice(1).forEach((line) => {
assert(/^ at/.test(line), `${line} has an unexpected format`);
assert(/^ {4}at/.test(line), `${line} has an unexpected format`);
});
}));

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http2-stream-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ server.on('stream', common.mustCall((stream) => {
assert.strictEqual(stream.aborted, false);
const insp = util.inspect(stream);
assert.ok(/Http2Stream { id/.test(insp));
assert.ok(/ state:/.test(insp));
assert.ok(/ readableState:/.test(insp));
assert.ok(/ writableState:/.test(insp));
assert.ok(/ {2}state:/.test(insp));
assert.ok(/ {2}readableState:/.test(insp));
assert.ok(/ {2}writableState:/.test(insp));
stream.end('ok');
}));
server.listen(0, common.mustCall(() => {
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ common.expectsError(() => {
}, { code: 'TEST_ERROR_1', type: RangeError });
}, {
code: 'ERR_ASSERTION',
message: /\+ type: \[Function: TypeError]\n- type: \[Function: RangeError]/
message: /\+ {3}type: \[Function: TypeError]\n- {3}type: \[Function: RangeError]/
});

common.expectsError(() => {
Expand All @@ -98,7 +98,7 @@ common.expectsError(() => {
}, {
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: /\+ message: 'Error for testing purposes: a',\n- message: \/\^Error/
message: /\+ {3}message: 'Error for testing purposes: a',\n- {3}message: \/\^Error/
});

// Test ERR_INVALID_FD_TYPE
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-definecommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ r.defineCommand('say2', function() {
});

inputStream.write('.help\n');
assert(/\n\.say1 help for say1\n/.test(output),
assert(/\n\.say1 {5}help for say1\n/.test(output),
'help for say1 not present');
assert(/\n\.say2\n/.test(output), 'help for say2 not present');
inputStream.write('.say1 node developer\n');
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-repl-underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function testError() {
'Thrown:',
/^{ Error: ENOENT: no such file or directory, scandir '.*nonexistent.*'/,
/Object\.readdirSync/,
/^ errno: -(2|4058),$/,
/^ {2}errno: -(2|4058),$/,
" syscall: 'scandir',",
" code: 'ENOENT',",
" path: '/nonexistent?' }",
Expand All @@ -196,8 +196,8 @@ function testError() {
'Thrown:',
'Error: baz',
/setImmediate/,
/^ at/,
/^ at/,
/^ {4}at/,
/^ {4}at/,
];
for (const line of lines) {
const expected = expectedLines.shift();
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@ const errorTests = [
/^{ Error: Cannot find module 'internal\/repl'/,
/^Require stack:/,
/^- <repl>/,
/^ at .*/,
/^ at .*/,
/^ at .*/,
/^ at .*/
/^ {4}at .*/,
/^ {4}at .*/,
/^ {4}at .*/,
/^ {4}at .*/
]
},
// REPL should handle quotes within regexp literal in multiline mode
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-v8-untrusted-code-mitigations.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ assert.notStrictEqual(untrustedFlag, -1);
const nextFlag = v8Options.indexOf('--', untrustedFlag + 2);
const slice = v8Options.substring(untrustedFlag, nextFlag);

assert(slice.match(/type: bool default: false/));
assert(slice.match(/type: bool {2}default: false/));
2 changes: 1 addition & 1 deletion test/tick-processor/test-tick-processor-unknown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const base = require('./tick-processor-base.js');
// Unknown checked for to prevent flakiness, if pattern is not found,
// then a large number of unknown ticks should be present
base.runTest({
pattern: /LazyCompile.*\[eval]:1|.*% UNKNOWN/,
pattern: /LazyCompile.*\[eval]:1|.*% {2}UNKNOWN/,
code: `function f() {
for (var i = 0; i < 1000000; i++) {
i++;
Expand Down