Skip to content

Commit

Permalink
tweak eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
joelnet committed Oct 16, 2018
1 parent 8b5f4a1 commit 5e34ce6
Show file tree
Hide file tree
Showing 54 changed files with 271 additions and 272 deletions.
7 changes: 4 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__tests__/
#__tests__/
coverage/
interop/
*.test.js
*.test.mjs
examples/
#*.test.js
#*.test.mjs
15 changes: 12 additions & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
env:
es6: true
node: true
jest: true
browser: false
extends: airbnb-base
parserOptions:
Expand All @@ -19,14 +20,22 @@ rules:
semi:
- error
- never
comma-dangle:
- error
- never
prefer-template: error
prefer-promise-reject-errors: off
array-bracket-spacing:
- error
- always
camelcase: warn
no-confusing-arrow: off
no-useless-escape: warn
no-nested-ternary: warn
no-sequences: warn
no-plusplus: warn
no-nested-ternary: off
no-sequences: off
no-plusplus: off
no-shadow: off
implicit-arrow-linebreak: off
import/no-extraneous-dependencies: warn
import/prefer-default-export: off
max-len: warn
6 changes: 3 additions & 3 deletions _internal/__tests__/call.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ describe('function/call', () => {

test('sync', () => {
const expected = 888
const actual = apply (increase) (887)
const actual = apply(increase)(887)
expect(actual).toBe(expected)
})

test('async', () => {
const expected = 888
const actual = apply (increase) (Promise.resolve(887))
const actual = apply(increase)(Promise.resolve(887))
expect(actual).resolves.toBe(expected)
})
})
})
16 changes: 8 additions & 8 deletions _internal/__tests__/iterableSerialReduce.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ describe('internal/iterableSerialReduce', () => {

test('sync array', () => {
const expected = 6
const actual = iterableSerialReduce(add, 0, [1, 2, 3])
const actual = iterableSerialReduce(add, 0, [ 1, 2, 3 ])
expect(actual).resolves.toBe(expected)
})
})

test('sync array 2', () => {
const expected = 6
const actual = iterableSerialReduce(add, null, [2, 3], Promise.resolve(1))
const actual = iterableSerialReduce(add, null, [ 2, 3 ], Promise.resolve(1))
expect(actual).resolves.toBe(expected)
})
})

test('sync iterator', () => {
const expected = 6
const actual = iterableSerialReduce(add, 0, iterator())
expect(actual).resolves.toBe(expected)
})
})

test('async array', () => {
const expected = 6
const actual = iterableSerialReduce(asyncAdd, 0, [1, 2, 3])
const actual = iterableSerialReduce(asyncAdd, 0, [ 1, 2, 3 ])
expect(actual).resolves.toBe(expected)
})
})

test('async iterator', () => {
const expected = 6
const actual = iterableSerialReduce(asyncAdd, 0, iterator())
expect(actual).resolves.toBe(expected)
})
})
})
18 changes: 9 additions & 9 deletions _internal/__tests__/iterableSerialReduceWhile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const iterableSerialReduceWhile = require('../iterableSerialReduceWhile')
describe('internal/iterableSerialReduceWhile', () => {
const add = (x, y) => x + y
const asyncAdd = (x, y) => Promise.resolve().then(() => x + y)
const predicate = acc => x => acc <= 2
const predicate = acc => () => acc <= 2
function* iterator() {
yield 1
yield 2
Expand All @@ -12,31 +12,31 @@ describe('internal/iterableSerialReduceWhile', () => {

test('sync array', () => {
const expected = 3
const actual = iterableSerialReduceWhile(predicate, add, 0, [1, 2, 3])
const actual = iterableSerialReduceWhile(predicate, add, 0, [ 1, 2, 3 ])
expect(actual).resolves.toBe(expected)
})
})

test('sync array 2', () => {
const expected = 3
const actual = iterableSerialReduceWhile(predicate, add, null, [2, 3], Promise.resolve(1))
const actual = iterableSerialReduceWhile(predicate, add, null, [ 2, 3 ], Promise.resolve(1))
expect(actual).resolves.toBe(expected)
})
})

test('sync iterator', () => {
const expected = 3
const actual = iterableSerialReduceWhile(predicate, add, 0, iterator())
expect(actual).resolves.toBe(expected)
})
})

