Skip to content

Commit e30f519

Browse files
TrottMyles Borins
authored andcommitted
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) PR-URL: #5063 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d462550 commit e30f519

16 files changed

+19
-17
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ rules:
8383
space-after-keywords: 2
8484
## no leading/trailing spaces in parens
8585
space-in-parens: [2, "never"]
86+
## no spaces with non-word unary operators, require for word unary operators
87+
space-unary-ops: 2
8688

8789
# ECMAScript 6
8890
# list: http://eslint.org/docs/rules/#ecmascript-6

lib/timers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function unrefdHandle() {
318318
Timeout.prototype.unref = function() {
319319
if (this._handle) {
320320
this._handle.unref();
321-
} else if (typeof(this._onTimeout) === 'function') {
321+
} else if (typeof this._onTimeout === 'function') {
322322
var now = Timer.now();
323323
if (!this._idleStart) this._idleStart = now;
324324
var delay = this._idleStart + this._idleTimeout - now;

test/gc/test-http-client-connaborted.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ for (var i = 0; i < 10; i++)
4848
getall();
4949

5050
function afterGC() {
51-
countGC ++;
51+
countGC++;
5252
}
5353

5454
var timer;

test/gc/test-http-client-onerror.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function runTest() {
5656
}
5757

5858
function afterGC() {
59-
countGC ++;
59+
countGC++;
6060
}
6161

6262
var timer;

test/gc/test-http-client-timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ for (var i = 0; i < 10; i++)
5757
getall();
5858

5959
function afterGC() {
60-
countGC ++;
60+
countGC++;
6161
}
6262

6363
var timer;

test/gc/test-http-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ for (var i = 0; i < 10; i++)
5151
getall();
5252

5353
function afterGC() {
54-
countGC ++;
54+
countGC++;
5555
}
5656

5757
setInterval(status, 1000).unref();

test/gc/test-net-timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ for (var i = 0; i < 10; i++)
5757
getall();
5858

5959
function afterGC() {
60-
countGC ++;
60+
countGC++;
6161
}
6262

6363
setInterval(status, 100).unref();

test/parallel/test-child-process-exec-buffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ var str = 'hello';
1010

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

1717
success_count++;

test/parallel/test-fs-read-stream-inherit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ file.on('close', function() {
5555
var file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
5656
file3.length = 0;
5757
file3.on('data', function(data) {
58-
assert.equal('string', typeof(data));
58+
assert.equal('string', typeof data);
5959
file3.length += data.length;
6060

6161
for (var i = 0; i < data.length; i++) {

test/parallel/test-fs-read-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ file.on('close', function() {
5555
var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
5656
file3.length = 0;
5757
file3.on('data', function(data) {
58-
assert.equal('string', typeof(data));
58+
assert.equal('string', typeof data);
5959
file3.length += data.length;
6060

6161
for (var i = 0; i < data.length; i++) {

0 commit comments

Comments
 (0)