From b2bf6c873f4c29fdce6c5b22314327df4e93791e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 27 Apr 2017 17:27:05 -0700 Subject: [PATCH] test,lib,doc: use function declarations Replace function expressions with function declarations in preparation for a lint rule requiring function declarations. Backport-PR-URL: https://github.com/nodejs/node/pull/19447 PR-URL: https://github.com/nodejs/node/pull/12711 Reviewed-By: Vse Mozhet Byt Reviewed-By: Gibson Fahnestock --- test/addons-napi/test_async/test.js | 5 ++--- test/addons-napi/test_exception/test.js | 6 +++--- test/addons-napi/test_instanceof/test.js | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/addons-napi/test_async/test.js b/test/addons-napi/test_async/test.js index 7c140d79fc054f..2b4577624a371e 100644 --- a/test/addons-napi/test_async/test.js +++ b/test/addons-napi/test_async/test.js @@ -6,8 +6,7 @@ const test_async = require(`./build/${common.buildType}/test_async`); test_async.Test(5, common.mustCall(function(err, val) { assert.strictEqual(err, null); assert.strictEqual(val, 10); - process.nextTick(common.mustCall(function() {})); + process.nextTick(common.mustCall()); })); -const cancelSuceeded = function() {}; -test_async.TestCancel(common.mustCall(cancelSuceeded)); +test_async.TestCancel(common.mustCall()); diff --git a/test/addons-napi/test_exception/test.js b/test/addons-napi/test_exception/test.js index 83d2b5000ec54a..94f9566a4b341f 100644 --- a/test/addons-napi/test_exception/test.js +++ b/test/addons-napi/test_exception/test.js @@ -4,12 +4,12 @@ const common = require('../../common'); const test_exception = require(`./build/${common.buildType}/test_exception`); const assert = require('assert'); const theError = new Error('Some error'); -const throwTheError = function() { +function throwTheError() { throw theError; -}; +} let caughtError; -const throwNoError = function() {}; +const throwNoError = common.noop; // Test that the native side successfully captures the exception let returnedError = test_exception.returnException(throwTheError); diff --git a/test/addons-napi/test_instanceof/test.js b/test/addons-napi/test_instanceof/test.js index 38d17031e9a6c9..418149d1909e6f 100644 --- a/test/addons-napi/test_instanceof/test.js +++ b/test/addons-napi/test_instanceof/test.js @@ -57,14 +57,14 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol && (theObject instanceof theConstructor)); } - const MyClass = function MyClass() {}; + function MyClass() {} Object.defineProperty(MyClass, Symbol.hasInstance, { value: function(candidate) { return 'mark' in candidate; } }); - const MySubClass = function MySubClass() {}; + function MySubClass() {} MySubClass.prototype = new MyClass(); let x = new MySubClass();