tools: use no-useless-concat ESLint rule

* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: https://github.com/nodejs/node/pull/12613
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
Vse Mozhet Byt 2017-04-24 01:16:24 +03:00
Родитель 20987752a2
Коммит 71abfa9548
8 изменённых файлов: 20 добавлений и 23 удалений

Просмотреть файл

@ -49,6 +49,7 @@ rules:
no-throw-literal: 2 no-throw-literal: 2
no-unused-labels: 2 no-unused-labels: 2
no-useless-call: 2 no-useless-call: 2
no-useless-concat: 2
no-useless-escape: 2 no-useless-escape: 2
no-useless-return: 2 no-useless-return: 2
no-void: 2 no-void: 2

Просмотреть файл

@ -93,11 +93,10 @@ function createTestCmdLine(options) {
testCmd += process.argv[0]; testCmd += process.argv[0];
if (options && options.withAbortOnUncaughtException) { if (options && options.withAbortOnUncaughtException) {
testCmd += ' ' + '--abort-on-uncaught-exception'; testCmd += ' --abort-on-uncaught-exception';
} }
testCmd += ' ' + process.argv[1]; testCmd += ` ${process.argv[1]} child`;
testCmd += ' ' + 'child';
return testCmd; return testCmd;
} }

Просмотреть файл

@ -4,8 +4,8 @@ const http = require('http');
const testServer = http.createServer(common.mustNotCall()); const testServer = http.createServer(common.mustNotCall());
testServer.on('connect', common.mustCall((req, socket, head) => { testServer.on('connect', common.mustCall((req, socket, head) => {
socket.write('HTTP/1.1 200 Connection Established' + '\r\n' + socket.write('HTTP/1.1 200 Connection Established\r\n' +
'Proxy-agent: Node-Proxy' + '\r\n' + 'Proxy-agent: Node-Proxy\r\n' +
'\r\n'); '\r\n');
// This shouldn't raise an assertion in StreamBase::Consume. // This shouldn't raise an assertion in StreamBase::Consume.
testServer.emit('connection', socket); testServer.emit('connection', socket);

Просмотреть файл

@ -30,7 +30,7 @@ let outstanding_reqs = 0;
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
res.writeHead(200, [['content-type', 'text/plain']]); res.writeHead(200, [['content-type', 'text/plain']]);
res.addTrailers({'x-foo': 'bar'}); res.addTrailers({'x-foo': 'bar'});
res.end('stuff' + '\n'); res.end('stuff\n');
}); });
server.listen(0); server.listen(0);

Просмотреть файл

@ -33,7 +33,7 @@ const server = net.createServer(function(socket) {
conn.setEncoding('utf8'); conn.setEncoding('utf8');
conn.write('before'); conn.write('before');
conn.on('connect', function() { conn.on('connect', function() {
conn.write('after'); conn.write(' after');
}); });
conn.on('data', function(buf) { conn.on('data', function(buf) {
received += buf; received += buf;
@ -41,6 +41,6 @@ const server = net.createServer(function(socket) {
}); });
conn.on('end', common.mustCall(function() { conn.on('end', common.mustCall(function() {
server.close(); server.close();
assert.strictEqual(received, 'before' + 'after'); assert.strictEqual(received, 'before after');
})); }));
})); }));

Просмотреть файл

@ -128,7 +128,7 @@ interactive.stdin.write('a\n');
interactive.stdin.write('process.exit()\n'); interactive.stdin.write('process.exit()\n');
childProcess.exec( childProcess.exec(
nodeBinary + ' ' + '--require ' + fixture('cluster-preload.js') + ' ' + `${nodeBinary} --require ${fixture('cluster-preload.js')} ` +
fixture('cluster-preload-test.js'), fixture('cluster-preload-test.js'),
function(err, stdout, stderr) { function(err, stdout, stderr) {
assert.ifError(err); assert.ifError(err);
@ -139,8 +139,8 @@ childProcess.exec(
// https://github.com/nodejs/node/issues/1691 // https://github.com/nodejs/node/issues/1691
process.chdir(common.fixturesDir); process.chdir(common.fixturesDir);
childProcess.exec( childProcess.exec(
nodeBinary + ' ' + '--expose_natives_as=v8natives ' + '--require ' + `${nodeBinary} --expose_natives_as=v8natives --require ` +
fixture('cluster-preload.js') + ' ' + 'cluster-preload-test.js', `${fixture('cluster-preload.js')} cluster-preload-test.js`,
function(err, stdout, stderr) { function(err, stdout, stderr) {
assert.ifError(err); assert.ifError(err);
assert.ok(/worker terminated with code 43/.test(stdout)); assert.ok(/worker terminated with code 43/.test(stdout));

Просмотреть файл

@ -442,12 +442,12 @@ function tcp_test() {
{ client: client_tcp, send: '', { client: client_tcp, send: '',
expect: prompt_tcp }, expect: prompt_tcp },
{ client: client_tcp, send: 'invoke_me(333)', { client: client_tcp, send: 'invoke_me(333)',
expect: ('\'' + 'invoked 333' + '\'\n' + prompt_tcp) }, expect: (`'invoked 333'\n${prompt_tcp}`) },
{ client: client_tcp, send: 'a += 1', { client: client_tcp, send: 'a += 1',
expect: ('12346' + '\n' + prompt_tcp) }, expect: (`12346\n${prompt_tcp}`) },
{ client: client_tcp, { client: client_tcp,
send: 'require(' + JSON.stringify(moduleFilename) + ').number', send: 'require(' + JSON.stringify(moduleFilename) + ').number',
expect: ('42' + '\n' + prompt_tcp) } expect: (`42\n${prompt_tcp}`) }
]); ]);
}); });
@ -511,13 +511,13 @@ function unix_test() {
{ client: client_unix, send: '', { client: client_unix, send: '',
expect: prompt_unix }, expect: prompt_unix },
{ client: client_unix, send: 'message', { client: client_unix, send: 'message',
expect: ('\'' + message + '\'\n' + prompt_unix) }, expect: (`'${message}'\n${prompt_unix}`) },
{ client: client_unix, send: 'invoke_me(987)', { client: client_unix, send: 'invoke_me(987)',
expect: ('\'' + 'invoked 987' + '\'\n' + prompt_unix) }, expect: (`'invoked 987'\n${prompt_unix}`) },
{ client: client_unix, send: 'a = 12345', { client: client_unix, send: 'a = 12345',
expect: ('12345' + '\n' + prompt_unix) }, expect: (`12345\n${prompt_unix}`) },
{ client: client_unix, send: '{a:1}', { client: client_unix, send: '{a:1}',
expect: ('{ a: 1 }' + '\n' + prompt_unix) } expect: (`{ a: 1 }\n${prompt_unix}`) }
]); ]);
}); });

Просмотреть файл

@ -239,11 +239,8 @@ if (process.argv[2] === 'child') {
testCmd += 'ulimit -c 0 && '; testCmd += 'ulimit -c 0 && ';
} }
testCmd += process.argv[0]; testCmd += `${process.argv[0]} --abort-on-uncaught-exception ` +
testCmd += ' ' + '--abort-on-uncaught-exception'; `${process.argv[1]} child ${testIndex}`;
testCmd += ' ' + process.argv[1];
testCmd += ' ' + 'child';
testCmd += ' ' + testIndex;
const child = child_process.exec(testCmd); const child = child_process.exec(testCmd);