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

Ignore template literals #14173

Closed
wants to merge 2 commits 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
15 changes: 8 additions & 7 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,18 @@ rules:
# ObjectExpression: first,
# SwitchCase: 1}]
indent-legacy: [error, 2, {ArrayExpression: first,
CallExpression: {arguments: first},
MemberExpression: 1,
ObjectExpression: first,
SwitchCase: 1}]
CallExpression: {arguments: first},
MemberExpression: 1,
ObjectExpression: first,
SwitchCase: 1}]
key-spacing: [error, {mode: minimum}]
keyword-spacing: error
linebreak-style: [error, unix]
max-len: [error, {code: 80,
ignoreRegExpLiterals: true,
ignoreUrls: true,
tabWidth: 2}]
ignoreRegExpLiterals: true,
ignoreTemplateLiterals: true,
ignoreUrls: true,
tabWidth: 2}]
new-parens: error
no-mixed-spaces-and-tabs: error
no-multiple-empty-lines: [error, {max: 2, maxEOF: 0, maxBOF: 0}]
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ E('ERR_INVALID_ARRAY_LENGTH',
(name, length, actual) => {
const assert = lazyAssert();
assert.strictEqual(typeof actual, 'number');
return `The "${name}" array must have a length of ${
length}. Received length ${actual}`;
return `The "${name}" array must have a length of ${length}. Received length ${actual}`;
});
E('ERR_INVALID_CALLBACK', 'Callback must be a function');
E('ERR_INVALID_CHAR', 'Invalid character in %s');
Expand Down
3 changes: 1 addition & 2 deletions test/inspector/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
};
this.sendAll_(commands, () => {
timeoutId = setTimeout(() => {
assert.fail(`Messages without response: ${
Object.keys(this.messages_).join(', ')}`);
assert.fail(`Messages without response: ${Object.keys(this.messages_).join(', ')}`);
}, TIMEOUT);
});
});
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-crypto-fips.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ function testHelper(stream, args, expectedOutput, cmd, env) {
});

console.error(
`Spawned child [pid:${child.pid}] with cmd '${cmd}' expect %j with args '${
args}' OPENSSL_CONF=%j`, expectedOutput, env.OPENSSL_CONF);
`Spawned child [pid:${child.pid}] with cmd '${cmd}' expect %j with args '${args}' OPENSSL_CONF=%j`,
expectedOutput,
env.OPENSSL_CONF
);

