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: enable no-extra-semi rule in eslint #2205

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
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ rules:
no-dupe-keys: 2
## check duplicate switch-case
no-duplicate-case: 2
## disallow superfluous semicolons
no-extra-semi: 2
## disallow assignment of exceptional params
no-ex-assign: 2
## disallow unreachable code
Expand Down
4 changes: 2 additions & 2 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
});
cb(null, mirror);
}
};
}
});
return;
} else if (handle.type === 'function') {
Expand Down Expand Up @@ -800,7 +800,7 @@ function Interface(stdin, stdout, args) {
} else {
self.repl.context[key] = fn;
}
};
}

// Copy all prototype methods in repl context
// Setup them as getters if possible
Expand Down
2 changes: 1 addition & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function listenerCount(type) {
}

return 0;
};
}

// About 1.5x faster than the two-arg version of Array#splice().
function spliceOne(list, index) {
Expand Down
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ function createServerHandle(address, port, addressType, fd) {
}

return handle;
};
}
exports._createServerHandle = createServerHandle;


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

return buff;
};
}

exports.convertNPNProtocols = function(protocols, out) {
// If protocols is Array - translate it into buffer
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function leakedGlobals() {
leaked.push(val);

return leaked;
};
}
exports.leakedGlobals = leakedGlobals;

// Turn this off if the test should not check for global leaks.
Expand Down
2 changes: 1 addition & 1 deletion test/debugger/helper-debugger-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function addTest(input, output) {
} else {
quit();
}
};
}
expected.push({input: input, lines: output, callback: next});
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-spawnsync-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var ret;
function checkSpawnSyncRet(ret) {
assert.strictEqual(ret.status, 0);
assert.strictEqual(ret.error, undefined);
};
}

function verifyBufOutput(ret) {
checkSpawnSyncRet(ret);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-1.0-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function check(tests) {
current++;
if (ctx.expectClose) return;
conn.removeListener('close', onclose);
conn.removeListener('data', ondata);;
conn.removeListener('data', ondata);
connected();
}
conn.on('data', ondata);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-stream-big-packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var passed = false;

function PassThrough() {
stream.Transform.call(this);
};
}
util.inherits(PassThrough, stream.Transform);
PassThrough.prototype._transform = function(chunk, encoding, done) {
this.push(chunk);
Expand All @@ -17,7 +17,7 @@ PassThrough.prototype._transform = function(chunk, encoding, done) {

function TestStream() {
stream.Transform.call(this);
};
}
util.inherits(TestStream, stream.Transform);
TestStream.prototype._transform = function(chunk, encoding, done) {
if (!passed) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-pipe-without-listenerCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ r.on('error', common.mustCall(noop));
w.on('error', common.mustCall(noop));
r.pipe(w);

function noop() {};
function noop() {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var util = require('util');
function MyWritable(fn, options) {
stream.Writable.call(this, options);
this.fn = fn;
};
}

util.inherits(MyWritable, stream.Writable);

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-stream-writable-decoded-encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var util = require('util');
function MyWritable(fn, options) {
stream.Writable.call(this, options);
this.fn = fn;
};
}

util.inherits(MyWritable, stream.Writable);

Expand All @@ -17,7 +17,7 @@ MyWritable.prototype._write = function(chunk, encoding, callback) {
callback();
};

;(function decodeStringsTrue() {
(function decodeStringsTrue() {
var m = new MyWritable(function(isBuffer, type, enc) {
assert(isBuffer);
assert.equal(type, 'object');
Expand All @@ -28,7 +28,7 @@ MyWritable.prototype._write = function(chunk, encoding, callback) {
m.end();
})();

;(function decodeStringsFalse() {
(function decodeStringsFalse() {
var m = new MyWritable(function(isBuffer, type, enc) {
assert(!isBuffer);
assert.equal(type, 'string');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-base64-single-char-read-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ src._read = function(n) {
src.push(new Buffer('1'));
src.push(null);
});
};
}
};

dst._write = function(chunk, enc, cb) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream3-pause-then-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function read100() {
function readn(n, then) {
console.error('read %d', n);
expectEndingData -= n;
;(function read() {
(function read() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say ;( can still be safer, is this avoidable?

Edit: I guess it doesn't matter too much. It's probably best to avoid (function(){})() constructs altogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

We enforce semicolons on the end of each expression, so this one seems unnecessary. Personally, I like using such IIFS to force a scope in ES5.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but since this is node and we operate in modules, where nothing gets exposed to the global scope anyways, isn't that kind of moot?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I don't really have that strong of an opinion here. Carry on.

var c = r.read(n);
if (!c)
r.once('readable', read);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ server.listen(common.PORT, common.localhostIPv4, function() {
if (nbClientsEnded === 2) {
server.close();
}
};
}

const client1 = net.connect({ port: common.PORT });
client1.on('end', addEndedClient);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-alpn-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function runTest(clientsOptions, serverOptions, cb) {
cb(results);
}
});
};
}

}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-npn-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function startTest() {

callback();
});
};
}

connectClient(clientsOptions[0], function() {
connectClient(clientsOptions[1], function() {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-sni-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function startTest() {
else
connectClient(i + 1, callback);
}
};
}

connectClient(0, function() {
server.close();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-sni-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function startTest() {
// Continue
start();
});
};
}

start();
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,6 @@ var throws = [
];
for (var i = 0; i < throws.length; i++) {
assert.throws(function() { url.format(throws[i]); }, TypeError);
};
}
assert(url.format('') === '');
assert(url.format({}) === '');
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-flush-drain.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ deflater.flush(function(err) {
});

deflater.on('drain', function() {
drainCount++;;
drainCount++;
});

process.once('exit', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-tls-server-large-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var options = {
function Mediator() {
stream.Writable.call(this);
this.buf = '';
};
}
util.inherits(Mediator, stream.Writable);

Mediator.prototype._write = function write(data, enc, cb) {
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-child-process-fork-getconnections.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (process.argv[2] === 'child') {
process.on('message', function(m, socket) {
function sendClosed(id) {
process.send({ id: id, status: 'closed'});
};
}

if (m.cmd === 'new') {
assert(socket);
Expand Down Expand Up @@ -82,7 +82,7 @@ if (process.argv[2] === 'child') {
});
sent++;
child.send({ id: i, cmd: 'close' });
};
}

let closeEmitted = false;
server.on('close', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-tcp-wrap-listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ server.onconnection = function(err, client) {
writeCount++;
console.log('write ' + writeCount);
maybeCloseClient();
};
}

sliceCount++;
} else {
Expand Down