From 0cd27704325d866d267619a1de8268ad87c6839d Mon Sep 17 00:00:00 2001 From: Ian Hofmann-Hicks Date: Sun, 19 Mar 2017 19:36:21 -0700 Subject: [PATCH] add better linting options and cleanup the code a bit (#113) --- .jshintrc | 12 +++++++++++- combinators/constant.js | 2 +- combinators/substitution.spec.js | 1 - crocks/Async.js | 4 ++-- crocks/Async.spec.js | 32 +++++++++++++++++--------------- crocks/Either.spec.js | 1 - crocks/IO.spec.js | 4 ++-- crocks/Identity.js | 2 -- crocks/List.spec.js | 3 --- crocks/Maybe.spec.js | 3 --- crocks/Pair.spec.js | 4 ++-- crocks/Result.js | 4 ++-- crocks/Result.spec.js | 3 +-- crocks/Star.js | 1 - crocks/Star.spec.js | 10 +++++----- crocks/State.js | 2 +- crocks/State.spec.js | 3 +-- crocks/Unit.js | 5 +---- helpers/composeP.js | 2 +- helpers/composeP.spec.js | 5 +---- helpers/pipeP.js | 2 +- helpers/pipeP.spec.js | 5 +---- helpers/tryCatch.spec.js | 2 +- internal/predOrFunc.spec.js | 4 ---- monoids/Assign.js | 1 - monoids/Endo.js | 1 - monoids/Prod.js | 1 - monoids/Sum.js | 1 - pointfree/alt.spec.js | 2 +- pointfree/ap.spec.js | 2 +- pointfree/both.js | 2 -- pointfree/fold.spec.js | 6 ++++-- pointfree/merge.spec.js | 2 +- predicates/isMonoid.js | 1 - predicates/isSameType.spec.js | 3 --- transforms/arrayToList.spec.js | 1 - transforms/listToArray.spec.js | 1 - transforms/maybeToAsync.spec.js | 1 - transforms/maybeToEither.spec.js | 1 - transforms/maybeToResult.spec.js | 1 - webpack.config.js | 2 -- 41 files changed, 58 insertions(+), 87 deletions(-) diff --git a/.jshintrc b/.jshintrc index 2d24bb6fb..a0d44e9b9 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,5 +1,15 @@ { "asi": true, + "curly": true, + "eqeqeq": true, "esversion": 6, - "laxbreak": true + "freeze": true, + "funcscope": true, + "globals": { + "require": true, + "module": true + }, + "laxbreak": true, + "undef": true, + "unused": true } diff --git a/combinators/constant.js b/combinators/constant.js index e973fa32b..471b03410 100644 --- a/combinators/constant.js +++ b/combinators/constant.js @@ -5,6 +5,6 @@ const curry = require('../helpers/curry') // Constant (Kestrel) // constant :: a -> b -> a -const constant = x => _ => x +const constant = x => () => x module.exports = curry(constant) diff --git a/combinators/substitution.spec.js b/combinators/substitution.spec.js index 4d81f9343..99eede5e7 100644 --- a/combinators/substitution.spec.js +++ b/combinators/substitution.spec.js @@ -1,5 +1,4 @@ const test = require('tape') -const sinon = require('sinon') const helpers = require('../test/helpers') const bindFunc = helpers.bindFunc diff --git a/crocks/Async.js b/crocks/Async.js index aad62967b..cb0b43ec8 100644 --- a/crocks/Async.js +++ b/crocks/Async.js @@ -29,7 +29,7 @@ const _of = x => Async((_, resolve) => resolve(x)) const Rejected = - x => Async((reject, _) => reject(x)) + x => Async((reject) => reject(x)) function all(asyncs) { if(!(isFoldable(asyncs) && allAsyncs(asyncs))) { @@ -163,7 +163,7 @@ function Async(fn) { return Async((rej, res) => { fork( - _ => m.fork(rej, res), + () => m.fork(rej, res), res ) }) diff --git a/crocks/Async.spec.js b/crocks/Async.spec.js index 5eee632b9..26bd83d7c 100644 --- a/crocks/Async.spec.js +++ b/crocks/Async.spec.js @@ -76,13 +76,13 @@ test('Async Resolved', t => { }) test('Async fromPromise', t => { - const resProm = x => new Promise((res, _) => res(x)) + const resProm = x => new Promise((res) => res(x)) t.ok(isFunction(Async.fromPromise), 'is a function') t.ok(isFunction(Async.fromPromise(resProm)), 'returns a function') const fn = bindFunc(Async.fromPromise) - const fork = bindFunc(x => Async.fromPromise(_ => x)().fork(noop, noop)) + const fork = bindFunc(x => Async.fromPromise(() => x)().fork(noop, noop)) t.throws(fn(undefined), TypeError, 'throws with undefined') t.throws(fn(null), TypeError, 'throws with null') @@ -116,7 +116,7 @@ test('Async fromPromise resolution', t => { const val = 'super fun' const rejProm = x => new Promise((_, rej) => rej(x)) - const resProm = x => new Promise((res, _) => res(x)) + const resProm = x => new Promise((res) => res(x)) const rej = y => x => t.equal(x, y, 'rejects a rejected Promise') const res = y => x => t.equal(x, y, 'resolves a resolved Promise') @@ -228,7 +228,7 @@ test('Async type', t => { test('Async fork', t => { const resolved = Async((_, res) => res('resolved')) - const rejected = Async((rej, _) => rej('rejected')) + const rejected = Async((rej) => rej('rejected')) const res = sinon.spy(identity) const rej = sinon.spy(identity) @@ -305,7 +305,7 @@ test('Async swap', t => { t.throws(fn(noop, {}), TypeError, 'throws with object in right') t.throws(fn(noop, []), TypeError, 'throws with array in right') - const rejected = Async((rej, _) => rej('silly')).swap(constant('was rejected'), identity) + const rejected = Async((rej) => rej('silly')).swap(constant('was rejected'), identity) const resolved = Async((_, res) => res('silly')).swap(identity, constant('was resolved')) const rej = sinon.spy() @@ -346,7 +346,7 @@ test('Async coalesce', t => { t.throws(fn(noop, {}), TypeError, 'throws with object in right') t.throws(fn(noop, []), TypeError, 'throws with array in right') - const rejected = Async((rej, _) => rej()).coalesce(constant('was rejected'), identity) + const rejected = Async((rej) => rej()).coalesce(constant('was rejected'), identity) const resolved = Async((_, res) => res()).coalesce(identity, constant('was resolved')) const rej = sinon.spy() @@ -384,8 +384,8 @@ test('Async map errors', t => { test('Async map functionality', t => { const mapFn = sinon.spy() - const rejected = Async((rej, _) => rej('rejected')).map(mapFn).fork(noop, noop) - const resolved = Async((_, res) => res('resolved')).map(mapFn).fork(noop, noop) + Async((rej) => rej('rejected')).map(mapFn).fork(noop, noop) + Async((_, res) => res('resolved')).map(mapFn).fork(noop, noop) t.equal(Async(noop).map(noop).type(), 'Async', 'returns an Async') t.ok(mapFn.calledWith('resolved'), 'calls map function on resolved') @@ -455,7 +455,7 @@ test('Async bimap functionality', t => { const rej = sinon.spy() const res = sinon.spy() - Async((rej, _) => rej('rejected')).bimap(left, right).fork(rej, res) + Async((rej) => rej('rejected')).bimap(left, right).fork(rej, res) Async((_, res) => res('resolved')).bimap(left, right).fork(rej, res) t.equal(Async(noop).bimap(noop, noop).type(), 'Async', 'returns an Async') @@ -714,8 +714,10 @@ test('Async chain properties (Chain)', t => { const f = x => Async((_, res) => res(x + 2)) const g = x => Async((_, res) => res(x + 10)) - const a = x => Async((_, res) => res(x)).chain(f).chain(g).fork(noop, aRes) - const b = x => Async((_, res) => res(x)).chain(y => f(y).chain(g)).fork(noop, bRes) + const x = 12 + + Async((_, res) => res(x)).chain(f).chain(g).fork(noop, aRes) + Async((_, res) => res(x)).chain(y => f(y).chain(g)).fork(noop, bRes) t.same(aRes.args[0], bRes.args[0], 'assosiativity') @@ -728,16 +730,16 @@ test('Async chain properties (Monad)', t => { const f = x => Async((_, res) => res(x)) - aLeft = sinon.spy() - bLeft = sinon.spy() + const aLeft = sinon.spy() + const bLeft = sinon.spy() Async.of(3).chain(f).fork(noop, aLeft) f(3).fork(noop, bLeft) t.same(aLeft.args[0], bLeft.args[0], 'left identity') - aRight = sinon.spy() - bRight = sinon.spy() + const aRight = sinon.spy() + const bRight = sinon.spy() f(3).chain(Async.of).fork(noop, aRight) f(3).fork(noop, bRight) diff --git a/crocks/Either.spec.js b/crocks/Either.spec.js index b06fca2fe..0dcac83d1 100644 --- a/crocks/Either.spec.js +++ b/crocks/Either.spec.js @@ -179,7 +179,6 @@ test('Either concat errors', t => { const m = { type: () => 'Either...Not' } const good = Either.Right([]) - const bad = Either.Left([]) const f = bindFunc(Either.Right([]).concat) const nonEitherErr = /Either.concat: Either of Semigroup required/ diff --git a/crocks/IO.spec.js b/crocks/IO.spec.js index 61bc56331..9fc09d869 100644 --- a/crocks/IO.spec.js +++ b/crocks/IO.spec.js @@ -212,8 +212,8 @@ test('IO chain properties (Chain)', t => { t.ok(isFunction(IO(noop).chain), 'provides a chain function') t.ok(isFunction(IO(noop).ap), 'implements the Apply spec') - const f = x => IO(_ => x + 2) - const g = x => IO(_ => x + 10) + const f = x => IO(() => x + 2) + const g = x => IO(() => x + 10) const a = x => IO(constant(x)).chain(f).chain(g) const b = x => IO(constant(x)).chain(y => f(y).chain(g)) diff --git a/crocks/Identity.js b/crocks/Identity.js index b5fe68ff1..d8f42094a 100644 --- a/crocks/Identity.js +++ b/crocks/Identity.js @@ -8,9 +8,7 @@ const isSameType = require('../predicates/isSameType') const _inspect = require('../internal/inspect') const innerConcat = require('../internal/innerConcat') -const composeB = require('../combinators/composeB') const constant = require('../combinators/constant') -const identity = require('../combinators/identity') const _type = constant('Identity') diff --git a/crocks/List.spec.js b/crocks/List.spec.js index 71c68342a..879c7f070 100644 --- a/crocks/List.spec.js +++ b/crocks/List.spec.js @@ -20,7 +20,6 @@ const Pred = require('./Pred') const List = require('./List') test('List', t => { - const m = bindFunc(List) const f = x => List(x).toArray() t.ok(isFunction(List), 'is a function') @@ -505,8 +504,6 @@ test('List chain errors', t => { const chain = bindFunc(List([ 0 ]).chain) const bad = bindFunc(x => List.of(x).chain(identity)) - const f = x => List.of(x) - const noFunc = /List.chain: Function required/ t.throws(chain(undefined), noFunc, 'throws with undefined') t.throws(chain(null), noFunc, 'throws with null') diff --git a/crocks/Maybe.spec.js b/crocks/Maybe.spec.js index 658be0e6e..cf886d652 100644 --- a/crocks/Maybe.spec.js +++ b/crocks/Maybe.spec.js @@ -463,9 +463,7 @@ test('Maybe of', t => { test('Maybe of properties (Applicative)', t => { const m = Maybe.Just(identity) - const j = Maybe.Just(3) - const n = Maybe.Nothing() t.ok(isFunction(j.of), 'Just provides an of function') t.ok(isFunction(j.ap), 'Just implements the Apply spec') @@ -487,7 +485,6 @@ test('Maybe of properties (Applicative)', t => { test('Maybe chain errors', t => { const chain = bindFunc(Maybe(0).chain) - const nChain = bindFunc(Maybe(undefined).chain) t.throws(chain(undefined), TypeError, 'throws with undefined') t.throws(chain(null), TypeError, 'throws with null') diff --git a/crocks/Pair.spec.js b/crocks/Pair.spec.js index fb87f6965..dfb668d57 100644 --- a/crocks/Pair.spec.js +++ b/crocks/Pair.spec.js @@ -389,8 +389,8 @@ test('Pair chain errors', t => { const badChain = bindFunc(Pair(0, 0).chain) const chain = bindFunc(Pair([], 0).chain) - const badFn = x => Pair(0, 0) - const fn = x => Pair([], 0) + const badFn = () => Pair(0, 0) + const fn = () => Pair([], 0) t.throws(badChain(noop), TypeError, 'throws if wrapped first value is not a Semigroup') t.throws(chain(badFn), TypeError, 'throws if monadic function returns a Pair with a non-Semigroup as first value') diff --git a/crocks/Result.js b/crocks/Result.js index 1e967a27d..38b79500c 100644 --- a/crocks/Result.js +++ b/crocks/Result.js @@ -34,7 +34,7 @@ const _type = const concatErr = m => x => m.either( y => and(isSemigroup, isSameType(y), x) ? x.concat(y) : x, - _ => x + () => x ) function runSequence(x) { @@ -158,7 +158,7 @@ function Result(u) { throw new TypeError('Result.ap: Wrapped value must be a function') } - return m.either(Result.Err, _ => m.map(fn)) + return m.either(Result.Err, () => m.map(fn)) } ) } diff --git a/crocks/Result.spec.js b/crocks/Result.spec.js index 02f7370ad..46fb2093c 100644 --- a/crocks/Result.spec.js +++ b/crocks/Result.spec.js @@ -114,7 +114,6 @@ test('Result concat errors', t => { const m = { type: () => 'Result...Not' } const good = Result.Ok([]) - const bad = Result.Err([]) const f = bindFunc(Result.Ok([]).concat) @@ -575,7 +574,7 @@ test('Result ap errors', t => { test('Result Err ap functionality', t => { const Err = Result.Err - const m = Result.Ok(x => y => z => x) + const m = Result.Ok(x => () => () => x) const extract = either(identity, constant('Ok')) diff --git a/crocks/Star.js b/crocks/Star.js index 3cf7e57c0..2868df6d9 100644 --- a/crocks/Star.js +++ b/crocks/Star.js @@ -10,7 +10,6 @@ const _inspect = require('../internal/inspect') const compose = require('../helpers/compose') const constant = require('../combinators/constant') -const identity = require('../combinators/identity') const merge = require('../pointfree/merge') const sequence = require('../pointfree/sequence') diff --git a/crocks/Star.spec.js b/crocks/Star.spec.js index d2a9bba4d..f6814f748 100644 --- a/crocks/Star.spec.js +++ b/crocks/Star.spec.js @@ -242,7 +242,7 @@ test('Star contramap functionality', t => { t.equal(m.type(), 'Star', 'returns a Star') t.notOk(spy.called, 'does not call mapping function initially') - const result = m.runWith(x) + m.runWith(x) t.ok(spy.called, 'calls mapping function when ran') t.equal(m.runWith(x).value(), x, 'returns the result of the resulting composition') @@ -320,7 +320,7 @@ test('Star promap functionality', t => { t.notOk(spyLeft.called, 'does not call left mapping function initially') t.notOk(spyRight.called, 'does not call right mapping function initially') - const result = m.runWith(x) + m.runWith(x) t.ok(spyLeft.called, 'calls left mapping function when ran') t.ok(spyRight.called, 'calls right mapping function when ran') @@ -375,7 +375,7 @@ test('Star first', t => { t.doesNotThrow(runWith(Pair(1, 2)), 'does not throw when inner value is a Pair') - const notValid = bindFunc(x => Star(_ => x).first().runWith(Pair(2, 3))) + const notValid = bindFunc(x => Star(() => x).first().runWith(Pair(2, 3))) t.throws(notValid(undefined), TypeError, 'throws with undefined input') t.throws(notValid(null), TypeError, 'throws with null as input') @@ -416,7 +416,7 @@ test('Star second', t => { t.doesNotThrow(runWith(Pair(1, 2)), 'does not throw when inner value is a Pair') - const notValid = bindFunc(x => Star(_ => x).second().runWith(Pair(2, 3))) + const notValid = bindFunc(x => Star(() => x).second().runWith(Pair(2, 3))) t.throws(notValid(undefined), TypeError, 'throws when computation returns undefined') t.throws(notValid(null), TypeError, 'throws when computation returns null') @@ -459,7 +459,7 @@ test('Star both', t => { t.doesNotThrow(runWith(Pair(1, 2)), 'does not throw when inner value is a Pair') - const notValid = bindFunc(x => Star(_ => x).both().runWith(Pair(2, 3))) + const notValid = bindFunc(x => Star(() => x).both().runWith(Pair(2, 3))) t.throws(notValid(undefined), TypeError, 'throws when computation returns undefined') t.throws(notValid(null), TypeError, 'throws when computation returns null') diff --git a/crocks/State.js b/crocks/State.js index ce779f22d..f866b7176 100644 --- a/crocks/State.js +++ b/crocks/State.js @@ -141,7 +141,7 @@ State.type = _type State.get = - _ => State(s => Pair(s, s)) + () => State(s => Pair(s, s)) State.gets = gets diff --git a/crocks/State.spec.js b/crocks/State.spec.js index 79a965622..23f45b368 100644 --- a/crocks/State.spec.js +++ b/crocks/State.spec.js @@ -9,7 +9,6 @@ const isObject = require('../predicates/isObject') const isFunction = require('../predicates/isFunction') const composeB = require('../combinators/composeB') -const constant = require('../combinators/constant') const identity = require('../combinators/identity') const Pair = require('./Pair') @@ -400,7 +399,7 @@ test('State chain errors', t => { t.throws(noPair({}), TypeError, 'throws when inner function returns an object') t.throws(noPair(noop), TypeError, 'throws when inner function returns a function') - const noState = bindFunc(State(x => Pair(0, 0)).chain(identity).runWith) + const noState = bindFunc(State(() => Pair(0, 0)).chain(identity).runWith) t.throws(noState(undefined), TypeError, 'throws when chain function returns undefined') t.throws(noState(null), TypeError, 'throws when chain function returns null') diff --git a/crocks/Unit.js b/crocks/Unit.js index e0570fa46..e373cda96 100644 --- a/crocks/Unit.js +++ b/crocks/Unit.js @@ -1,13 +1,10 @@ /** @license ISC License (c) copyright 2016 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ +const constant = require('../combinators/constant') const isFunction = require('../predicates/isFunction') - -const _inspect = require('../internal/inspect') const isSameType = require('../predicates/isSameType') -const constant = require('../combinators/constant') - const _type = constant('Unit') diff --git a/helpers/composeP.js b/helpers/composeP.js index 3ffd4c3a2..11d6b83aa 100644 --- a/helpers/composeP.js +++ b/helpers/composeP.js @@ -9,7 +9,7 @@ const isPromise = require('../predicates/isPromise') function applyCompose(f, g) { return function() { - p = f.apply(null, arguments) + const p = f.apply(null, arguments) if(!isPromise(p)) { throw new TypeError('composeP: Only accepts Promise returning functions') diff --git a/helpers/composeP.spec.js b/helpers/composeP.spec.js index f459e05f8..72b09e300 100644 --- a/helpers/composeP.spec.js +++ b/helpers/composeP.spec.js @@ -1,14 +1,11 @@ const test = require('tape') -const sinon = require('sinon') const helpers = require('../test/helpers') const bindFunc = helpers.bindFunc const noop = helpers.noop -const isFunction = require('../predicates/isFunction') - -const compose = require('./compose') const identity = require('../combinators/identity') +const isFunction = require('../predicates/isFunction') const composeP = require('./composeP') diff --git a/helpers/pipeP.js b/helpers/pipeP.js index 2eb3fe8f5..7a68e108c 100644 --- a/helpers/pipeP.js +++ b/helpers/pipeP.js @@ -9,7 +9,7 @@ const isPromise = require('../predicates/isPromise') function applyPipe(f, g) { return function() { - p = f.apply(null, arguments) + const p = f.apply(null, arguments) if(!isPromise(p)) { throw new TypeError('pipeP: Only accepts Promise returning functions') diff --git a/helpers/pipeP.spec.js b/helpers/pipeP.spec.js index c5ac8ee79..cd3c5c97f 100644 --- a/helpers/pipeP.spec.js +++ b/helpers/pipeP.spec.js @@ -1,14 +1,11 @@ const test = require('tape') -const sinon = require('sinon') const helpers = require('../test/helpers') const bindFunc = helpers.bindFunc const noop = helpers.noop -const isFunction = require('../predicates/isFunction') - -const compose = require('./compose') const identity = require('../combinators/identity') +const isFunction = require('../predicates/isFunction') const pipeP = require('./pipeP') diff --git a/helpers/tryCatch.spec.js b/helpers/tryCatch.spec.js index 2b410c8de..ac8f3cbe8 100644 --- a/helpers/tryCatch.spec.js +++ b/helpers/tryCatch.spec.js @@ -35,7 +35,7 @@ test('tryCatch', t => { test('tryCatch functionality', t => { const f = x => x - const g = _ => { throw new Error('silly error') } + const g = () => { throw new Error('silly error') } const extract = either(constant('left'), constant('right')) diff --git a/internal/predOrFunc.spec.js b/internal/predOrFunc.spec.js index fc9b13e67..29a8d5e76 100644 --- a/internal/predOrFunc.spec.js +++ b/internal/predOrFunc.spec.js @@ -1,10 +1,6 @@ const test = require('tape') const sinon = require('sinon') -const helpers = require('../test/helpers') - -const noop = helpers.noop - const isFunction = require('../predicates/isFunction') const predOrFunc = require('./predOrFunc') diff --git a/monoids/Assign.js b/monoids/Assign.js index b773bffbf..3b642b9c2 100644 --- a/monoids/Assign.js +++ b/monoids/Assign.js @@ -1,7 +1,6 @@ /** @license ISC License (c) copyright 2016 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ -const isFunction = require('../predicates/isFunction') const isNil = require('../predicates/isNil') const isObject = require('../predicates/isObject') const isSameType = require('../predicates/isSameType') diff --git a/monoids/Endo.js b/monoids/Endo.js index da29e3f11..71f421892 100644 --- a/monoids/Endo.js +++ b/monoids/Endo.js @@ -2,7 +2,6 @@ /** @author Ian Hofmann-Hicks (evil) */ const isFunction = require('../predicates/isFunction') -const isNil = require('../predicates/isNil') const isSameType = require('../predicates/isSameType') const _inspect = require('../internal/inspect') diff --git a/monoids/Prod.js b/monoids/Prod.js index ad0a1872b..3f0a01a28 100644 --- a/monoids/Prod.js +++ b/monoids/Prod.js @@ -1,7 +1,6 @@ /** @license ISC License (c) copyright 2016 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ -const isFunction = require('../predicates/isFunction') const isNil = require('../predicates/isNil') const isNumber = require('../predicates/isNumber') const isSameType = require('../predicates/isSameType') diff --git a/monoids/Sum.js b/monoids/Sum.js index 207b592bb..4e28cf9e7 100644 --- a/monoids/Sum.js +++ b/monoids/Sum.js @@ -1,7 +1,6 @@ /** @license ISC License (c) copyright 2016 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ -const isFunction = require('../predicates/isFunction') const isNil = require('../predicates/isNil') const isNumber = require('../predicates/isNumber') const isSameType = require('../predicates/isSameType') diff --git a/pointfree/alt.spec.js b/pointfree/alt.spec.js index 1863c30f6..0a5d884ae 100644 --- a/pointfree/alt.spec.js +++ b/pointfree/alt.spec.js @@ -51,7 +51,7 @@ test('alt with Alt', t => { const m = mock({ alt: sinon.spy(identity) }) const x = mock({ alt: sinon.spy(identity) }) - const result = alt(m)(x) + alt(m, x) t.ok(x.alt.calledWith(m), 'calls the alt function on the second arg passing in the first arg') diff --git a/pointfree/ap.spec.js b/pointfree/ap.spec.js index 60f0fa259..d8b12a48b 100644 --- a/pointfree/ap.spec.js +++ b/pointfree/ap.spec.js @@ -51,7 +51,7 @@ test('ap applicative', t => { const m = mock({ ap: sinon.spy(identity) }) const x = mock({ ap: sinon.spy(identity) }) - const result = ap(m)(x) + ap(m, x) t.ok(x.ap.calledWith(m), 'calls the ap method on the second arg passing in the first arg') diff --git a/pointfree/both.js b/pointfree/both.js index 4850a1b1d..b3ecf087d 100644 --- a/pointfree/both.js +++ b/pointfree/both.js @@ -4,8 +4,6 @@ const isFunction = require('../predicates/isFunction') const isSameType = require('../predicates/isSameType') -const identity = require('../combinators/identity') - const Pair = require('../crocks/Pair') function both(m) { diff --git a/pointfree/fold.spec.js b/pointfree/fold.spec.js index 08d3e7af3..f882691ed 100644 --- a/pointfree/fold.spec.js +++ b/pointfree/fold.spec.js @@ -13,6 +13,8 @@ const fold = require('./fold') test('fold pointfree errors', t => { const f = bindFunc(fold) + t.ok(isFunction(fold), 'is a function') + const noFold = /fold: Non-empty Foldable with at least one Semigroup is required/ t.throws(f(undefined), noFold, 'throws when passed undefined') t.throws(f(null), noFold, 'throws when passed null') @@ -30,8 +32,8 @@ test('fold pointfree errors', t => { t.throws(f([ 0 ]), noSemi, 'throws when passed a single element array with no semigroup') const notSame = /fold: Foldable must contain Semigroups of the same type/ - t.throws(f([ '', 0 ]), noSemi, 'throws when not elements are semigroups') - t.throws(f([ '', [] ]), noSemi, 'throws when different semigroups') + t.throws(f([ '', 0 ]), notSame, 'throws when not elements are semigroups') + t.throws(f([ '', [] ]), notSame, 'throws when different semigroups') t.end() }) diff --git a/pointfree/merge.spec.js b/pointfree/merge.spec.js index d56cd3c53..85dd2d1bb 100644 --- a/pointfree/merge.spec.js +++ b/pointfree/merge.spec.js @@ -47,7 +47,7 @@ test('merge arrow', t => { const x = 34 const m = { merge: sinon.spy(constant(x)) } - const result = merge(identity)(m) + merge(identity, m) t.ok(m.merge.calledWith(identity), 'calls merge on arrow, passing the function') t.ok(m.merge.returned(x), 'returns the result of m.merge') diff --git a/predicates/isMonoid.js b/predicates/isMonoid.js index 3dc8e4751..f5786a0c0 100644 --- a/predicates/isMonoid.js +++ b/predicates/isMonoid.js @@ -2,7 +2,6 @@ /** @author Ian Hofmann-Hicks (evil) */ const isFunction = require('./isFunction') -const isSemigroup = require('./isSemigroup') // isMonoid :: a -> Boolean function isMonoid(m) { diff --git a/predicates/isSameType.spec.js b/predicates/isSameType.spec.js index 04e769c1c..935a6d074 100644 --- a/predicates/isSameType.spec.js +++ b/predicates/isSameType.spec.js @@ -7,9 +7,6 @@ const noop = helpers.noop const isSameType = require('./isSameType') test('isSameType predicate function', t => { - const first = { type: () => 'first' } - const second = { type: () => 'second' } - t.ok(isFunction(isSameType), 'is a function') t.end() diff --git a/transforms/arrayToList.spec.js b/transforms/arrayToList.spec.js index 041543f90..268337575 100644 --- a/transforms/arrayToList.spec.js +++ b/transforms/arrayToList.spec.js @@ -5,7 +5,6 @@ const bindFunc = helpers.bindFunc const identity = require('../combinators/identity') -const isArray = require('../predicates/isArray') const isFunction = require('../predicates/isFunction') const isSameType = require('../predicates/isSameType') diff --git a/transforms/listToArray.spec.js b/transforms/listToArray.spec.js index 65843a4fe..f06d3e1fa 100644 --- a/transforms/listToArray.spec.js +++ b/transforms/listToArray.spec.js @@ -7,7 +7,6 @@ const identity = require('../combinators/identity') const isArray = require('../predicates/isArray') const isFunction = require('../predicates/isFunction') -const isSameType = require('../predicates/isSameType') const List = require('../crocks/List') diff --git a/transforms/maybeToAsync.spec.js b/transforms/maybeToAsync.spec.js index 22dff93d1..a31d78faf 100644 --- a/transforms/maybeToAsync.spec.js +++ b/transforms/maybeToAsync.spec.js @@ -19,7 +19,6 @@ test('maybeToAsync transform', t => { const f = bindFunc(maybeToAsync) const x = 23 - const m = Maybe.of(x) t.ok(isFunction(maybeToAsync), 'is a function') diff --git a/transforms/maybeToEither.spec.js b/transforms/maybeToEither.spec.js index 5bc1a9404..e5a8869cd 100644 --- a/transforms/maybeToEither.spec.js +++ b/transforms/maybeToEither.spec.js @@ -16,7 +16,6 @@ const maybeToEither = require('./maybeToEither') test('maybeToEither transform', t => { const f = bindFunc(maybeToEither) const x = 23 - const m = Maybe.of(x) t.ok(isFunction(maybeToEither), 'is a function') diff --git a/transforms/maybeToResult.spec.js b/transforms/maybeToResult.spec.js index 1e84f5883..de736a81a 100644 --- a/transforms/maybeToResult.spec.js +++ b/transforms/maybeToResult.spec.js @@ -16,7 +16,6 @@ const maybeToResult = require('./maybeToResult') test('maybeToResult transform', t => { const f = bindFunc(maybeToResult) const x = 23 - const m = Maybe.of(x) t.ok(isFunction(maybeToResult), 'is a function') diff --git a/webpack.config.js b/webpack.config.js index aa19b23a8..e5ef7bd8a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,3 @@ -const webpack = require('webpack') - module.exports = { entry: './crocks.js', output: {