Skip to content

Commit

Permalink
Fix lint violtions for no-empty-function
Browse files Browse the repository at this point in the history
  • Loading branch information
mroderick committed Oct 8, 2018
1 parent 9e3db95 commit e0b7240
Show file tree
Hide file tree
Showing 20 changed files with 241 additions and 233 deletions.
4 changes: 3 additions & 1 deletion lib/sinon/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ assert = {
throw error;
},

pass: function pass() {},
pass: function pass() {
return;
},

callOrder: function assertCallOrder() {
verifyIsStub.apply(null, arguments);
Expand Down
8 changes: 6 additions & 2 deletions lib/sinon/spy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function spy(object, property, types) {
}

if (!object && !property) {
return spy.create(function () {});
return spy.create(function () {
return;
});
}

if (!types) {
Expand Down Expand Up @@ -150,7 +152,9 @@ var spyApi = {
var name;

if (typeof func !== "function") {
func = function () { };
func = function () {
return;
};
} else {
name = functionName(func);
}
Expand Down
34 changes: 17 additions & 17 deletions test/assert-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe("assert", function () {
});

it("supports proxy property", function () {
var api = { method: function () {} };
api.method.proxy = function () {};
var api = { method: function () { return; } };
api.method.proxy = function () { return; };
sinonSpy(api, "method");
api.method();

Expand Down Expand Up @@ -114,7 +114,7 @@ describe("assert", function () {

it("fails when method is not stub", function () {
assert.exception(function () {
sinonAssert.called(function () {});
sinonAssert.called(function () { return; });
});

assert(sinonAssert.fail.called);
Expand Down Expand Up @@ -176,7 +176,7 @@ describe("assert", function () {

it("fails when method is not stub", function () {
assert.exception(function () {
sinonAssert.notCalled(function () {});
sinonAssert.notCalled(function () { return; });
});

assert(sinonAssert.fail.called);
Expand Down Expand Up @@ -234,7 +234,7 @@ describe("assert", function () {

it("fails when method is not stub", function () {
assert.exception(function () {
sinonAssert.calledOnce(function () {});
sinonAssert.calledOnce(function () { return; });
});

assert(sinonAssert.fail.called);
Expand Down Expand Up @@ -502,7 +502,7 @@ describe("assert", function () {
sinonStub(this.stub, "calledOn");

assert.exception(function () {
sinonAssert.calledOn(function () {}, object);
sinonAssert.calledOn(function () { return; }, object);
});

assert.isFalse(this.stub.calledOn.calledWith(object));
Expand Down Expand Up @@ -583,7 +583,7 @@ describe("assert", function () {
sinonStub(this.stub, "calledWithNew");

assert.exception(function () {
sinonAssert.calledWithNew(function () {});
sinonAssert.calledWithNew(function () { return; });
});

assert.isFalse(this.stub.calledWithNew.called);
Expand Down Expand Up @@ -659,7 +659,7 @@ describe("assert", function () {
sinonStub(this.stub, "alwaysCalledWithNew");

assert.exception(function () {
sinonAssert.alwaysCalledWithNew(function () {});
sinonAssert.alwaysCalledWithNew(function () { return; });
});

assert.isFalse(this.stub.alwaysCalledWithNew.called);
Expand Down Expand Up @@ -952,7 +952,7 @@ describe("assert", function () {

it("fails if method is not fake", function () {
assert.exception(function () {
sinonAssert.alwaysCalledOn(function () {}, {});
sinonAssert.alwaysCalledOn(function () { return; }, {});
});
});

Expand Down Expand Up @@ -1005,7 +1005,7 @@ describe("assert", function () {

it("fails if method is not fake", function () {
assert.exception(function () {
sinonAssert.alwaysCalledWith(function () {});
sinonAssert.alwaysCalledWith(function () { return; });
});
});

Expand Down Expand Up @@ -1163,7 +1163,7 @@ describe("assert", function () {
describe("message", function () {
beforeEach(function () {
this.obj = {
doSomething: function () {}
doSomething: function () { return; }
};

sinonSpy(this.obj, "doSomething");
Expand Down Expand Up @@ -1217,7 +1217,7 @@ describe("assert", function () {
});

it("assert.callOrder exception message", function () {
var obj = { doop: function () {}, foo: function () {} };
var obj = { doop: function () { return; }, foo: function () { return; } };
sinonSpy(obj, "doop");
sinonSpy(obj, "foo");

Expand All @@ -1233,7 +1233,7 @@ describe("assert", function () {
});

it("assert.callOrder with missing first call exception message", function () {
var obj = { doop: function () {}, foo: function () {} };
var obj = { doop: function () { return; }, foo: function () { return; } };
sinonSpy(obj, "doop");
sinonSpy(obj, "foo");

Expand All @@ -1247,7 +1247,7 @@ describe("assert", function () {
});

it("assert.callOrder with missing last call exception message", function () {
var obj = { doop: function () {}, foo: function () {} };
var obj = { doop: function () { return; }, foo: function () { return; } };
sinonSpy(obj, "doop");
sinonSpy(obj, "foo");

Expand Down Expand Up @@ -1505,7 +1505,7 @@ describe("assert", function () {

it("assert.calledWith match.instanceOf exception message", function () {
this.obj.doSomething();
var matcher = sinonMatch.instanceOf(function CustomType() {});
var matcher = sinonMatch.instanceOf(function CustomType() { return; });

assert.equals(
this.message("calledWith", this.obj.doSomething, matcher).replace(/ at.*/g, ""),
Expand Down Expand Up @@ -1553,7 +1553,7 @@ describe("assert", function () {

it("assert.calledWith match test function exception message", function () {
this.obj.doSomething();
var matcher = sinonMatch({ test: function custom() {} });
var matcher = sinonMatch({ test: function custom() { return; } });

assert.equals(
this.message("calledWith", this.obj.doSomething, matcher).replace(/ at.*/g, ""),
Expand Down Expand Up @@ -1673,7 +1673,7 @@ describe("assert", function () {
var obj = {};

function setupSymbol(symbol) {
obj[symbol] = function () {};
obj[symbol] = function () { return; };
sinonSpy(obj, symbol);
}

Expand Down
30 changes: 15 additions & 15 deletions test/call-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var refute = referee.refute;
function spyCallSetUp() {
this.thisValue = {};
this.args = [{}, [], new Error(), 3];
this.returnValue = function () {};
this.call = sinonSpyCall(function () {}, this.thisValue,
this.returnValue = function () { return; };
this.call = sinonSpyCall(function () { return; }, this.thisValue,
this.args, this.returnValue, null, 0);
}

Expand Down Expand Up @@ -121,14 +121,14 @@ describe("sinonSpy.call", function () {
});

it("stores given call id", function () {
var call = sinonSpyCall(function () {}, {}, [], null, null, 42);
var call = sinonSpyCall(function () { return; }, {}, [], null, null, 42);

assert.same(call.callId, 42);
});

it("throws if callId is undefined", function () {
assert.exception(function () {
sinonSpyCall.create(function () {}, {}, []);
sinonSpyCall.create(function () { return; }, {}, []);
});
});

Expand Down Expand Up @@ -219,13 +219,13 @@ describe("sinonSpy.call", function () {
});

it("returns true for no arguments", function () {
var call = sinonSpyCall(function () {}, {}, [], null, null, 0);
var call = sinonSpyCall(function () { return; }, {}, [], null, null, 0);

assert(call.calledWithExactly());
});

it("returns false when called with no args but matching one", function () {
var call = sinonSpyCall(function () {}, {}, [], null, null, 0);
var call = sinonSpyCall(function () { return; }, {}, [], null, null, 0);

assert.isFalse(call.calledWithExactly({}));
});
Expand Down Expand Up @@ -463,8 +463,8 @@ describe("sinonSpy.call", function () {
describe(".callback", function () {
it("it should be a reference for the callback", function () {
var spy = sinonSpy();
var callback1 = function () {};
var callback2 = function () {};
var callback1 = function () { return; };
var callback2 = function () { return; };

spy(1, 2, 3, callback1);
assert.equals(spy.getCall(0).callback, callback1);
Expand Down Expand Up @@ -594,7 +594,7 @@ describe("sinonSpy.call", function () {
describe("call.invokeCallback", function () {

it("is alias for yield", function () {
var call = sinonSpyCall(function () {}, {}, [], null, null, 0);
var call = sinonSpyCall(function () { return; }, {}, [], null, null, 0);

assert.same(call.yield, call.invokeCallback);
});
Expand Down Expand Up @@ -1040,7 +1040,7 @@ describe("sinonSpy.call", function () {

describe("constructor", function () {
beforeEach(function () {
this.CustomConstructor = function () {};
this.CustomConstructor = function () { return; };
this.customPrototype = this.CustomConstructor.prototype;
sinonSpy(this, "CustomConstructor");
});
Expand Down Expand Up @@ -1082,7 +1082,7 @@ describe("sinonSpy.call", function () {
});

it("haves toString method", function () {
var obj = { meth: function () {} };
var obj = { meth: function () { return; } };
sinonSpy(obj, "meth");

assert.equals(obj.meth.toString(), "meth");
Expand All @@ -1095,14 +1095,14 @@ describe("sinonSpy.call", function () {
});

it("toString should report name of spied function", function () {
function myTestFunc() {}
function myTestFunc() { return; }
var spy = sinonSpy(myTestFunc);

assert.equals(spy.toString(), "myTestFunc");
});

it("toString should prefer displayName property if available", function () {
function myTestFunc() {}
function myTestFunc() { return; }
myTestFunc.displayName = "My custom method";
var spy = sinonSpy(myTestFunc);

Expand Down Expand Up @@ -1389,11 +1389,11 @@ describe("sinonSpy.call", function () {
describe(".printf", function () {
describe("name", function () {
it("named", function () {
var named = sinonSpy(function cool() { });
var named = sinonSpy(function cool() { return; });
assert.equals(named.printf("%n"), "cool");
});
it("anon", function () {
var anon = sinonSpy(function () {});
var anon = sinonSpy(function () { return; });
assert.equals(anon.printf("%n"), "spy");

var noFn = sinonSpy();
Expand Down
16 changes: 8 additions & 8 deletions test/fake-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function verifyProxy(func, argument) {
});
}

function noop() {}
function noop() { return; }

function requirePromiseSupport() {
if (typeof Promise !== "function") {
Expand All @@ -50,7 +50,7 @@ describe("fake", function () {
});

describe("when passed a Function", function () {
verifyProxy(fake, function () {});
verifyProxy(fake, function () { return; });

it("should keep the `this` context of the wrapped function", function () {
function method() { return this.foo; }
Expand Down Expand Up @@ -81,8 +81,8 @@ describe("fake", function () {
describe(".callback", function () {
it("it should be a reference for the callback in the last call", function () {
var f = fake();
var callback1 = function () {};
var callback2 = function () {};
var callback1 = function () { return; };
var callback2 = function () { return; };

f(1, 2, 3, callback1);
assert.equals(f.callback, callback1);
Expand Down Expand Up @@ -264,7 +264,7 @@ describe("fake", function () {
var callback = sinon.spy();
var myFake = fake.yields();

myFake(function () {}, callback);
myFake(function () { return; }, callback);

sinon.assert.calledOnce(callback);
});
Expand All @@ -273,7 +273,7 @@ describe("fake", function () {
var myFake = fake.yields();

assert.exception(function () {
myFake(function () {}, "not a function");
myFake(function () { return; }, "not a function");
}, /TypeError: Expected last argument to be a function/);
});
});
Expand Down Expand Up @@ -301,7 +301,7 @@ describe("fake", function () {
var callback = sinon.spy();
var myFake = fake.yieldsAsync();

myFake(function () {}, callback);
myFake(function () { return; }, callback);

sinon.assert.notCalled(callback);

Expand All @@ -316,7 +316,7 @@ describe("fake", function () {
var myFake = fake.yieldsAsync();

assert.exception(function () {
myFake(function () {}, "not a function");
myFake(function () { return; }, "not a function");
}, /TypeError: Expected last argument to be a function/);
});
});
Expand Down
Loading

0 comments on commit e0b7240

Please sign in to comment.