Skip to content

Commit

Permalink
Set ESLint one-var to error (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroderick committed Aug 17, 2015
1 parent 01dd2ac commit 51ed619
Show file tree
Hide file tree
Showing 35 changed files with 176 additions and 155 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@
"newline-after-var": 0,
"object-curly-spacing": [0, "never"],
"object-shorthand": 0,
"one-var": 0,
"one-var": [2, {
// Exactly one declaration for uninitialized variables per function (var) or block (let or const)
"uninitialized": "always",
// Exactly one declarator per initialized variable declaration per function (var) or block (let or const)
"initialized": "never"
}],
"operator-assignment": [0, "always"],
"operator-linebreak": 0,
"padded-blocks": 0,
Expand Down
3 changes: 2 additions & 1 deletion lib/sinon/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@

callOrder: function assertCallOrder() {
verifyIsStub.apply(null, arguments);
var expected = "", actual = "";
var expected = "";
var actual = "";

if (!sinon.calledInOrder(arguments)) {
try {
Expand Down
4 changes: 2 additions & 2 deletions lib/sinon/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
* Returns the extended target
*/
function extend(target /*, sources */) {
var sources = Array.prototype.slice.call(arguments, 1),
source, i, prop;
var sources = Array.prototype.slice.call(arguments, 1);
var source, i, prop;

for (i = 0; i < sources.length; i++) {
source = sources[i];
Expand Down
4 changes: 2 additions & 2 deletions lib/sinon/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
return util ? format : valueFormatter;
}

var isNode = typeof module !== "undefined" && module.exports && typeof require === "function",
formatter;
var isNode = typeof module !== "undefined" && module.exports && typeof require === "function";
var formatter;

if (isNode) {
try {
Expand Down
14 changes: 8 additions & 6 deletions lib/sinon/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@

verify: function verify() {
var expectations = this.expectations || {};
var messages = [], met = [];
var messages = [];
var met = [];

each(this.proxies, function (proxy) {
each(expectations[proxy], function (expectation) {
Expand All @@ -134,10 +135,10 @@
},

invokeMethod: function invokeMethod(method, thisValue, args) {
var expectations = this.expectations && this.expectations[method] ? this.expectations[method] : [],
expectationsWithMatchingArgs = [],
currentArgs = args || [],
i;
var expectations = this.expectations && this.expectations[method] ? this.expectations[method] : [];
var expectationsWithMatchingArgs = [];
var currentArgs = args || [];
var i, available;

for (i = 0; i < expectations.length; i += 1) {
var expectedArgs = expectations[i].expectedArguments || [];
Expand All @@ -153,7 +154,8 @@
}
}

var messages = [], available, exhausted = 0;
var messages = [];
var exhausted = 0;

for (i = 0; i < expectationsWithMatchingArgs.length; i += 1) {
if (expectationsWithMatchingArgs[i].allowsCall(thisValue, args)) {
Expand Down
4 changes: 3 additions & 1 deletion lib/sinon/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@
sandbox.args = sandbox.args || [];
sandbox.injectedKeys = [];
sandbox.injectInto = config.injectInto;
var prop, value, exposed = sandbox.inject({});
var prop,
value;
var exposed = sandbox.inject({});

if (config.properties) {
for (var i = 0, l = config.properties.length; i < l; i++) {
Expand Down
5 changes: 3 additions & 2 deletions lib/sinon/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
throw new TypeError("Custom stub should be a function or a property descriptor");
}

var wrapper;
var wrapper,
prop;

if (func) {
if (typeof func === "function") {
Expand All @@ -48,7 +49,7 @@
}

if (typeof property === "undefined" && typeof object === "object") {
for (var prop in object) {
for (prop in object) {
if (typeof sinon.getPropertyDescriptor(object, prop).value === "function") {
stub(object, prop);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/sinon/test_case.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@

prefix = prefix || "test";
var rPrefix = new RegExp("^" + prefix);
var methods = {}, testName, property, method;
var methods = {};
var setUp = tests.setUp;
var tearDown = tests.tearDown;
var testName,
property,
method;

for (testName in tests) {
if (tests.hasOwnProperty(testName) && !/^(setUp|tearDown)$/.test(testName)) {
Expand Down
19 changes: 12 additions & 7 deletions lib/sinon/util/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@
}
}

var error, wrappedMethod;
var error, wrappedMethod, i;

// IE 8 does not support hasOwnProperty on the window object and Firefox has a problem
// when using hasOwn.call on objects from other frames.
var owned = object.hasOwnProperty ? object.hasOwnProperty(property) : hasOwn.call(object, property);

if (hasES5Support) {
var methodDesc = (typeof method === "function") ? {value: method} : method,
wrappedMethodDesc = sinon.getPropertyDescriptor(object, property),
i;
var methodDesc = (typeof method === "function") ? {value: method} : method;
var wrappedMethodDesc = sinon.getPropertyDescriptor(object, property);

if (!wrappedMethodDesc) {
error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " +
Expand Down Expand Up @@ -212,7 +211,9 @@
return a.valueOf() === b.valueOf();
}

var prop, aLength = 0, bLength = 0;
var prop;
var aLength = 0;
var bLength = 0;

if (aString === "[object Array]" && a.length !== b.length) {
return false;
Expand Down Expand Up @@ -258,7 +259,9 @@

sinon.functionToString = function toString() {
if (this.getCall && this.callCount) {
var thisValue, prop, i = this.callCount;
var thisValue,
prop;
var i = this.callCount;

while (i--) {
thisValue = this.getCall(i).thisValue;
Expand Down Expand Up @@ -291,7 +294,9 @@
};

sinon.getPropertyDescriptor = function getPropertyDescriptor(object, property) {
var proto = object, descriptor;
var proto = object;
var descriptor;

while (proto && !(descriptor = Object.getOwnPropertyDescriptor(proto, property))) {
proto = Object.getPrototypeOf(proto);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/sinon/util/fake_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
"autoRespondAfter": true,
"respondImmediately": true,
"fakeHTTPMethods": true
},
setting;
};
var setting;

config = config || {};
for (setting in config) {
if (whitelist.hasOwnProperty(setting) && config.hasOwnProperty(setting)) {
Expand Down
3 changes: 2 additions & 1 deletion lib/sinon/util/fake_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
var llx = typeof lolex !== "undefined" ? lolex : lol;

s.useFakeTimers = function () {
var now, methods = Array.prototype.slice.call(arguments);
var now;
var methods = Array.prototype.slice.call(arguments);

if (typeof methods[0] === "string") {
now = 0;
Expand Down
8 changes: 4 additions & 4 deletions test/assert-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert,
refute = buster.refute;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;
var refute = buster.refute;

buster.testCase("sinon.assert", {
setUp: function () {
Expand Down
8 changes: 4 additions & 4 deletions test/call-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert,
refute = buster.refute;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;
var refute = buster.refute;

function spyCallSetUp() {
this.thisValue = {};
Expand Down
6 changes: 3 additions & 3 deletions test/collection-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;

buster.testCase("sinon.collection", {
"creates fake collection": function () {
Expand Down
36 changes: 18 additions & 18 deletions test/extend-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;

buster.testCase("sinon.extend", {
"should return unaltered target when only one argument": function () {
Expand All @@ -26,29 +26,29 @@

"should copy toString method into target": function () {
var target = {
hello: "world",
toString: function () {
return "hello world";
}
},
source = {
toString: function () {
return "hello source";
}
};
hello: "world",
toString: function () {
return "hello world";
}
};
var source = {
toString: function () {
return "hello source";
}
};

sinon.extend(target, source);

assert.same(target.toString, source.toString);
},

"must copy the last occuring property into the target": function () {
var target = { a: 0, b: 0, c: 0, d: 0 },
source1 = { a: 1, b: 1, c: 1 },
source2 = { a: 2, b: 2 },
soruce3 = { a: 3 };
var target = { a: 0, b: 0, c: 0, d: 0 };
var source1 = { a: 1, b: 1, c: 1 };
var source2 = { a: 2, b: 2 };
var source3 = { a: 3 };

sinon.extend(target, source1, source2, soruce3);
sinon.extend(target, source1, source2, source3);

assert.equals(target.a, 3);
assert.equals(target.b, 2);
Expand Down
6 changes: 3 additions & 3 deletions test/format-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;

buster.testCase("sinon.format", {
"formats with formatio by default": function () {
Expand Down
6 changes: 4 additions & 2 deletions test/hello-world-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// this is a very simple testcase primarily used for debugging
// issues with the AMD setup
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
assert = buster.assert;
var buster = root.buster || require("buster");
var assert = buster.assert;

buster.testCase("hello world", {
"hello world test": function () {
Expand Down
8 changes: 4 additions & 4 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../../lib/sinon"),
assert = buster.assert,
refute = buster.refute;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../../lib/sinon");
var assert = buster.assert;
var refute = buster.refute;

buster.testCase("issues", {
setUp: function () {
Expand Down
14 changes: 7 additions & 7 deletions test/log-error-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;

buster.testCase("sinon.log", {
"is a function": function () {
Expand All @@ -27,10 +27,10 @@
},

"calls sinon.log with a String": function () {
var spy = this.sandbox.spy(sinon, "log"),
name = "Quisque consequat, elit id suscipit.",
message = "Pellentesque gravida orci in tellus tristique, ac commodo nibh congue.",
error = new Error();
var spy = this.sandbox.spy(sinon, "log");
var name = "Quisque consequat, elit id suscipit.";
var message = "Pellentesque gravida orci in tellus tristique, ac commodo nibh congue.";
var error = new Error();

error.name = name;
error.message = message;
Expand Down
6 changes: 3 additions & 3 deletions test/match-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;

function propertyMatcherTests(matcher) {
return {
Expand Down
8 changes: 4 additions & 4 deletions test/mock-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (root) {
"use strict";

var buster = root.buster || require("buster"),
sinon = root.sinon || require("../lib/sinon"),
assert = buster.assert,
refute = buster.refute;
var buster = root.buster || require("buster");
var sinon = root.sinon || require("../lib/sinon");
var assert = buster.assert;
var refute = buster.refute;

buster.testCase("sinon.mock", {
".create": {
Expand Down
Loading

0 comments on commit 51ed619

Please sign in to comment.