Skip to content

Commit 34f27b1

Browse files
chore: update deps, linting and fix tests
1 parent 15be0ab commit 34f27b1

21 files changed

+2594
-2210
lines changed

.babelrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"presets": [
3-
"env"
3+
"@babel/preset-env"
44
],
55
"plugins": [
6-
"transform-object-rest-spread"
6+
"@babel/plugin-proposal-object-rest-spread"
77
]
88
}

package.json

+29-32
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,39 @@
4444
"author": "Alexander Lichter <[email protected]>",
4545
"license": "MIT",
4646
"devDependencies": {
47-
"@commitlint/cli": "^7.2.1",
48-
"@commitlint/config-conventional": "^7.3.0",
49-
"@commitlint/travis-cli": "^7.2.1",
50-
"babel-core": "^6.26.3",
51-
"babel-eslint": "^10.0.1",
52-
"babel-jest": "^23.6.0",
53-
"babel-loader": "^8.0.5",
54-
"babel-plugin-external-helpers": "^6.22.0",
55-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
56-
"babel-plugin-transform-runtime": "^6.23.0",
57-
"babel-preset-env": "^1.7.0",
58-
"babel-preset-stage-2": "^6.24.1",
59-
"babel-register": "^6.26.0",
47+
"@babel/core": "^7.5.5",
48+
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
49+
"@babel/preset-env": "^7.5.5",
50+
"@commitlint/cli": "^8.1.0",
51+
"@commitlint/config-conventional": "^8.1.0",
52+
"@commitlint/travis-cli": "^8.1.0",
53+
"babel-eslint": "^10.0.2",
54+
"babel-jest": "^24.9.0",
55+
"babel-loader": "^8.0.6",
56+
"babel-register": "^6.22.0",
6057
"chalk": "^2.4.2",
61-
"codecov": "^3.1.0",
58+
"codecov": "^3.5.0",
6259
"cross-spawn": "^6.0.5",
63-
"eslint": "^5.12.0",
64-
"eslint-config-standard": "^11.0.0",
60+
"eslint": "^6.2.0",
61+
"eslint-config-standard": "^13.0.1",
6562
"eslint-friendly-formatter": "^4.0.1",
66-
"eslint-loader": "^2.1.1",
67-
"eslint-plugin-html": "^5.0.0",
68-
"eslint-plugin-import": "^2.14.0",
69-
"eslint-plugin-jest": "^22.1.3",
70-
"eslint-plugin-node": "^8.0.1",
71-
"eslint-plugin-promise": "^4.0.1",
63+
"eslint-loader": "^2.2.1",
64+
"eslint-plugin-html": "^6.0.0",
65+
"eslint-plugin-import": "^2.18.2",
66+
"eslint-plugin-jest": "^22.15.1",
67+
"eslint-plugin-node": "^9.1.0",
68+
"eslint-plugin-promise": "^4.2.1",
7269
"eslint-plugin-standard": "^4.0.0",
73-
"husky": "^1.3.1",
74-
"jest": "^23.6.0",
75-
"jest-each": "^23.6.0",
76-
"jest-environment-node": "^23.4.0",
77-
"regenerator-runtime": "^0.13.1",
78-
"rollup": "^1.1.0",
79-
"rollup-plugin-babel": "^4.3.0",
80-
"rollup-plugin-commonjs": "^9.2.0",
81-
"rollup-plugin-node-resolve": "^4.0.0",
82-
"rollup-plugin-uglify": "^6.0.1"
70+
"husky": "^3.0.4",
71+
"jest": "^24.9.0",
72+
"jest-each": "^24.9.0",
73+
"jest-environment-node": "^24.9.0",
74+
"regenerator-runtime": "^0.13.3",
75+
"rollup": "^1.19.4",
76+
"rollup-plugin-babel": "^4.3.3",
77+
"rollup-plugin-commonjs": "^10.0.2",
78+
"rollup-plugin-node-resolve": "^5.2.0",
79+
"rollup-plugin-uglify": "^6.0.2"
8380
},
8481
"jest": {
8582
"moduleDirectories": [

src/dtmf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const decode = (input, options = {}) => {
2323
return foundCell[1]
2424
}
2525

26-
if (lookup.hasOwnProperty(i)) {
26+
if (typeof lookup[i] !== 'undefined') {
2727
return lookup[i]
2828
}
2929

src/fractionatedMorse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const decode = (input, options = {}) => {
55
options = { ...DEFAULT_OPTIONS, ...options }
66
const morseOptions = { ...DEFAULT_MORSE_OPTION, ...{ failOnUnknownCharacter: options.failOnUnknownCharacter } }
77

8-
let morseCode = [...input]
8+
const morseCode = [...input]
99
.map(c => {
1010
const decodedCharacterIndex = options.keyAlphabet.indexOf(c)
1111
if (decodedCharacterIndex !== -1) {

src/morse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const ALPHABET = {
7272
';': '-.-.-.',
7373
'?': '..--..',
7474
'-': '-....-',
75-
'_': '..--.-',
75+
_: '..--.-',
7676
'(': '-.--.',
7777
')': '-.--.-',
7878
'\'': '.----.',

src/polybius.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const decode = (input, options = {}) => {
4242
options = { ...DEFAULT_OPTIONS, ...options }
4343

4444
const grid = prepareGridString(options)
45-
let squareSize = options.withNumbers ? 6 : 5
45+
const squareSize = options.withNumbers ? 6 : 5
4646

4747
return input
4848
.split(' ')

src/wolfenbuetteler.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const retrieveOptions = options => ({
88
})
99

1010
const DEFAULT_MAPPING = {
11-
'A': 'M',
12-
'E': 'K',
13-
'I': 'D',
14-
'O': 'T',
15-
'U': 'H'
11+
A: 'M',
12+
E: 'K',
13+
I: 'D',
14+
O: 'T',
15+
U: 'H'
1616
}

test/aer256.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import aer256 from 'aer256'
22

33
describe('encoding', () => {
44
test('default', () => {
5-
expect(() => { aer256.encode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
5+
expect(() => { aer256.encode('1432.382960035134') }).toThrow('Key is too short! It must be at least 3 characters')
66
})
77
test('with key', () => {
88
expect(aer256.encode('hey', { key: 'ABCDEF' })).toBe('1432.382960035134')
@@ -12,13 +12,13 @@ describe('encoding', () => {
1212
expect(aer256.encode('hey!*Aäää', { key: 'ABCDEF*' })).toBe('384574.7097057532, 155650.8842775582, -27.9211682037769')
1313
})
1414
test('invalid characters', () => {
15-
expect(() => { aer256.encode('💯文', {key: 'ABCDEF*'}) }).toThrowError('Invalid character')
15+
expect(() => { aer256.encode('💯文', { key: 'ABCDEF*' }) }).toThrow('Invalid character')
1616
})
1717
})
1818

1919
describe('decoding', () => {
2020
test('default', () => {
21-
expect(() => { aer256.decode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
21+
expect(() => { aer256.decode('1432.382960035134') }).toThrow('Key is too short! It must be at least 3 characters')
2222
})
2323
test('with key', () => {
2424
expect(aer256.decode('1432.382960035134', { key: 'ABCDEF' })).toBe('hey')

test/affine.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('encoding', () => {
1212
})
1313
test('failing with unknown character', () => {
1414
expect(() => { affine.encode('AB/', { failOnUnknownCharacter: true }) })
15-
.toThrowError('Could not transform character')
15+
.toThrow('Could not transform character')
1616
})
1717
test('omitting unknown character', () => {
1818
expect(affine.encode('AB/', { omitUnknownCharacter: true })).toBe('BE')
@@ -24,7 +24,7 @@ describe('encoding', () => {
2424
expect(affine.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.toLowerCase(), { keys: [25, 3] })).toBe('DCBAZYXWVUTSRQPONMLKJIHGFE'.toLowerCase())
2525
})
2626
test('illegal key', () => {
27-
expect(() => { affine.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ', { keys: [1, 1] }) }).toThrowError('Illegal key')
27+
expect(() => { affine.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZ', { keys: [1, 1] }) }).toThrow('Illegal key')
2828
})
2929
})
3030

@@ -40,7 +40,7 @@ describe('decoding', () => {
4040
})
4141
test('failing with unknown character', () => {
4242
expect(() => { affine.decode('BE/', { failOnUnknownCharacter: true }) })
43-
.toThrowError('Could not transform character')
43+
.toThrow('Could not transform character')
4444
})
4545
test('omitting unknown character', () => {
4646
expect(affine.decode('BE/', { omitUnknownCharacter: true })).toBe('AB')
@@ -52,6 +52,6 @@ describe('decoding', () => {
5252
expect(affine.decode('DCBAZYXWVUTSRQPONMLKJIHGFE'.toLowerCase(), { keys: [25, 3] })).toBe('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.toLowerCase())
5353
})
5454
test('illegal key', () => {
55-
expect(() => { affine.decode('DCBAZYXWVUTSRQPONMLKJIHGFE', { keys: [1, 1] }) }).toThrowError('Illegal key')
55+
expect(() => { affine.decode('DCBAZYXWVUTSRQPONMLKJIHGFE', { keys: [1, 1] }) }).toThrow('Illegal key')
5656
})
5757
})

test/armon64.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import armon64 from 'armon64'
22

33
describe('encoding', () => {
44
test('default', () => {
5-
expect(() => { armon64.encode('1007.3509783549783') }).toThrowError('Key is too short! It must be at least 3 characters')
5+
expect(() => { armon64.encode('1007.3509783549783') }).toThrow('Key is too short! It must be at least 3 characters')
66
})
77
test('with key', () => {
88
expect(armon64.encode('hey', { key: 'ABCDEF' })).toBe('1007.3509783549783')
@@ -13,7 +13,7 @@ describe('encoding', () => {
1313

1414
describe('decoding', () => {
1515
test('default', () => {
16-
expect(() => { armon64.decode('1432.382960035134') }).toThrowError('Key is too short! It must be at least 3 characters')
16+
expect(() => { armon64.decode('1432.382960035134') }).toThrow('Key is too short! It must be at least 3 characters')
1717
})
1818
test('with key', () => {
1919
expect(armon64.decode('1007.3509783549783', { key: 'ABCDEF' })).toBe('hey')

test/dtmf.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ describe('encoding', () => {
3636
})
3737

3838
test('unknown mode', () => {
39-
expect(() => { dtmf.encode(alphabet, { mode: 'UH' }) }).toThrowError('Unknown mode')
39+
expect(() => { dtmf.encode(alphabet, { mode: 'UH' }) }).toThrow('Unknown mode')
4040
})
4141

4242
test('invalid input', () => {
43-
expect(() => { dtmf.encode('Y') }).toThrowError('Invalid input')
43+
expect(() => { dtmf.encode('Y') }).toThrow('Invalid input')
4444
})
4545

4646
test('invalid input with silentFail', () => {
@@ -74,13 +74,13 @@ describe('decoding', () => {
7474
})
7575

7676
test('unknown mode', () => {
77-
expect(() => { dtmf.decode(alphabet, { mode: 'UH' }) }).toThrowError('Unknown mode')
77+
expect(() => { dtmf.decode(alphabet, { mode: 'UH' }) }).toThrow('Unknown mode')
7878
})
7979

8080
test('invalid input', () => {
81-
expect(() => { dtmf.decode('a') }).toThrowError('Could not decode a - No row found')
82-
expect(() => { dtmf.decode('697') }).toThrowError('Could not decode 697 - No cell found')
83-
expect(() => { dtmf.decode('a', { mode: 'sum' }) }).toThrowError('Could not decode a - No matching value')
81+
expect(() => { dtmf.decode('a') }).toThrow('Could not decode a - No row found')
82+
expect(() => { dtmf.decode('697') }).toThrow('Could not decode 697 - No cell found')
83+
expect(() => { dtmf.decode('a', { mode: 'sum' }) }).toThrow('Could not decode a - No matching value')
8484
})
8585

8686
test('invalid input with silent fail', () => {

test/fractionatedMorse.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ describe('encoding', () => {
1919
expect(fractionatedMorse.encode('1234567890.,:;?-_()\'=+/@')).toBe('EOBOAOAFACJCMCNCNLNODKWBQMCKDSMHAFBKVMVMPNLJFDLJLED')
2020
expect(fractionatedMorse.encode('A D E F')).toBe('FVIIBI')
2121

22-
expect(() => { fractionatedMorse.encode('€€€') }).toThrowError('Unencodable character')
23-
expect(() => { fractionatedMorse.encode('Ü') }).toThrowError('Unencodable character')
24-
expect(() => { fractionatedMorse.encode('A A') }).toThrowError('Unencodable character')
22+
expect(() => { fractionatedMorse.encode('€€€') }).toThrow('Unencodable character')
23+
expect(() => { fractionatedMorse.encode('Ü') }).toThrow('Unencodable character')
24+
expect(() => { fractionatedMorse.encode('A A') }).toThrow('Unencodable character')
2525
})
2626

2727
test('with different keyAlphabet', () => {
@@ -43,7 +43,7 @@ describe('decoding', () => {
4343
expect(fractionatedMorse.decode('EOBOAOAFACJCMCNCNLNODKWBQMCKDSMHAFBKVMVMPNLJFDLJLED')).toBe('1234567890.,:;?-_()\'=+/@')
4444
expect(fractionatedMorse.decode('FT')).toBe('A A')
4545
expect(fractionatedMorse.decode('FVIIBI')).toBe('A D E F')
46-
expect(() => { fractionatedMorse.decode('ÜÄÖ') }).toThrowError('Undecodable character')
46+
expect(() => { fractionatedMorse.decode('ÜÄÖ') }).toThrow('Undecodable character')
4747
})
4848

4949
test('with different keyAlphabet', () => {

test/helpers/helpers.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('randomInRange', () => {
1010
expect(randomInRange(0, 0)).toBe(0)
1111
})
1212
test('returns error when min > max', () => {
13-
expect(() => { randomInRange(1, 0) }).toThrowError('Min cannot be larger than max')
13+
expect(() => { randomInRange(1, 0) }).toThrow('Min cannot be larger than max')
1414
})
1515
})
1616

@@ -22,10 +22,10 @@ describe('modInverse', () => {
2222
expect(modInverse(1, 2)).toBe(1)
2323
})
2424
test('it throws error on invalid input', () => {
25-
expect(() => { modInverse(-1, 26) }).toThrowError()
26-
expect(() => { modInverse(3, 1) }).toThrowError()
27-
expect(() => { modInverse(3, 0) }).toThrowError()
28-
expect(() => { modInverse('b', 'A') }).toThrowError()
25+
expect(() => { modInverse(-1, 26) }).toThrow()
26+
expect(() => { modInverse(3, 1) }).toThrow()
27+
expect(() => { modInverse(3, 0) }).toThrow()
28+
expect(() => { modInverse('b', 'A') }).toThrow()
2929
})
3030
test('it returns correct inverse for prime mods', () => {
3131
expect(modInverse(1, 7)).toBe(1)

test/helpers/substitute.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { substitute } from 'helpers/substitute'
22

33
describe('substitute', () => {
4-
const mappingOptions = { mapping: { 'A': 'M' } }
5-
const mappingAndCaseInsensitiveOptions = { mapping: { 'A': 'M' }, caseSensitive: false }
4+
const mappingOptions = { mapping: { A: 'M' } }
5+
const mappingAndCaseInsensitiveOptions = { mapping: { A: 'M' }, caseSensitive: false }
66
test('default', () => {
77
expect(substitute('A')).toBe('A')
88
})

test/manchester.test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ describe('encoding', () => {
2525

2626
test('empty', () => {
2727
expect(manchester.encode('', silentFailOptions)).toBe('')
28-
expect(() => { manchester.encode('') }).toThrowError('Invalid Input after splitting')
28+
expect(() => { manchester.encode('') }).toThrow('Invalid Input after splitting')
2929
})
3030

3131
test('invalid', () => {
3232
expect(manchester.encode('A', silentFailOptions)).toBe('')
3333
expect(manchester.encode('€', silentFailOptions)).toBe('')
3434
expect(manchester.encode('€0', silentFailOptions)).toBe('01')
3535

36-
expect(() => { manchester.encode('A') }).toThrowError('Invalid Input')
37-
expect(() => { manchester.encode('€') }).toThrowError('Invalid Input')
36+
expect(() => { manchester.encode('A') }).toThrow('Invalid Input')
37+
expect(() => { manchester.encode('€') }).toThrow('Invalid Input')
3838
})
3939
})
4040

@@ -55,7 +55,7 @@ describe('decoding', () => {
5555

5656
test('empty', () => {
5757
expect(manchester.decode('', silentFailOptions)).toBe('')
58-
expect(() => { manchester.decode('') }).toThrowError('Invalid Input after splitting')
58+
expect(() => { manchester.decode('') }).toThrow('Invalid Input after splitting')
5959
})
6060

6161
test('invalid', () => {
@@ -64,8 +64,8 @@ describe('decoding', () => {
6464
expect(manchester.decode('€', silentFailOptions)).toBe('')
6565
expect(manchester.decode('€01', silentFailOptions)).toBe('0')
6666

67-
expect(() => { manchester.decode('0') }).toThrowError('Invalid Input')
68-
expect(() => { manchester.decode('A') }).toThrowError('Invalid Input')
69-
expect(() => { manchester.decode('€') }).toThrowError('Invalid Input')
67+
expect(() => { manchester.decode('0') }).toThrow('Invalid Input')
68+
expect(() => { manchester.decode('A') }).toThrow('Invalid Input')
69+
expect(() => { manchester.decode('€') }).toThrow('Invalid Input')
7070
})
7171
})

test/morse.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('decoding', () => {
2727
})
2828

2929
test('decoding invalid character', () => {
30-
expect(() => { morse.decode(invalidMorseCharacter.input) }).toThrowError('Undecodable character')
30+
expect(() => { morse.decode(invalidMorseCharacter.input) }).toThrow('Undecodable character')
3131
expect(morse.decode(invalidMorseCharacter.input, {
3232
failOnUnknownCharacter: false
3333
})).toBe(invalidMorseCharacter.preserve)
@@ -42,7 +42,7 @@ describe('encoding', () => {
4242
expect(morse.encode(alphabet)).toBe(encodedAlphabet)
4343
})
4444
test('encoding invalid character', () => {
45-
expect(() => { morse.encode(invalidCharacter.input) }).toThrowError('Unencodable character')
45+
expect(() => { morse.encode(invalidCharacter.input) }).toThrow('Unencodable character')
4646
expect(morse.encode(invalidCharacter.input, {
4747
separator: '',
4848
failOnUnknownCharacter: false

test/multiTap.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('encoding', () => {
4646
})
4747

4848
test('with invalid characters', () => {
49-
expect(() => { multiTap.encode('$') }).toThrowError('Unencodable character $')
49+
expect(() => { multiTap.encode('$') }).toThrow('Unencodable character $')
5050
})
5151

5252
test('with invalid characters and silent fail', () => {
@@ -81,7 +81,7 @@ describe('decoding', () => {
8181
})
8282

8383
test('with invalid characters', () => {
84-
expect(() => { multiTap.decode('$2') }).toThrowError('Undecodable character')
84+
expect(() => { multiTap.decode('$2') }).toThrow('Undecodable character')
8585
})
8686

8787
test('with invalid characters and silent fail', () => {

0 commit comments

Comments
 (0)