Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
tools: lint for spacing around unary operators
Enable `space-unary-ops` in `.eslintrc`. This prohibits things like:

    i ++        // use `i++` instead
    typeof(foo) // use `typeof foo` or `typeof (foo)` instead

Ref: #4772 (comment)
  • Loading branch information
Trott committed Feb 3, 2016
commit 363427b12ef9b5af82c61115bc19e77aee601b59
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ rules:
space-after-keywords: 2
## no leading/trailing spaces in parens
space-in-parens: [2, "never"]
## no spaces with non-word unary operators, require for word unary operators
space-unary-ops: [2]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

style: we don't use an array to just enable the rules


# ECMAScript 6
# list: http://eslint.org/docs/rules/#ecmascript-6
Expand Down
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function unrefdHandle() {
Timeout.prototype.unref = function() {
if (this._handle) {
this._handle.unref();
} else if (typeof(this._onTimeout) === 'function') {
} else if (typeof this._onTimeout === 'function') {
var now = Timer.now();
if (!this._idleStart) this._idleStart = now;
var delay = this._idleStart + this._idleTimeout - now;
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 @@ -48,7 +48,7 @@ for (var i = 0; i < 10; i++)
getall();

function afterGC() {
countGC ++;
countGC++;
}

var timer;
Expand Down
2 changes: 1 addition & 1 deletion test/gc/test-http-client-onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function runTest() {
}

function afterGC() {
countGC ++;
countGC++;
}

var timer;
Expand Down
2 changes: 1 addition & 1 deletion test/gc/test-http-client-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for (var i = 0; i < 10; i++)
getall();

function afterGC() {
countGC ++;
countGC++;
}

var timer;
Expand Down
2 changes: 1 addition & 1 deletion test/gc/test-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ for (var i = 0; i < 10; i++)
getall();

function afterGC() {
countGC ++;
countGC++;
}

setInterval(status, 1000).unref();
Expand Down
2 changes: 1 addition & 1 deletion test/gc/test-net-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for (var i = 0; i < 10; i++)
getall();

function afterGC() {
countGC ++;
countGC++;
}

setInterval(status, 100).unref();
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-child-process-exec-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var str = 'hello';

// default encoding
exec('echo ' + str, function(err, stdout, stderr) {
assert.ok('string', typeof(stdout), 'Expected stdout to be a string');
assert.ok('string', typeof(stderr), 'Expected stderr to be a string');
assert.ok('string', typeof stdout, 'Expected stdout to be a string');
assert.ok('string', typeof stderr, 'Expected stderr to be a string');
assert.equal(str + os.EOL, stdout);

success_count++;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-read-stream-inherit.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ file.on('close', function() {
var file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
file3.length = 0;
file3.on('data', function(data) {
assert.equal('string', typeof(data));
assert.equal('string', typeof data);
file3.length += data.length;

for (var i = 0; i < data.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-read-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ file.on('close', function() {
var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
file3.length = 0;
file3.on('data', function(data) {
assert.equal('string', typeof(data));
assert.equal('string', typeof data);
file3.length += data.length;

for (var i = 0; i < data.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-byteswritten.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var httpServer = http.createServer(function(req, res) {

res.on('finish', function() {
sawFinish = true;
assert(typeof(req.connection.bytesWritten) === 'number');
assert(typeof req.connection.bytesWritten === 'number');
assert(req.connection.bytesWritten > 0);
});
res.writeHead(200, { 'Content-Type': 'text/plain' });
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-date-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var http = require('http');
var testResBody = 'other stuff!\n';

var server = http.createServer(function(req, res) {
assert.ok(! ('date' in req.headers),
assert.ok(!('date' in req.headers),
'Request headers contained a Date.');
res.writeHead(200, {
'Content-Type': 'text/plain'
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-response-multiheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ server.listen(common.PORT, common.mustCall(function() {
http.get(
{port:common.PORT, headers:{'x-num': n}},
common.mustCall(function(res) {
if (++ count === 2) server.close();
if (++count === 2) server.close();
assert.equal(res.headers['content-length'], 1);
for (const name of norepeat) {
assert.equal(res.headers[name], 'A');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-set-trailers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ server.on('listening', function() {

c.on('end', function() {
c.end();
assert.ok(! /x-foo/.test(res_buffer), 'Trailer in HTTP/1.0 response.');
assert.ok(!/x-foo/.test(res_buffer), 'Trailer in HTTP/1.0 response.');
outstanding_reqs--;
if (outstanding_reqs == 0) {
server.close();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-byteswritten.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var body = 'hello world\n';

var httpsServer = https.createServer(options, function(req, res) {
res.on('finish', function() {
assert(typeof(req.connection.bytesWritten) === 'number');
assert(typeof req.connection.bytesWritten === 'number');
assert(req.connection.bytesWritten > 0);
httpsServer.close();
console.log('ok');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-vm-debug-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ assert.throws(function() {
vm.runInDebugContext('(function(f) { f(f) })(function(f) { f(f) })');
}, /RangeError/);

assert.equal(typeof(vm.runInDebugContext('this')), 'object');
assert.equal(typeof(vm.runInDebugContext('Debug')), 'object');
assert.equal(typeof vm.runInDebugContext('this'), 'object');
assert.equal(typeof vm.runInDebugContext('Debug'), 'object');

assert.strictEqual(vm.runInDebugContext(), undefined);
assert.strictEqual(vm.runInDebugContext(0), 0);
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-cluster-listening-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (cluster.isMaster) {
// ensure that the port is not 0 or null
assert(port);
// ensure that the port is numerical
assert.strictEqual(typeof(port), 'number');
assert.strictEqual(typeof port, 'number');
worker.kill();
});
process.on('exit', function() {
Expand Down