Skip to content

Commit

Permalink
Use common Sinon.JS eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Feb 25, 2017
1 parent e3ce0aa commit 8b2651a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 193 deletions.
172 changes: 0 additions & 172 deletions .eslintrc

This file was deleted.

7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -24,11 +24,16 @@
},
"devDependencies": {
"browserify": "^13.0.1",
"eslint": "^3.0.1",
"eslint": "^3.16.1",
"eslint-config-sinon": "^1.0.0",
"eslint-plugin-mocha": "^4.8.0",
"mocha": "^3.1.2",
"mochify": "^2.18.0",
"referee": "^1.2.0",
"sinon": "^1.17.4"
},
"eslintConfig": {
"extends": "eslint-config-sinon"
},
"main": "./src/lolex-src.js"
}
40 changes: 21 additions & 19 deletions src/lolex-src.js
Expand Up @@ -44,8 +44,10 @@ function parseTime(str) {
}

var strings = str.split(":");
var l = strings.length, i = l;
var ms = 0, parsed;
var l = strings.length;
var i = l;
var ms = 0;
var parsed;

if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
throw new Error("tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits");
Expand Down Expand Up @@ -223,10 +225,9 @@ function compareTimers(a, b) {
}

function firstTimerInRange(clock, from, to) {
var timers = clock.timers,
timer = null,
id,
isInRange;
var timers = clock.timers;
var timer = null;
var id, isInRange;

for (id in timers) {
if (timers.hasOwnProperty(id)) {
Expand All @@ -242,9 +243,9 @@ function firstTimerInRange(clock, from, to) {
}

function firstTimer(clock) {
var timers = clock.timers,
timer = null,
id;
var timers = clock.timers;
var timer = null;
var id;

for (id in timers) {
if (timers.hasOwnProperty(id)) {
Expand All @@ -258,9 +259,9 @@ function firstTimer(clock) {
}

function lastTimer(clock) {
var timers = clock.timers,
timer = null,
id;
var timers = clock.timers;
var timer = null;
var id;

for (id in timers) {
if (timers.hasOwnProperty(id)) {
Expand Down Expand Up @@ -408,8 +409,8 @@ if (hrtimePresent) {
}

var keys = Object.keys || function (obj) {
var ks = [],
key;
var ks = [];
var key;

for (key in obj) {
if (obj.hasOwnProperty(key)) {
Expand Down Expand Up @@ -474,17 +475,18 @@ function createClock(now, loopLimit) {

clock.tick = function tick(ms) {
ms = typeof ms === "number" ? ms : parseTime(ms);
var tickFrom = clock.now, tickTo = clock.now + ms, previous = clock.now;
var tickFrom = clock.now;
var tickTo = clock.now + ms;
var previous = clock.now;
var timer = firstTimerInRange(clock, tickFrom, tickTo);
var oldNow;
var oldNow, firstException;

clock.duringTick = true;

function updateHrTime(newNow) {
clock.hrNow += (newNow - clock.now);
}

var firstException;
while (timer && tickFrom <= tickTo) {
if (clock.timers[timer.id]) {
updateHrTime(timer.callAt);
Expand Down Expand Up @@ -566,9 +568,9 @@ function createClock(now, loopLimit) {
clock.timers = {};
};

clock.setSystemTime = function setSystemTime(now) {
clock.setSystemTime = function setSystemTime(systemTime) {
// determine time difference
var newNow = getEpoch(now);
var newNow = getEpoch(systemTime);
var difference = newNow - clock.now;
var id, timer;

Expand Down
12 changes: 12 additions & 0 deletions test/.eslintrc
@@ -0,0 +1,12 @@
{
"env": {
"mocha": true
},
"plugins": [
"mocha"
],
"rules": {
"mocha/no-exclusive-tests": 2,
"max-nested-callbacks": 0
}
}
2 changes: 1 addition & 1 deletion test/lolex-test.js
Expand Up @@ -1250,7 +1250,7 @@ describe("lolex", function () {

it("creates real Date objects when Date constructor is gone", function () {
var realDate = new Date();
Date = NOOP;
Date = NOOP; // eslint-disable-line no-native-reassign
global.Date = NOOP;

var date = new this.clock.Date();
Expand Down

0 comments on commit 8b2651a

Please sign in to comment.