Skip to content

Commit

Permalink
Merge pull request #85 from ds300/lint
Browse files Browse the repository at this point in the history
Enable recommended lint
  • Loading branch information
TrySound committed Nov 10, 2017
2 parents fcb43cb + ded2159 commit 35e6df3
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"es5"
],
"extends": [
"eslint:recommended",
"plugin:es5/no-es2015"
],
"rules": {
"no-console": 0,
"semi": 2,
"no-undef": 2,
"comma-dangle": [2, "only-multiline"],
"es5/no-modules": 0
}
Expand Down
2 changes: 1 addition & 1 deletion src/atom.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function Atom (value) {
this._type = ATOM;
this._equals = null;
return this;
};
}

util.assign(Atom.prototype, {
_clone: function () {
Expand Down
9 changes: 4 additions & 5 deletions src/derivation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as util from './util';
import * as parents from './parents';
import * as transactions from './transactions';
import * as types from './types';
import {unpack} from './unpack';
import {CHANGED, UNCHANGED, UNKNOWN, DISCONNECTED} from './states';
Expand All @@ -17,7 +16,7 @@ export function Derivation (deriver) {
if (util.isDebug()) {
this.stack = Error().stack;
}
};
}

util.assign(Derivation.prototype, {
_clone: function () {
Expand Down Expand Up @@ -122,13 +121,13 @@ export function detach (parent, child) {
export function derive (f, a, b, c, d) {
if (f instanceof Array) {
// Template string tag for derivable strings
var args = util.slice(arguments, 1);
var tplArgs = util.slice(arguments, 1);
return derive(function () {
var s = "";
for (var i=0; i < f.length; i++) {
s += f[i];
if (i < args.length) {
s += unpack(args[i]);
if (i < tplArgs.length) {
s += unpack(tplArgs[i]);
}
}
return s;
Expand Down
2 changes: 1 addition & 1 deletion src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function struct (arg) {
} else {
throw new Error("`struct` expects plain Object or Array");
}
};
}

export function wrapPreviousState (f, init) {
var lastState = init;
Expand Down
2 changes: 1 addition & 1 deletion src/parents.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export function maybeCaptureParent (p) {
}
}
}
};
}
2 changes: 1 addition & 1 deletion src/reactors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as types from './types';
import * as util from './util';
import {DISCONNECTED, UNKNOWN, UNCHANGED, CHANGED} from './states';
import {CHANGED} from './states';
import {detach, derive} from './derivation';

export function Reactor(parent, react, governor) {
Expand Down
8 changes: 4 additions & 4 deletions src/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export var currentCtx = null;

export function inTransaction () {
return currentCtx !== null;
};
}

export function transact (f) {
beginTransaction();
Expand All @@ -71,7 +71,7 @@ export function transact (f) {
return;
}
commitTransaction();
};
}

export function atomically (f) {
if (!inTransaction()) {
Expand All @@ -91,7 +91,7 @@ export function transaction (f) {
});
return result;
};
};
}

export function atomic (f) {
return function () {
Expand Down Expand Up @@ -168,4 +168,4 @@ export function ticker () {
}
},
};
};
}
4 changes: 2 additions & 2 deletions src/unpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function unpack (thing) {
} else {
return thing;
}
};
}

export function deepUnpack (thing) {
if (isDerivable(thing)) {
Expand All @@ -29,4 +29,4 @@ export function deepUnpack (thing) {
} else {
return thing;
}
};
}
16 changes: 8 additions & 8 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ export var assign = Object.assign;

export function equals (a, b) {
return Object.is(a, b) || (a && typeof a.equals === 'function' && a.equals(b));
};
}

export function addToArray (a, b) {
var i = a.indexOf(b);
if (i < 0) {
a.push(b);
}
};
}

export function removeFromArray (a, b) {
var i = a.indexOf(b);
if (i >= 0) {
a.splice(i, 1);
}
};
}

var _nextId = 0;
export function nextId () {
return _nextId++;
};
}

export function slice (a, i) {
return Array.prototype.slice.call(a, i);
};
}

export var unique = Object.freeze({equals: function () { return false; }});

export function some (x) {
return (x !== null) && (x !== void 0);
};
}

var DEBUG_MODE = false;

export function setDebugMode (val) {
DEBUG_MODE = !!val;
};
}

export function isDebug() {
return DEBUG_MODE;
Expand All @@ -48,4 +48,4 @@ export function isDebug() {
export function setEquals (derivable, equals) {
derivable._equals = equals;
return derivable;
};
}
2 changes: 2 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"jest": true
},
"rules": {
"no-global-assign": 0,
"no-empty": ["error", { "allowEmptyCatch": true }],
"es5/no-block-scoping": 0,
"es5/no-arrow-functions": 0,
"es5/no-template-literals": 0
Expand Down
4 changes: 2 additions & 2 deletions test/atom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ describe('the concurrent modification of _reactors bug', function () {
var A_success = false;
var C_success = false;

$A.react(function (A) {
$A.react(function () {
A_success = true;
}, {
from: $A
});

var $C = $A.and($B);

$C.react(function (ready) {
$C.react(function () {
C_success = true;
}, {
from: $C
Expand Down
2 changes: 1 addition & 1 deletion test/derivation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe("a derivation", function () {
assert.strictEqual(name.derive('length').get(), 6);
assert.strictEqual(name.derive(0).get(), "s");

var x = startsWithS.then(function () {
startsWithS.then(function () {
return (0, assert)(true, "smithy starts with s");
}, function () {
return (0, assert)(false, "smithy what?");
Expand Down
6 changes: 2 additions & 4 deletions test/module_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

var immutable = require('immutable');

var derivable = require('../dist/derivable');

var assert = require('assert');
Expand Down Expand Up @@ -130,7 +128,7 @@ describe("the `struct` function", function () {
assert.throws(function () {
return derivable.struct(new Error());
});
function A() {};
function A() {}
assert.throws(function () {
return derivable.struct(new A());
});
Expand Down Expand Up @@ -464,7 +462,7 @@ describe("debug mode", function () {
console.error = err;
} catch (e) {
assert.strictEqual(e, 'cheese');
};
}
derivable.setDebugMode(false);
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/reactor_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ describe("setting the values of atoms in a reaction phase", function () {
return n * 2;
};

var r = nmod2.react(function (_) {
nmod2.react(function () {
return n.update(double);
}, {skipFirst: true});

Expand Down Expand Up @@ -721,7 +721,7 @@ describe('the `when` optons to the `react` method', function () {
};

var i = 0;
$N.react(function (n) {
$N.react(function () {
return i++;
}, { when: $Cond });

Expand Down Expand Up @@ -762,7 +762,7 @@ describe('the `when` optons to the `react` method', function () {

var i = 0;

$N.react(function (n) {
$N.react(function () {
return i++;
}, { when: $Cond });

Expand Down

0 comments on commit 35e6df3

Please sign in to comment.