test('async array', () => {
const expected = 3
const actual = iterableSerialReduceWhile(predicate, asyncAdd, 0, [1, 2, 3])
const actual = iterableSerialReduceWhile(predicate, asyncAdd, 0, [ 1, 2, 3 ])
expect(actual).resolves.toBe(expected)
})
})

test('async iterator', () => {
const expected = 3
const actual = iterableSerialReduceWhile(predicate, asyncAdd, 0, iterator())
expect(actual).resolves.toBe(expected)
})
})
})
8 changes: 4 additions & 4 deletions _internal/call.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

const isThenable = require('../_internal/isThenable')

/*
* Takes a value or a Promise and applies func to it.
*/
// call :: Function -> Any -> Any | Promise<Any>
const call = func => value => (isThenable(value)
? value.then(func)
: func(value))
const call = func => value =>
isThenable(value)
? value.then(func)
: func(value)

module.exports = call
1 change: 0 additions & 1 deletion _internal/ensureExecutable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const K = require('../combinators/K')
const is = require('../type/is')

Expand Down
2 changes: 1 addition & 1 deletion _internal/escapeRegExp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* from: https://stackoverflow.com/a/1144788/504836 */

const escapeRegExp = str => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1')
const escapeRegExp = str => str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1')

module.exports = escapeRegExp
1 change: 0 additions & 1 deletion _internal/iterableSerialReduce.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const iterableSerialReduceWhile = require('./iterableSerialReduceWhile')