function childOk(child) {
console.error(`Child #${++num_children_ok} [pid:${child.pid}] OK.`);
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-crypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ const modSize = 1024;
fs.writeFileSync(msgfile, msg);

const cmd =
`"${common.opensslCli}" dgst -sha256 -verify "${pubfile}" -signature "${
sigfile}" -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-2 "${
msgfile}"`;
`"${common.opensslCli}" dgst -sha256 -verify "${pubfile}" -signature "${sigfile}" -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-2 "${msgfile}"`;

exec(cmd, common.mustCall((err, stdout, stderr) => {
assert(stdout.includes('Verified OK'));
Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-domain-uncaught-exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ if (process.argv[2] === 'child') {
test.expectedMessages.forEach(function(expectedMessage) {
const msgs = test.messagesReceived;
if (msgs === undefined || !msgs.includes(expectedMessage)) {
assert.fail(`test ${test.fn.name} should have sent message: ${
expectedMessage} but didn't`);
assert.fail(
`test ${test.fn.name} should have sent message: ${expectedMessage} but didn't`
);
}
});

if (test.messagesReceived) {
test.messagesReceived.forEach(function(receivedMessage) {
if (!test.expectedMessages.includes(receivedMessage)) {
assert.fail(`test ${test.fn.name} should not have sent message: ${
receivedMessage} but did`);
assert.fail(
`test ${test.fn.name} should not have sent message: ${receivedMessage} but did`
);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-domain-with-abort-on-uncaught-exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ if (process.argv[2] === 'child') {
if (options.useTryCatch)
useTryCatchOpt = 'useTryCatch';

cmdToExec += `"${process.argv[0]}" ${cmdLineOption ? cmdLineOption : ''} "${
process.argv[1]}" child ${throwInDomainErrHandlerOpt} ${useTryCatchOpt}`;
cmdToExec +=
`"${process.argv[0]}" ${cmdLineOption ? cmdLineOption : ''} "${process.argv[1]}" child ${throwInDomainErrHandlerOpt} ${useTryCatchOpt}`;

const child = exec(cmdToExec);

Expand Down
7 changes: 4 additions & 3 deletions test/parallel/test-http-should-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ const server = net.createServer(function(socket) {
function makeRequest() {
const req = http.get({port: server.address().port}, function(res) {
assert.strictEqual(
req.shouldKeepAlive, SHOULD_KEEP_ALIVE[responses],
`${SERVER_RESPONSES[responses]} should ${
SHOULD_KEEP_ALIVE[responses] ? '' : 'not '}Keep-Alive`);
req.shouldKeepAlive,
SHOULD_KEEP_ALIVE[responses],
`${SERVER_RESPONSES[responses]} should ${SHOULD_KEEP_ALIVE[responses] ? '' : 'not '}Keep-Alive`
);
++responses;
if (responses < SHOULD_KEEP_ALIVE.length) {
makeRequest();
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ if (!common.hasIntl) {
common.skip('Intl tests because Intl object not present.');
} else {
const erMsg =
`"Intl" object is present but v8_enable_i18n_support is ${
enablei18n}. Is this test out of date?`;
`"Intl" object is present but v8_enable_i18n_support is ${enablei18n}. Is this test out of date?`;
assert.strictEqual(enablei18n, 1, erMsg);

// Construct a new date at the beginning of Unix time
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-path-parse-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ trailingTests.forEach(function(test) {
test[1].forEach(function(test) {
const actual = parse(test[0]);
const expected = test[1];
const message = `path.${os}.parse(${JSON.stringify(test[0])})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
const message =
`path.${os}.parse(${JSON.stringify(test[0])})\n` +
` expect=${JSON.stringify(expected)}\n` +
` actual=${JSON.stringify(actual)}`;
const actualKeys = Object.keys(actual);
const expectedKeys = Object.keys(expected);
let failed = (actualKeys.length !== expectedKeys.length);
Expand Down
23 changes: 14 additions & 9 deletions test/parallel/test-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ assert.strictEqual(path.win32.dirname('foo'), '.');
}
const actual = extname(input);
const expected = test[1];
const message = `path.${os}.extname(${JSON.stringify(input)})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
const message =
`path.${os}.extname(${JSON.stringify(input)})\n` +
` expect=${JSON.stringify(expected)}\n` +
` actual=${JSON.stringify(actual)}`;
if (actual !== expected)
failures.push(`\n${message}`);
});
Expand Down Expand Up @@ -354,8 +356,9 @@ joinTests.forEach((test) => {
os = 'posix';
}
const message =
`path.${os}.join(${test[0].map(JSON.stringify).join(',')})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
`path.${os}.join(${test[0].map(JSON.stringify).join(',')})\n` +
` expect=${JSON.stringify(expected)}\n` +
` actual=${JSON.stringify(actual)}`;
if (actual !== expected && actualAlt !== expected)
failures.push(`\n${message}`);
});
Expand Down Expand Up @@ -460,8 +463,9 @@ resolveTests.forEach((test) => {

const expected = test[1];
const message =
`path.${os}.resolve(${test[0].map(JSON.stringify).join(',')})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
`path.${os}.resolve(${test[0].map(JSON.stringify).join(',')})\n` +
` expect=${JSON.stringify(expected)}\n` +
` actual=${JSON.stringify(actual)}`;
if (actual !== expected && actualAlt !== expected)
failures.push(`\n${message}`);
});
Expand Down Expand Up @@ -559,9 +563,10 @@ relativeTests.forEach((test) => {
const actual = relative(test[0], test[1]);
const expected = test[2];
const os = relative === path.win32.relative ? 'win32' : 'posix';
const message = `path.${os}.relative(${
test.slice(0, 2).map(JSON.stringify).join(',')})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
const message =
`path.${os}.relative(${test.slice(0, 2).map(JSON.stringify).join(',')})\n` +
` expect=${JSON.stringify(expected)}\n` +
` actual=${JSON.stringify(actual)}`;
if (actual !== expected)
failures.push(`\n${message}`);
});
Expand Down
9 changes: 3 additions & 6 deletions test/parallel/test-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ replProc.on('close', function(code) {
// test that preload placement at other points in the cmdline
// also test that duplicated preload only gets loaded once
childProcess.exec(
`"${nodeBinary}" ${preloadOption([fixtureA])}-e "console.log('hello');" ${
preloadOption([fixtureA, fixtureB])}`,
`"${nodeBinary}" ${preloadOption([fixtureA])}-e "console.log('hello');" ${preloadOption([fixtureA, fixtureB])}`,
function(err, stdout, stderr) {
assert.ifError(err);
assert.strictEqual(stdout, 'A\nB\nhello\n');
Expand All @@ -124,8 +123,7 @@ interactive.stdin.write('a\n');
interactive.stdin.write('process.exit()\n');

childProcess.exec(
`"${nodeBinary}" --require "${fixture('cluster-preload.js')}" "${
fixture('cluster-preload-test.js')}"`,
`"${nodeBinary}" --require "${fixture('cluster-preload.js')}" "${fixture('cluster-preload-test.js')}"`,
function(err, stdout, stderr) {
assert.ifError(err);
assert.ok(/worker terminated with code 43/.test(stdout));
Expand All @@ -135,8 +133,7 @@ childProcess.exec(
// https://github.com/nodejs/node/issues/1691
process.chdir(common.fixturesDir);
childProcess.exec(
`"${nodeBinary}" --expose_natives_as=v8natives --require ` +
`"${fixture('cluster-preload.js')}" cluster-preload-test.js`,
`"${nodeBinary}" --expose_natives_as=v8natives --require "${fixture('cluster-preload.js')}" cluster-preload-test.js`,
function(err, stdout, stderr) {
assert.ifError(err);
assert.ok(/worker terminated with code 43/.test(stdout));
Expand Down
49 changes: 23 additions & 26 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ function error_test() {

client_unix.on('data', function(data) {
read_buffer += data.toString('ascii', 0, data.length);
console.error(
`Unix data: ${JSON.stringify(read_buffer)}, expecting ${
client_unix.expect.exec ?
const expected = client_unix.expect.exec ?
client_unix.expect :
JSON.stringify(client_unix.expect)}`);
JSON.stringify(client_unix.expect);
console.error(
`Unix data: ${JSON.stringify(read_buffer)}, expecting ${expected}`
);

if (read_buffer.includes(prompt_unix)) {
// if it's an exact match, then don't do the regexp
Expand Down Expand Up @@ -267,8 +268,8 @@ function error_test() {
expect: /\bSyntaxError: Invalid or unexpected token/ },
// do not fail when a String is created with line continuation
{ client: client_unix, send: '\'the\\\nfourth\\\neye\'',
expect: `${prompt_multiline}${prompt_multiline}'thefourtheye'\n${
prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}'thefourtheye'\n` +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why split in this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting at \n made sense elsewhere as it made the template literal layout approximate its output, although I can see that maybe it's not needed here.

`${prompt_unix}` },
// Don't fail when a partial String is created and line continuation is used
// with whitespace characters at the end of the string. We are to ignore it.
// This test is to make sure that we properly remove the whitespace
Expand All @@ -277,12 +278,12 @@ function error_test() {
expect: prompt_unix },
// multiline strings preserve whitespace characters in them
{ client: client_unix, send: '\'the \\\n fourth\t\t\\\n eye \'',
expect: `${prompt_multiline}${
prompt_multiline}'the fourth\\t\\t eye '\n${prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}'the fourth\\t\\t eye '\n` +
`${prompt_unix}` },
// more than one multiline strings also should preserve whitespace chars
{ client: client_unix, send: '\'the \\\n fourth\' + \'\t\t\\\n eye \'',
expect: `${prompt_multiline}${
prompt_multiline}'the fourth\\t\\t eye '\n${prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}'the fourth\\t\\t eye '\n` +
`${prompt_unix}` },
// using REPL commands within a string literal should still work
{ client: client_unix, send: '\'\\\n.break',
expect: prompt_unix },
Expand All @@ -294,8 +295,8 @@ function error_test() {
expect: prompt_unix + prompt_unix + prompt_unix },
// empty lines in the string literals should not affect the string
{ client: client_unix, send: '\'the\\\n\\\nfourtheye\'\n',
expect: `${prompt_multiline}${
prompt_multiline}'thefourtheye'\n${prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}'thefourtheye'\n` +
`${prompt_unix}` },
// Regression test for https://github.com/nodejs/node/issues/597
{ client: client_unix,
send: '/(.)(.)(.)(.)(.)(.)(.)(.)(.)/.test(\'123456789\')\n',
Expand All @@ -308,25 +309,25 @@ function error_test() {
'\'7\'\n', '\'8\'\n', '\'9\'\n'].join(`${prompt_unix}`) },
// regression tests for https://github.com/nodejs/node/issues/2749
{ client: client_unix, send: 'function x() {\nreturn \'\\n\';\n }',
expect: `${prompt_multiline}${prompt_multiline}undefined\n${
prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}undefined\n` +
`${prompt_unix}` },
{ client: client_unix, send: 'function x() {\nreturn \'\\\\\';\n }',
expect: `${prompt_multiline}${prompt_multiline}undefined\n${
prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}undefined\n` +
`${prompt_unix}` },
// regression tests for https://github.com/nodejs/node/issues/3421
{ client: client_unix, send: 'function x() {\n//\'\n }',
expect: `${prompt_multiline}${prompt_multiline}undefined\n${
prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}undefined\n` +
`${prompt_unix}` },
{ client: client_unix, send: 'function x() {\n//"\n }',
expect: `${prompt_multiline}${prompt_multiline}undefined\n${
prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}undefined\n` +
`${prompt_unix}` },
{ client: client_unix, send: 'function x() {//\'\n }',
expect: `${prompt_multiline}undefined\n${prompt_unix}` },
{ client: client_unix, send: 'function x() {//"\n }',
expect: `${prompt_multiline}undefined\n${prompt_unix}` },
{ client: client_unix, send: 'function x() {\nvar i = "\'";\n }',
expect: `${prompt_multiline}${prompt_multiline}undefined\n${
prompt_unix}` },
expect: `${prompt_multiline}${prompt_multiline}undefined\n` +
`${prompt_unix}` },
{ client: client_unix, send: 'function x(/*optional*/) {}',
expect: `undefined\n${prompt_unix}` },
{ client: client_unix, send: 'function x(/* // 5 */) {}',
Expand Down Expand Up @@ -453,8 +454,6 @@ function tcp_test() {

client_tcp.on('data', function(data) {
read_buffer += data.toString('ascii', 0, data.length);
console.error(`TCP data: ${JSON.stringify(read_buffer)}, expecting ${
JSON.stringify(client_tcp.expect)}`);
if (read_buffer.includes(prompt_tcp)) {
assert.strictEqual(client_tcp.expect, read_buffer);
console.error('match');
Expand Down Expand Up @@ -523,8 +522,6 @@ function unix_test() {

client_unix.on('data', function(data) {
read_buffer += data.toString('ascii', 0, data.length);
console.error(`Unix data: ${JSON.stringify(read_buffer)}, expecting ${
JSON.stringify(client_unix.expect)}`);
if (read_buffer.includes(prompt_unix)) {
assert.strictEqual(client_unix.expect, read_buffer);
console.error('match');
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-stdout-to-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const tmpFile = path.join(common.tmpDir, 'stdout.txt');
common.refreshTmpDir();

function test(size, useBuffer, cb) {
const cmd = `"${process.argv[0]}" "${
useBuffer ? scriptBuffer : scriptString}" ${size} > "${tmpFile}"`;
const cmd = `"${process.argv[0]}" "${useBuffer ? scriptBuffer : scriptString}" ${size} > "${tmpFile}"`;

try {
fs.unlinkSync(tmpFile);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-ecdh-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const options = {
const server = tls.createServer(options, common.mustNotCall());

server.listen(0, '127.0.0.1', common.mustCall(function() {
let cmd = `"${common.opensslCli}" s_client -cipher ${
options.ciphers} -connect 127.0.0.1:${this.address().port}`;
let cmd =
`"${common.opensslCli}" s_client -cipher ${options.ciphers} -connect 127.0.0.1:${this.address().port}`;

// for the performance and stability issue in s_client on Windows
if (common.isWindows)
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-ecdh.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const server = tls.createServer(options, common.mustCall(function(conn) {
}));

server.listen(0, '127.0.0.1', common.mustCall(function() {
let cmd = `"${common.opensslCli}" s_client -cipher ${
options.ciphers} -connect 127.0.0.1:${this.address().port}`;
let cmd =
`"${common.opensslCli}" s_client -cipher ${options.ciphers} -connect 127.0.0.1:${this.address().port}`;

// for the performance and stability issue in s_client on Windows
if (common.isWindows)
Expand Down
6 changes: 2 additions & 4 deletions test/parallel/test-tls-server-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ function runClient(prefix, port, options, cb) {
`${prefix}${options.name} rejected, but should NOT have been`);
assert.strictEqual(
options.shouldAuth, authed,
`${prefix}${options.name} authed is ${authed} but should have been ${
options.shouldAuth}`);
`${prefix}${options.name} authed is ${authed} but should have been ${options.shouldAuth}`
);
}

cb();
Expand Down Expand Up @@ -312,8 +312,6 @@ function runTest(port, testIndex) {
}

if (c.authorized) {
console.error(`${prefix}- authed connection: ${
c.getPeerCertificate().subject.CN}`);
c.write('\n_authed\n');
} else {
console.error(`${prefix}- unauthed connection: %s`, c.authorizationError);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-set-ciphers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const server = tls.createServer(options, common.mustCall(function(conn) {
}));

server.listen(0, '127.0.0.1', function() {
let cmd = `"${common.opensslCli}" s_client -cipher ${
options.ciphers} -connect 127.0.0.1:${this.address().port}`;
let cmd =
`"${common.opensslCli}" s_client -cipher ${options.ciphers} -connect 127.0.0.1:${this.address().port}`;

// for the performance and stability issue in s_client on Windows
if (common.isWindows)
Expand Down
Loading