From 7ca56ebe2c78d0286e21a589c35ae28275aa8bf7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 2 Jan 2021 13:42:03 -0800 Subject: [PATCH] [eslint] fix some inconsistencies --- .eslintrc | 5 +++++ lib/results.js | 6 +++--- lib/test.js | 11 +++++------ test/async-await.js | 16 ++++++++-------- test/max_listeners/source.js | 2 +- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8ca1d024..db6f0597 100644 --- a/.eslintrc +++ b/.eslintrc @@ -20,6 +20,11 @@ }], "no-undef": "error", "no-useless-escape": "error", + "operator-linebreak": ["error", "before"], + "space-unary-ops": ["error", { + "words": false, + "nonwords": false, + }], "strict": "error", }, "overrides": [ diff --git a/lib/results.js b/lib/results.js index 2be5b2f8..ed1de927 100644 --- a/lib/results.js +++ b/lib/results.js @@ -119,11 +119,11 @@ Results.prototype._watch = function (t) { return; } write(encodeResult(res, self.count + 1)); - self.count ++; + self.count++; - if (res.ok || res.todo) self.pass ++; + if (res.ok || res.todo) self.pass++; else { - self.fail ++; + self.fail++; self.emit('fail'); } }); diff --git a/lib/test.js b/lib/test.js index 4d6182c0..3d70bc5d 100644 --- a/lib/test.js +++ b/lib/test.js @@ -47,7 +47,7 @@ var getTestArgs = function (name_, opts_, cb_) { }; function Test(name_, opts_, cb_) { - if (! (this instanceof Test)) { + if (!(this instanceof Test)) { return new Test(name_, opts_, cb_); } @@ -101,9 +101,9 @@ Test.prototype.run = function () { var callbackReturn = this._cb(this); if ( - typeof Promise === 'function' && - callbackReturn && - typeof callbackReturn.then === 'function' + typeof Promise === 'function' + && callbackReturn + && typeof callbackReturn.then === 'function' ) { var self = this; Promise.resolve(callbackReturn).then(function onResolve() { @@ -205,8 +205,7 @@ Test.prototype._end = function (err) { }; Test.prototype._exit = function () { - if (this._plan !== undefined && - !this._planError && this.assertCount !== this._plan) { + if (this._plan !== undefined && !this._planError && this.assertCount !== this._plan) { this._planError = true; this.fail('plan != count', { expected: this._plan, diff --git a/test/async-await.js b/test/async-await.js index 02aff917..fb8da577 100644 --- a/test/async-await.js +++ b/test/async-await.js @@ -37,7 +37,7 @@ tap.test('async2', function (t) { var stdout = r.stdout.toString('utf8'); var lines = stdout.split('\n'); lines = lines.filter(function (line) { - return ! /^(\s+)at(\s+)$/.test(line); + return !/^(\s+)at(\s+)$/.test(line); }); stdout = lines.join('\n'); @@ -180,9 +180,9 @@ tap.test('sync-error', function (t) { var stderr = r.stderr.toString('utf8'); var lines = stderr.split('\n'); lines = lines.filter(function (line) { - return ! /\(timers.js:/.test(line) && - ! /\(internal\/timers.js:/.test(line) && - ! /Immediate\.next/.test(line); + return !/\(timers.js:/.test(line) + && !/\(internal\/timers.js:/.test(line) + && !/Immediate\.next/.test(line); }); stderr = lines.join('\n'); @@ -207,7 +207,7 @@ tap.test('async-error', function (t) { var stdout = r.stdout.toString('utf8'); var lines = stdout.split('\n'); lines = lines.filter(function (line) { - return ! /^(\s+)at(\s+)$/.test(line); + return !/^(\s+)at(\s+)$/.test(line); }); stdout = lines.join('\n'); @@ -235,9 +235,9 @@ tap.test('async-error', function (t) { var stderr = r.stderr.toString('utf8'); var lines = stderr.split('\n'); lines = lines.filter(function (line) { - return ! /\(timers.js:/.test(line) && - ! /\(internal\/timers.js:/.test(line) && - ! /Immediate\.next/.test(line); + return !/\(timers.js:/.test(line) + && !/\(internal\/timers.js:/.test(line) + && !/Immediate\.next/.test(line); }); stderr = lines.join('\n'); diff --git a/test/max_listeners/source.js b/test/max_listeners/source.js index 0d7613ed..e801853e 100644 --- a/test/max_listeners/source.js +++ b/test/max_listeners/source.js @@ -2,6 +2,6 @@ var test = require('../../'); -for (var i = 0; i < 11; i ++) { +for (var i = 0; i < 11; i++) { test(function (t) { t.ok(true, 'true is truthy'); t.end(); }); }