const iterableSerialReduce = iterableSerialReduceWhile.bind(null, null)
Expand Down
1 change: 0 additions & 1 deletion _internal/iterableSerialReduceWhile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const iterableSerialReduceWhile = async (
predicate,
func,
Expand Down
1 change: 0 additions & 1 deletion _internal/maybeExec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const is = require('../type/is')

const isFunction = is(Function)
Expand Down
2 changes: 1 addition & 1 deletion bin/patch-readme/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import main from './main'
const dependencies = {
baseUrl: 'https://github.com/joelnet/MojiScript/tree/master',
readFile: readFileUtf8,
log,
log
}
const state = `${process.cwd()}/README.md`

Expand Down
4 changes: 2 additions & 2 deletions bin/patch-readme/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import W from '../../combinators/W'

const prependLinksInReadme = baseUrl => W(readme => pipe([
getInternalLinks,
prependAllLinks(baseUrl)(readme),
prependAllLinks(baseUrl)(readme)
]))

const main = ({ log, readFile, baseUrl }) => pipe([
readFile,
prependLinksInReadme(baseUrl),
log,
log
])

export default main
6 changes: 3 additions & 3 deletions bin/patch-readme/markdown.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import S from 'sanctuary'
import S from 'sanctuary' // eslint-disable-line import/no-extraneous-dependencies
import pipe from '../../core/pipe'
import replace from '../../string/replace'

Expand All @@ -8,12 +8,12 @@ const isInternalLink = ([ , link ]) => !S.test(rxExternalLink)(link)

export const getAllLinks = pipe([
S.matchAll(rxLink),
S.map(({ groups }) => S.justs(groups)),
S.map(({ groups }) => S.justs(groups))
])

export const getInternalLinks = pipe([
getAllLinks,
S.filter(isInternalLink),
S.filter(isInternalLink)
])

export const prependLink = baseUrl => document => ([ text, link ]) => replace(`[${text}](${link})`)(`[${text}](${baseUrl}/${link})`)(document)
Expand Down
2 changes: 1 addition & 1 deletion combinators/__tests__/I.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const I = require('../I')
describe('combinators/I', () => {
test('returns value', () => {
const expected = 888
const actual = I (expected)
const actual = I(expected)
expect(actual).toBe(expected)
})
})
2 changes: 1 addition & 1 deletion combinators/__tests__/K.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const K = require('../K')
describe('combinators/K', () => {
test('returns value', () => {
const expected = 888
const actual = K (expected) (666)
const actual = K(expected)(666)
expect(actual).toBe(expected)
})
})
2 changes: 1 addition & 1 deletion combinators/__tests__/S.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('combinators/S', () => {
const expected = 30
const f = a => b => a + b
const g = a => a * 2
const actual = S (f) (g) (10)
const actual = S(f)(g)(10)
expect(actual).toBe(expected)
})
})
2 changes: 1 addition & 1 deletion combinators/__tests__/W.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('combinators/W', () => {
test('returns value', () => {
const expected = 888
const f = a => b => a + b
const actual = W (f) (444)
const actual = W(f)(444)
expect(actual).toBe(expected)
})
})
4 changes: 2 additions & 2 deletions console/__tests__/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ describe('console/error', () => {

test('calls console.error', () => {
const expected = 888
error (expected)
error(expected)
const actual = global.console.error.mock.calls[0][0]
expect(actual).toBe(expected)
})

test('returns original value', () => {
const expected = 888
const actual = error (expected)
const actual = error(expected)
expect(actual).toBe(expected)
})
})
4 changes: 2 additions & 2 deletions console/__tests__/log.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ describe('console/log', () => {

test('calls console.log', () => {
const expected = 888
log (expected)
log(expected)
const actual = global.console.log.mock.calls[0][0]
expect(actual).toBe(expected)
})

test('returns original value', () => {
const expected = 888
const actual = log (expected)
const actual = log(expected)
expect(actual).toBe(expected)
})
})
4 changes: 2 additions & 2 deletions console/__tests__/logF.test..js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ describe('console/logF', () => {

test('calls console.log', () => {
const expected = 888
logF (double) (444)
logF(double)(444)
const actual = global.console.log.mock.calls[0][0]
expect(actual).toBe(expected)
})

test('returns original value', () => {
const expected = 888
const actual = logF (double) (expected)
const actual = logF(double)(expected)
expect(actual).toBe(expected)
})
})
3 changes: 1 addition & 2 deletions console/error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

const tap = require('../function/tap')

const error = tap(x => console.error(x))
const error = tap(x => console.error(x)) // eslint-disable-line no-console

module.exports = error
3 changes: 1 addition & 2 deletions console/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

const tap = require('../function/tap')

const log = tap(x => console.log(x))
const log = tap(x => console.log(x)) // eslint-disable-line no-console

module.exports = log
3 changes: 1 addition & 2 deletions console/logF.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

const tap = require('../function/tap')

const logF = func => tap(x => console.log(func(x)))
const logF = func => tap(x => console.log(func(x))) // eslint-disable-line no-console

module.exports = logF
6 changes: 3 additions & 3 deletions core/__tests__/after.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('core/after', () => {
const expected = 888
const f = jest.fn()
const g = jest.fn()
await after (f) (g) (expected)
await after(f)(g)(expected)
const actual = f.mock.calls[0][0]
expect(actual).toBe(expected)
})
Expand All @@ -16,7 +16,7 @@ describe('core/after', () => {
const expected = 888
const f = jest.fn()
const g = jest.fn()
await after (f) (g) (expected)
await after(f)(g)(expected)
const actual = g.mock.calls[0][0]
expect(actual).toBe(expected)
})
Expand All @@ -26,7 +26,7 @@ describe('core/after', () => {
const expected = 888
const f = jest.fn()
const g = x => x * 2
const actual = after (f) (g) (444)
const actual = after(f)(g)(444)
expect(actual).resolves.toBe(expected)
})
})
Loading

0 comments on commit 5e34ce6

Please sign in to comment.