From 75c0c3a4f9452c36b5318ba6c09ab4ebc97f15d0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 19 Sep 2022 10:48:21 -0700 Subject: [PATCH] [eslint] enable `func-style` --- .eslintrc | 3 ++- index.js | 8 ++++---- lib/results.js | 4 ++-- lib/test.js | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6e61464a..4d02509e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,7 +12,7 @@ "rules": { "array-bracket-spacing": "off", "complexity": "off", - "func-style": "warn", + "func-style": ["error", "declaration"], "max-lines-per-function": "warn", "max-lines": "warn", "max-statements-per-line": [2, { "max": 2 }], @@ -107,6 +107,7 @@ "allowKeywords": true, "allowPattern": "throws" }], + "func-style": "off", "id-length": "off", "max-len": "off", "max-lines-per-function": "off", diff --git a/index.js b/index.js index 2d2d2e53..1a11e3ca 100644 --- a/index.js +++ b/index.js @@ -23,10 +23,10 @@ module.exports = (function () { return harness; } - var lazyLoad = function () { + function lazyLoad() { // eslint-disable-next-line no-invalid-this return getHarness().apply(this, arguments); - }; + } lazyLoad.only = function () { return getHarness().only.apply(this, arguments); @@ -61,7 +61,7 @@ function createHarness(conf_) { results.once('done', function () { results.close(); }); } - var test = function (name, conf, cb) { + function test(name, conf, cb) { var t = new Test(name, conf, cb); test._tests.push(t); @@ -76,7 +76,7 @@ function createHarness(conf_) { results.push(t); return t; - }; + } test._results = results; test._tests = []; diff --git a/lib/results.js b/lib/results.js index 2460a712..23fc0734 100644 --- a/lib/results.js +++ b/lib/results.js @@ -174,7 +174,7 @@ Results.prototype.only = function (t) { Results.prototype._watch = function (t) { var self = this; - var write = function (s) { self._stream.queue(s); }; + function write(s) { self._stream.queue(s); } t.once('prerun', function () { var premsg = ''; if (t._skip) { @@ -208,7 +208,7 @@ Results.prototype.close = function () { var self = this; if (self.closed) { self._stream.emit('error', new Error('ALREADY CLOSED')); } self.closed = true; - var write = function (s) { self._stream.queue(s); }; + function write(s) { self._stream.queue(s); } write('\n1..' + self.count + '\n'); write('# tests ' + self.count + '\n'); diff --git a/lib/test.js b/lib/test.js index c43b57a4..596f83a5 100644 --- a/lib/test.js +++ b/lib/test.js @@ -23,7 +23,7 @@ var safeSetTimeout = setTimeout; var safeClearTimeout = clearTimeout; // eslint-disable-next-line no-unused-vars -var getTestArgs = function (name_, opts_, cb_) { +function getTestArgs(name_, opts_, cb_) { var name = '(anonymous)'; var opts = {}; var cb; @@ -44,7 +44,7 @@ var getTestArgs = function (name_, opts_, cb_) { opts: opts, cb: cb }; -}; +} function Test(name_, opts_, cb_) { if (!(this instanceof Test)) { @@ -387,6 +387,7 @@ Test.prototype.skip = function (msg, extra) { }); }; +// eslint-disable-next-line func-style var tapeAssert = function assert(value, msg, extra) { this._assert(value, { message: defined(msg, 'should be truthy'),