Skip to content

tools: disallow multiple spaces except for indentation #6645

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

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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rules:
# Best Practices
# http://eslint.org/docs/rules/#best-practices
no-fallthrough: 2
no-multi-spaces: 2
no-octal: 2
no-redeclare: 2
no-self-assign: 2
Expand Down
8 changes: 4 additions & 4 deletions benchmark/buffers/buffer-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var bench = common.createBenchmark(main, {
millions: [1]
});

const INT8 = 0x7f;
const INT16 = 0x7fff;
const INT32 = 0x7fffffff;
const UINT8 = (INT8 * 2) + 1;
const INT8 = 0x7f;
const INT16 = 0x7fff;
const INT32 = 0x7fffffff;
const UINT8 = (INT8 * 2) + 1;
const UINT16 = (INT16 * 2) + 1;
const UINT32 = INT32;

Expand Down
8 changes: 4 additions & 4 deletions benchmark/buffers/dataview-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ var bench = common.createBenchmark(main, {
millions: [1]
});

const INT8 = 0x7f;
const INT16 = 0x7fff;
const INT32 = 0x7fffffff;
const UINT8 = INT8 * 2;
const INT8 = 0x7f;
const INT16 = 0x7fff;
const INT32 = 0x7fffffff;
const UINT8 = INT8 * 2;
const UINT16 = INT16 * 2;
const UINT32 = INT32 * 2;

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
`the new one i.e., ${historyPath} and is empty.\nUsing it as is.\n`);
repl._refreshLine();

} else if (oldHistoryPath) {
} else if (oldHistoryPath) {
// Grab data from the older pre-v3.0 JSON NODE_REPL_HISTORY_FILE format.
repl._writeToOutput(
'\nConverting old JSON repl history to line-separated history.\n' +
Expand Down
4 changes: 2 additions & 2 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ const win32 = {
end = i;
break;
}
} else {
} else {
// We saw the first non-path separator
matchedSlash = false;
}
Expand Down Expand Up @@ -1335,7 +1335,7 @@ const posix = {
end = i;
break;
}
} else {
} else {
// We saw the first non-path separator
matchedSlash = false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ QueryString.unescapeBuffer = function(s, decodeSpaces) {
case 2: // Second hex digit
state = 0;
if (c >= 48/*0*/ && c <= 57/*9*/) {
m = c - 48/*0*/;
m = c - 48/*0*/;
} else if (c >= 65/*A*/ && c <= 70/*F*/) {
m = c - 65/*A*/ + 10;
} else if (c >= 97/*a*/ && c <= 102/*f*/) {
Expand Down
2 changes: 1 addition & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class LineParser {

this.shouldFail = this.shouldFail ||
((!this._literal && lastChar === '\\') ||
(this._literal && lastChar !== '\\'));
(this._literal && lastChar !== '\\'));

return line;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function convertProtocols(protocols) {
return buff;
}

exports.convertNPNProtocols = function(protocols, out) {
exports.convertNPNProtocols = function(protocols, out) {
// If protocols is Array - translate it into buffer
if (Array.isArray(protocols)) {
protocols = convertProtocols(protocols);
Expand Down
8 changes: 4 additions & 4 deletions test/addons/buffer-free-callback/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ check(64, 1, 0);
check(97, 1, 0);

// Buffers can be unaligned
check(64, 8, 0);
check(64, 8, 0);
check(64, 16, 0);
check(64, 8, 1);
check(64, 8, 1);
check(64, 16, 1);
check(97, 8, 1);
check(97, 8, 1);
check(97, 16, 1);
check(97, 8, 3);
check(97, 8, 3);
check(97, 16, 3);

// Empty ArrayBuffer does not allocate data, worth checking
Expand Down
2 changes: 1 addition & 1 deletion test/gc/test-http-client-connaborted.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function serverHandler(req, res) {
res.connection.destroy();
}

const http = require('http');
const http = require('http');
const weak = require('weak');
const common = require('../common');
const assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
[ 'utf9',
'utf-7',
'Unicode-FTW',
'new gnu gun' ].forEach(function(enc) {
'new gnu gun' ].forEach(function(enc) {
assert.equal(Buffer.isEncoding(enc), false);
});

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('../common');
var assert = require('assert');

var zero = [];
var one = [ Buffer.from('asdf') ];
var one = [ Buffer.from('asdf') ];
var long = [];
for (var i = 0; i < 10; i++) long.push(Buffer.from('asdf'));

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-includes.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ assert(!mixedByteStringUtf8.includes('\u0396'));
// Long string that isn't a simple repeat of a shorter string.
var longString = 'A';
for (let i = 66; i < 76; i++) { // from 'B' to 'K'
longString = longString + String.fromCharCode(i) + longString;
longString = longString + String.fromCharCode(i) + longString;
}

const longBufferString = Buffer.from(longString);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-indexof.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ assert.equal(-1, mixedByteStringUtf8.indexOf('\u0396'));
// Long string that isn't a simple repeat of a shorter string.
var longString = 'A';
for (let i = 66; i < 76; i++) { // from 'B' to 'K'
longString = longString + String.fromCharCode(i) + longString;
longString = longString + String.fromCharCode(i) + longString;
}

var longBufferString = Buffer.from(longString);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ Buffer(Buffer(0), 0, 0);
[ 'utf9',
'utf-7',
'Unicode-FTW',
'new gnu gun' ].forEach(function(enc) {
'new gnu gun' ].forEach(function(enc) {
assert.equal(Buffer.isEncoding(enc), false);
});

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-crypto-fips.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function testHelper(stream, args, expectedOutput, cmd, env) {
cmd + ' and args \'' + args + '\'');

function childOk(child) {
console.error('Child #' + ++num_children_ok +
console.error('Child #' + ++num_children_ok +
' [pid:' + child.pid + '] OK.');
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-crypto-padding-aes256.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';

function aes256(decipherFinal) {
var iv = Buffer.from('00000000000000000000000000000000', 'hex');
var iv = Buffer.from('00000000000000000000000000000000', 'hex');
var key = Buffer.from('0123456789abcdef0123456789abcdef' +
'0123456789abcdef0123456789abcdef', 'hex');

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-dgram-send-bad-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ assert.throws(function() {
}, TypeError); // First argument should be a buffer.

// send(buf, offset, length, port, host)
assert.throws(function() { sock.send(buf, 1, 1, -1, host); }, RangeError);
assert.throws(function() { sock.send(buf, 1, 1, 0, host); }, RangeError);
assert.throws(function() { sock.send(buf, 1, 1, -1, host); }, RangeError);
assert.throws(function() { sock.send(buf, 1, 1, 0, host); }, RangeError);
assert.throws(function() { sock.send(buf, 1, 1, 65536, host); }, RangeError);

// send(buf, port, host)
assert.throws(function() { sock.send(23, 12345, host); }, TypeError);
assert.throws(function() { sock.send(23, 12345, host); }, TypeError);

// send([buf1, ..], port, host)
assert.throws(function() { sock.send([buf, 23], 12345, host); }, TypeError);
2 changes: 1 addition & 1 deletion test/parallel/test-domain-abort-on-uncaught.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ if (process.argv[2] === 'child') {
testCmd += 'ulimit -c 0 && ';
}

testCmd += process.argv[0];
testCmd += process.argv[0];
testCmd += ' ' + '--abort-on-uncaught-exception';
testCmd += ' ' + process.argv[1];
testCmd += ' ' + 'child';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ if (process.argv[2] === 'child') {
testCmd += 'ulimit -c 0 && ';
}

testCmd += process.argv[0];
testCmd += process.argv[0];
testCmd += ' ' + '--abort-on-uncaught-exception';
testCmd += ' ' + process.argv[1];
testCmd += ' ' + 'child';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if (process.argv[2] === 'child') {
if (options.useTryCatch)
useTryCatchOpt = 'useTryCatch';

cmdToExec += process.argv[0] + ' ';
cmdToExec += process.argv[0] + ' ';
cmdToExec += (cmdLineOption ? cmdLineOption : '') + ' ';
cmdToExec += process.argv[1] + ' ';
cmdToExec += [
Expand Down
54 changes: 27 additions & 27 deletions test/parallel/test-fs-null-bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ function check(async, sync) {
async.apply(null, argsAsync);
}

check(fs.access, fs.accessSync, 'foo\u0000bar');
check(fs.access, fs.accessSync, 'foo\u0000bar', fs.F_OK);
check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar');
check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644');
check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34);
check(fs.link, fs.linkSync, 'foo\u0000bar', 'foobar');
check(fs.link, fs.linkSync, 'foobar', 'foo\u0000bar');
check(fs.lstat, fs.lstatSync, 'foo\u0000bar');
check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755');
check(fs.open, fs.openSync, 'foo\u0000bar', 'r');
check(fs.readFile, fs.readFileSync, 'foo\u0000bar');
check(fs.readdir, fs.readdirSync, 'foo\u0000bar');
check(fs.readlink, fs.readlinkSync, 'foo\u0000bar');
check(fs.realpath, fs.realpathSync, 'foo\u0000bar');
check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar');
check(fs.rename, fs.renameSync, 'foobar', 'foo\u0000bar');
check(fs.rmdir, fs.rmdirSync, 'foo\u0000bar');
check(fs.stat, fs.statSync, 'foo\u0000bar');
check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar');
check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar');
check(fs.truncate, fs.truncateSync, 'foo\u0000bar');
check(fs.unlink, fs.unlinkSync, 'foo\u0000bar');
check(null, fs.unwatchFile, 'foo\u0000bar', common.fail);
check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0);
check(null, fs.watch, 'foo\u0000bar', common.fail);
check(null, fs.watchFile, 'foo\u0000bar', common.fail);
check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar');
check(fs.access, fs.accessSync, 'foo\u0000bar');
check(fs.access, fs.accessSync, 'foo\u0000bar', fs.F_OK);
check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar');
check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644');
check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34);
check(fs.link, fs.linkSync, 'foo\u0000bar', 'foobar');
check(fs.link, fs.linkSync, 'foobar', 'foo\u0000bar');
check(fs.lstat, fs.lstatSync, 'foo\u0000bar');
check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755');
check(fs.open, fs.openSync, 'foo\u0000bar', 'r');
check(fs.readFile, fs.readFileSync, 'foo\u0000bar');
check(fs.readdir, fs.readdirSync, 'foo\u0000bar');
check(fs.readlink, fs.readlinkSync, 'foo\u0000bar');
check(fs.realpath, fs.realpathSync, 'foo\u0000bar');
check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar');
check(fs.rename, fs.renameSync, 'foobar', 'foo\u0000bar');
check(fs.rmdir, fs.rmdirSync, 'foo\u0000bar');
check(fs.stat, fs.statSync, 'foo\u0000bar');
check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar');
check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar');
check(fs.truncate, fs.truncateSync, 'foo\u0000bar');
check(fs.unlink, fs.unlinkSync, 'foo\u0000bar');
check(null, fs.unwatchFile, 'foo\u0000bar', common.fail);
check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0);
check(null, fs.watch, 'foo\u0000bar', common.fail);
check(null, fs.watchFile, 'foo\u0000bar', common.fail);
check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar');

// an 'error' for exists means that it doesn't exist.
// one of many reasons why this file is the absolute worst.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-agent-session-eviction.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ https.createServer(options, function(req, res) {
});

// Do request and let agent cache the session
function first(server) {
function first(server) {
const req = https.request({
port: common.PORT,
rejectUnauthorized: false
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-regress-GH-7511.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const vm = require('vm');

assert.doesNotThrow(function() {
var context = vm.createContext({ process: process });
var result = vm.runInContext('process.env["PATH"]', context);
var result = vm.runInContext('process.env["PATH"]', context);
assert.notEqual(undefined, result);
});
2 changes: 1 addition & 1 deletion test/parallel/test-repl-domain.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var common = require('../common');

var repl = require('repl');
var repl = require('repl');

const putIn = new common.ArrayStream();
repl.start('', putIn);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ test('end callback after .write() call', function(t) {
test('end callback called after write callback', function(t) {
var tw = new TestWriter();
var writeCalledback = false;
tw.write(Buffer.from('hello world'), function() {
tw.write(Buffer.from('hello world'), function() {
writeCalledback = true;
});
tw.end(function() {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-string-decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test(
test('ucs2', Buffer.from('ababc', 'ucs2'), 'ababc');

// UTF-16LE
test('ucs2', Buffer.from('3DD84DDC', 'hex'), '\ud83d\udc4d'); // thumbs up
test('ucs2', Buffer.from('3DD84DDC', 'hex'), '\ud83d\udc4d'); // thumbs up

console.log(' crayon!');

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-client-getephemeralkeyinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (!common.hasCrypto) {
var tls = require('tls');

var fs = require('fs');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');

var ntests = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-client-mindhsize.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (!common.hasCrypto) {
var tls = require('tls');

var fs = require('fs');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');

var nsuccess = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-dhe.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var tls = require('tls');

var spawn = require('child_process').spawn;
var fs = require('fs');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');
var nsuccess = 0;
var ntests = 0;
Expand Down
4 changes: 2 additions & 2 deletions test/timers/test-timers-reliability.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

require('../common');

var Timer = process.binding('timer_wrap').Timer;
var Timer = process.binding('timer_wrap').Timer;
var assert = require('assert');

var timerFired = false;
var timerFired = false;
var intervalFired = false;

/*
Expand Down