fix: pre-commit hook setup
MODIFY
.babelrc
.babelrc
{
- "presets": [
- [
- "@babel/env",
- {
- "targets": {
- "browsers": ["last 2 versions"]
- }
- }
- ]
- ],
+ "presets": ["@babel/env"],
"plugins": ["@babel/plugin-transform-runtime"]
}

MODIFY
.eslintrc.js
.eslintrc.js
@@ -9,6 +9,10 @@ module.exports = {
rules: {
"space-before-function-paren": ["error", "never"],
semi: ["error", "never"],
- "no-underscore-dangle": 0
+ "no-underscore-dangle": 0,
+ // allow debugger during development
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
+ // trailing comma
+ 'comma-dangle': ['error', 'always-multiline'],
}
}

MODIFY
.gitignore
.gitignore
node_modules
lib
+dist
.DS_Store
*.log

MODIFY
package-lock.json
package-lock.json
"integrity": "sha512-yprFYuno9FtNsSHVlSWd+nRlmGoAbqbeCwOryP6sC/zoCjhpArcRMYp19EvpSUSizJAlsXEwJv+wcWS9XaXdMw==",
"dev": true
},
+ "@samverschueren/stream-to-observable": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz",
+ "integrity": "sha512-MI4Xx6LHs4Webyvi6EbspgyAb4D2Q2VtnCQ1blOJcoLS6mVa8lNN2rkIy1CVxfTUpoyIbCTkXES1rLXztFD1lg==",
+ "dev": true,
+ "requires": {
+ "any-observable": "0.3.0"
+ },
+ "dependencies": {
+ "any-observable": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz",
+ "integrity": "sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog==",
+ "dev": true
+ }
+ }
+ },
"@sindresorhus/is": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz",
"integrity": "sha512-sjndyZHrrWiu4RY7AkHgjn80GfAM2ZSzUkZLV/Js59Ldmh6JDThf0SUmOHU53rFu2rVxxfCzJ30Ukcfch3Gb/A==",
"dev": true
},
+ "ci-info": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz",
+ "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==",
+ "dev": true
+ },
"cipher-base": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
}
}
},
- "clean-webpack-plugin": {
- "version": "0.1.19",
- "resolved": "https://registry.npmjs.org/clean-webpack-plugin/-/clean-webpack-plugin-0.1.19.tgz",
- "integrity": "sha512-M1Li5yLHECcN2MahoreuODul5LkjohJGFxLPTjl3j1ttKrF5rgjZET1SJduuqxLAuT1gAPOdkhg03qcaaU1KeA==",
- "dev": true,
- "requires": {
- "rimraf": "2.6.2"
- }
- },
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"vary": "1.1.2"
}
},
+ "cosmiconfig": {
+ "version": "5.0.6",
+ "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.6.tgz",
+ "integrity": "sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ==",
+ "dev": true,
+ "requires": {
+ "is-directory": "0.3.1",
+ "js-yaml": "3.12.0",
+ "parse-json": "4.0.0"
+ },
+ "dependencies": {
+ "parse-json": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
+ "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=",
+ "dev": true,
+ "requires": {
+ "error-ex": "1.3.2",
+ "json-parse-better-errors": "1.0.2"
+ }
+ }
+ }
+ },
"create-ecdh": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz",
}
}
},
+ "dedent": {
+ "version": "0.7.0",
+ "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz",
+ "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=",
+ "dev": true
+ },
"deep-eql": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
"pkg-dir": "2.0.0"
}
},
+ "find-parent-dir": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/find-parent-dir/-/find-parent-dir-0.3.0.tgz",
+ "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=",
+ "dev": true
+ },
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
"integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==",
"dev": true
},
+ "get-own-enumerable-property-symbols": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-2.0.1.tgz",
+ "integrity": "sha512-TtY/sbOemiMKPRUDDanGCSgBYe7Mf0vbRsWnBZ+9yghpZ1MvcpSpuZFjHdEeY/LZjZy0vdLjS77L6HosisFiug==",
+ "dev": true
+ },
+ "get-stdin": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
+ "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
+ "dev": true
+ },
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
"dev": true
},
+ "husky": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-1.1.1.tgz",
+ "integrity": "sha512-D8ly8eIZdWzWVG4mh4apaX1PP47uLSaN8CS0RyuuLtHJ20Gt6Ccky5pSecaPsqxNzQj0zon3x6QX/0kCc5/TOQ==",
+ "dev": true,
+ "requires": {
+ "cosmiconfig": "5.0.6",
+ "execa": "0.9.0",
+ "find-up": "3.0.0",
+ "get-stdin": "6.0.0",
+ "is-ci": "1.2.1",
+ "pkg-dir": "3.0.0",
+ "please-upgrade-node": "3.1.1",
+ "read-pkg": "4.0.1",
+ "run-node": "1.0.0",
+ "slash": "2.0.0"
+ },
+ "dependencies": {
+ "cross-spawn": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
+ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
+ "dev": true,
+ "requires": {
+ "lru-cache": "4.1.3",
+ "shebang-command": "1.2.0",
+ "which": "1.3.1"
+ }
+ },
+ "execa": {
+ "version": "0.9.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-0.9.0.tgz",
+ "integrity": "sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA==",
+ "dev": true,
+ "requires": {
+ "cross-spawn": "5.1.0",
+ "get-stream": "3.0.0",
+ "is-stream": "1.1.0",
+ "npm-run-path": "2.0.2",
+ "p-finally": "1.0.0",
+ "signal-exit": "3.0.2",
+ "strip-eof": "1.0.0"
+ }
+ },
+ "find-up": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
+ "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
+ "dev": true,
+ "requires": {
+ "locate-path": "3.0.0"
+ }
+ },
+ "locate-path": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
+ "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
+ "dev": true,
+ "requires": {
+ "p-locate": "3.0.0",
+ "path-exists": "3.0.0"
+ }
+ },
+ "p-limit": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz",
+ "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==",
+ "dev": true,
+ "requires": {
+ "p-try": "2.0.0"
+ }
+ },
+ "p-locate": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
+ "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
+ "dev": true,
+ "requires": {
+ "p-limit": "2.0.0"
+ }
+ },
+ "p-try": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz",
+ "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==",
+ "dev": true
+ },
+ "parse-json": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
+ "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=",
+ "dev": true,
+ "requires": {
+ "error-ex": "1.3.2",
+ "json-parse-better-errors": "1.0.2"
+ }
+ },
+ "pify": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
+ "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
+ "dev": true
+ },
+ "pkg-dir": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz",
+ "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==",
+ "dev": true,
+ "requires": {
+ "find-up": "3.0.0"
+ }
+ },
+ "read-pkg": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz",
+ "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=",
+ "dev": true,
+ "requires": {
+ "normalize-package-data": "2.4.0",
+ "parse-json": "4.0.0",
+ "pify": "3.0.0"
+ }
+ }
+ }
+ },
"iconv-lite": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA=="
},
+ "is-ci": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz",
+ "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==",
+ "dev": true,
+ "requires": {
+ "ci-info": "1.6.0"
+ }
+ },
"is-data-descriptor": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
}
}
},
+ "is-directory": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz",
+ "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=",
+ "dev": true
+ },
"is-dotfile": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz",
}
}
},
+ "is-obj": {
+ "version": "1.0.1",
+ "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
+ "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
+ "dev": true
+ },
"is-object": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz",
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
"dev": true
},
+ "is-regexp": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz",
+ "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=",
+ "dev": true
+ },
"is-resolvable": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz",
"is-object": "1.0.1"
}
},
+ "jest-get-type": {
+ "version": "22.4.3",
+ "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz",
+ "integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==",
+ "dev": true
+ },
+ "jest-validate": {
+ "version": "23.6.0",
+ "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.6.0.tgz",
+ "integrity": "sha512-OFKapYxe72yz7agrDAWi8v2WL8GIfVqcbKRCLbRG9PAxtzF9b1SEDdTpytNDN12z2fJynoBwpMpvj2R39plI2A==",
+ "dev": true,
+ "requires": {
+ "chalk": "2.4.1",
+ "jest-get-type": "22.4.3",
+ "leven": "2.1.0",
+ "pretty-format": "23.6.0"
+ }
+ },
"js-levenshtein": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.4.tgz",
"integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=",
"dev": true
},
+ "json-parse-better-errors": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
+ "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
+ "dev": true
+ },
"json-schema": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
}
}
},
+ "leven": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
+ "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=",
+ "dev": true
+ },
"levn": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
"type-check": "0.3.2"
}
},
+ "lint-staged": {
+ "version": "7.3.0",
+ "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-7.3.0.tgz",
+ "integrity": "sha512-AXk40M9DAiPi7f4tdJggwuKIViUplYtVj1os1MVEteW7qOkU50EOehayCfO9TsoGK24o/EsWb41yrEgfJDDjCw==",
+ "dev": true,
+ "requires": {
+ "chalk": "2.4.1",
+ "commander": "2.19.0",
+ "cosmiconfig": "5.0.6",
+ "debug": "3.2.5",
+ "dedent": "0.7.0",
+ "execa": "0.9.0",
+ "find-parent-dir": "0.3.0",
+ "is-glob": "4.0.0",
+ "is-windows": "1.0.2",
+ "jest-validate": "23.6.0",
+ "listr": "0.14.2",
+ "lodash": "4.17.11",
+ "log-symbols": "2.2.0",
+ "micromatch": "3.1.10",
+ "npm-which": "3.0.1",
+ "p-map": "1.2.0",
+ "path-is-inside": "1.0.2",
+ "pify": "3.0.0",
+ "please-upgrade-node": "3.1.1",
+ "staged-git-files": "1.1.1",
+ "string-argv": "0.0.2",
+ "stringify-object": "3.2.2"
+ },
+ "dependencies": {
+ "commander": {
+ "version": "2.19.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
+ "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
+ "dev": true
+ },
+ "cross-spawn": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
+ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
+ "dev": true,
+ "requires": {
+ "lru-cache": "4.1.3",
+ "shebang-command": "1.2.0",
+ "which": "1.3.1"
+ }
+ },
+ "debug": {
+ "version": "3.2.5",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.5.tgz",
+ "integrity": "sha512-D61LaDQPQkxJ5AUM2mbSJRbPkNs/TmdmOeLAi1hgDkpDfIfetSrjmWhccwtuResSwMbACjx/xXQofvM9CE/aeg==",
+ "dev": true,
+ "requires": {
+ "ms": "2.1.1"
+ }
+ },
+ "execa": {
+ "version": "0.9.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-0.9.0.tgz",
+ "integrity": "sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA==",
+ "dev": true,
+ "requires": {
+ "cross-spawn": "5.1.0",
+ "get-stream": "3.0.0",
+ "is-stream": "1.1.0",
+ "npm-run-path": "2.0.2",
+ "p-finally": "1.0.0",
+ "signal-exit": "3.0.2",
+ "strip-eof": "1.0.0"
+ }
+ },
+ "is-observable": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-1.1.0.tgz",
+ "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==",
+ "dev": true,
+ "requires": {
+ "symbol-observable": "1.2.0"
+ }
+ },
+ "listr": {
+ "version": "0.14.2",
+ "resolved": "https://registry.npmjs.org/listr/-/listr-0.14.2.tgz",
+ "integrity": "sha512-vmaNJ1KlGuGWShHI35X/F8r9xxS0VTHh9GejVXwSN20fG5xpq3Jh4bJbnumoT6q5EDM/8/YP1z3YMtQbFmhuXw==",
+ "dev": true,
+ "requires": {
+ "@samverschueren/stream-to-observable": "0.3.0",
+ "is-observable": "1.1.0",
+ "is-promise": "2.1.0",
+ "is-stream": "1.1.0",
+ "listr-silent-renderer": "1.1.1",
+ "listr-update-renderer": "0.4.0",
+ "listr-verbose-renderer": "0.4.1",
+ "p-map": "1.2.0",
+ "rxjs": "6.3.3"
+ }
+ },
+ "ms": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
+ "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+ "dev": true
+ },
+ "pify": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
+ "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
+ "dev": true
+ },
+ "symbol-observable": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
+ "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==",
+ "dev": true
+ }
+ }
+ },
"listr": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/listr/-/listr-0.13.0.tgz",
}
}
},
+ "npm-path": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/npm-path/-/npm-path-2.0.4.tgz",
+ "integrity": "sha512-IFsj0R9C7ZdR5cP+ET342q77uSRdtWOlWpih5eC+lu29tIDbNEgDbzgVJ5UFvYHWhxDZ5TFkJafFioO0pPQjCw==",
+ "dev": true,
+ "requires": {
+ "which": "1.3.1"
+ }
+ },
"npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
"path-key": "2.0.1"
}
},
+ "npm-which": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/npm-which/-/npm-which-3.0.1.tgz",
+ "integrity": "sha1-kiXybsOihcIJyuZ8OxGmtKtxQKo=",
+ "dev": true,
+ "requires": {
+ "commander": "2.19.0",
+ "npm-path": "2.0.4",
+ "which": "1.3.1"
+ },
+ "dependencies": {
+ "commander": {
+ "version": "2.19.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
+ "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
+ "dev": true
+ }
+ }
+ },
"number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"find-up": "2.1.0"
}
},
+ "please-upgrade-node": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz",
+ "integrity": "sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ==",
+ "dev": true,
+ "requires": {
+ "semver-compare": "1.0.0"
+ }
+ },
"pluralize": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz",
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=",
"dev": true
},
+ "pretty-format": {
+ "version": "23.6.0",
+ "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.6.0.tgz",
+ "integrity": "sha512-zf9NV1NSlDLDjycnwm6hpFATCGl/K1lt0R/GdkAK2O5LN/rwJoB+Mh93gGJjut4YbmecbfgLWVGSTCr0Ewvvbw==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "3.0.0",
+ "ansi-styles": "3.2.1"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
+ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
+ "dev": true
+ }
+ }
+ },
"private": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz",
"is-promise": "2.1.0"
}
},
+ "run-node": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz",
+ "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==",
+ "dev": true
+ },
"run-queue": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
"integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==",
"dev": true
},
+ "semver-compare": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz",
+ "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=",
+ "dev": true
+ },
"send": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz",
"safe-buffer": "5.1.2"
}
},
+ "staged-git-files": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/staged-git-files/-/staged-git-files-1.1.1.tgz",
+ "integrity": "sha512-H89UNKr1rQJvI1c/PIR3kiAMBV23yvR7LItZiV74HWZwzt7f3YHuujJ9nJZlt58WlFox7XQsOahexwk7nTe69A==",
+ "dev": true
+ },
"static-extend": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
},
+ "string-argv": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.0.2.tgz",
+ "integrity": "sha1-2sMECGkMIfPDYwo/86BYd73L1zY=",
+ "dev": true
+ },
"string-template": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz",
"safe-buffer": "5.1.2"
}
},
+ "stringify-object": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.2.2.tgz",
+ "integrity": "sha512-O696NF21oLiDy8PhpWu8AEqoZHw++QW6mUv0UvKZe8gWSdSvMXkiLufK7OmnP27Dro4GU5kb9U7JIO0mBuCRQg==",
+ "dev": true,
+ "requires": {
+ "get-own-enumerable-property-symbols": "2.0.1",
+ "is-obj": "1.0.1",
+ "is-regexp": "1.0.0"
+ }
+ },
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",

MODIFY
package.json
package.json
"lib": "./lib"
},
"scripts": {
- "clean": "rm -rf lib",
+ "clean": "rimraf lib dist",
"babel:build": "babel src/ --out-dir lib/",
- "build": "npm run lint && npm run clean && npm run pack",
- "lint": "eslint src/**/*.js ./test/**/*.spec.js",
+ "build": "npm run lint && npm run clean && npm run babel:build && npm run pack",
+ "lint": "eslint --ext .js src test",
"test": "mocha --require @babel/register --colors ./test/**/*.spec.js",
"test:watch": "mocha --require @babel/register --colors -w ./test/**/*.spec.js",
"pack": "webpack --env build",
},
"dependencies": {
"@babel/polyfill": "7.0.0",
- "@babel/runtime": "^7.1.2",
- "ethereumjs-block": "^2.0.1",
- "ethereumjs-tx": "^1.3.7",
- "ethereumjs-util": "^5.2.0",
- "ethers": "^4.0.0",
- "isomorphic-fetch": "^2.2.1",
- "merkle-patricia-tree": "^2.3.2",
- "query-string": "^6.1.0",
+ "@babel/runtime": "7.1.2",
+ "ethereumjs-block": "2.0.1",
+ "ethereumjs-tx": "1.3.7",
+ "ethereumjs-util": "5.2.0",
+ "ethers": "4.0.0",
+ "isomorphic-fetch": "2.2.1",
+ "merkle-patricia-tree": "2.3.2",
+ "query-string": "6.1.0",
"web3": "1.0.0-beta.36"
},
"devDependencies": {
"@babel/cli": "7.1.0",
"@babel/core": "7.1.0",
- "@babel/plugin-transform-runtime": "^7.1.0",
+ "@babel/plugin-transform-runtime": "7.1.0",
"@babel/preset-env": "7.1.0",
"@babel/register": "7.0.0",
"babel-eslint": "7.2.3",
"babel-loader": "8.0.0-beta.0",
- "chai": "^3.5.0",
- "clean-webpack-plugin": "0.1.19",
+ "chai": "3.5.0",
"eslint": "5.6.0",
"eslint-config-standard": "12.0.0",
"eslint-loader": "2.1.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "7.0.1",
"eslint-plugin-promise": "4.0.1",
- "ganache-cli": "^6.1.8",
- "mocha": "^3.3.0",
+ "ganache-cli": "6.1.8",
+ "husky": "1.1.1",
+ "lint-staged": "7.3.0",
+ "mocha": "3.3.0",
+ "rimraf": "2.6.2",
"webpack": "4.1.0",
"webpack-cli": "2.0.10",
"yargs": "8.0.2"
+ },
+ "browserslist": [
+ "> 1%",
+ "node 8",
+ "not dead"
+ ],
+ "husky": {
+ "hooks": {
+ "pre-commit": "lint-staged"
+ }
+ },
+ "lint-staged": {
+ "linters": {
+ "*.js": ["eslint --fix src test", "git add"]
+ },
+ "ignore": ["dist", "lib"]
}
}

MODIFY
src/helpers/proofs.js
src/helpers/proofs.js
@@ -47,7 +47,7 @@ export async function getTxProof(tx, block) {
parentNodes: stack.map(s => s.raw),
root: getRawHeader(block).transactionsTrie,
path: rlp.encode(tx.transactionIndex),
- value: rlp.decode(rawTxNode.value)
+ value: rlp.decode(rawTxNode.value),
}
resolve(prf)
}
@@ -78,9 +78,9 @@ export function getReceiptBytes(receipt) {
return [
utils.toBuffer(l.address), // convert address to buffer
l.topics.map(utils.toBuffer), // convert topics to buffer
- utils.toBuffer(l.data) // convert data to buffer
+ utils.toBuffer(l.data), // convert data to buffer
]
- })
+ }),
])
}
@@ -125,7 +125,7 @@ export async function getReceiptProof(receipt, block, web3) {
parentNodes: stack.map(s => s.raw),
root: getRawHeader(block).receiptTrie,
path: rlp.encode(receipt.transactionIndex),
- value: rlp.decode(rawReceiptNode.value)
+ value: rlp.decode(rawReceiptNode.value),
}
resolve(prf)
}
@@ -200,12 +200,10 @@ export function verifyTxProof(proof) {
}
break
default:
- // console.log("all nodes must be length 17 or 2")
return false
}
}
} catch (e) {
- // console.log(e)
return false
}
return false

MODIFY
src/index.js
src/index.js
@@ -11,7 +11,7 @@ import {
getReceiptProof,
verifyTxProof,
verifyReceiptProof,
- verifyHeaderProof
+ verifyHeaderProof,
} from "./helpers/proofs"
import { getHeaders, getBlockHeader } from "./helpers/blocks"
import MerkleTree from "./helpers/merkle-tree"
@@ -142,7 +142,7 @@ export default class Matic {
if (this._syncerUrl) {
try {
const response = await this._apiCall({
- url: `${this._syncerUrl}/tx/${txId}`
+ url: `${this._syncerUrl}/tx/${txId}`,
})
if (response && response.tx) {
@@ -160,7 +160,7 @@ export default class Matic {
if (this._syncerUrl) {
try {
const response = await this._apiCall({
- url: `${this._syncerUrl}/tx/${txId}/receipt`
+ url: `${this._syncerUrl}/tx/${txId}/receipt`,
})
if (response && response.receipt) {
@@ -176,7 +176,7 @@ export default class Matic {
async getTxProof(txId) {
const { proof: txProof } = await this._apiCall({
- url: `${this._syncerUrl}/tx/${txId}/proof`
+ url: `${this._syncerUrl}/tx/${txId}/proof`,
})
return txProof
@@ -188,7 +188,7 @@ export default class Matic {
async getReceiptProof(txId) {
const { proof: receiptProof } = await this._apiCall({
- url: `${this._syncerUrl}/tx/${txId}/receipt/proof`
+ url: `${this._syncerUrl}/tx/${txId}/receipt/proof`,
})
return receiptProof
@@ -200,7 +200,7 @@ export default class Matic {
getHeaderObject(blockNumber) {
return this._apiCall({
- url: `${this._watcherUrl}/header/included/${blockNumber}`
+ url: `${this._watcherUrl}/header/included/${blockNumber}`,
})
}
@@ -209,8 +209,8 @@ export default class Matic {
url: `${this._syncerUrl}/block/${blockNumber}/proof`,
query: {
start: +header.start,
- end: +header.end
- }
+ end: +header.end,
+ },
})
return headerProof
@@ -224,7 +224,7 @@ export default class Matic {
// fetch trancation & receipt proof
const [txProof, receiptProof] = await Promise.all([
this.getTxProof(txId),
- this.getReceiptProof(txId)
+ this.getReceiptProof(txId),
])
// fetch header object & header proof
@@ -269,7 +269,7 @@ export default class Matic {
txId: txId,
block: withdrawBlock,
tx: withdrawTx,
- receipt: withdrawReceipt
+ receipt: withdrawReceipt,
}
const txProof = await getTxProof(withdrawObj.tx, withdrawObj.block)
@@ -362,7 +362,7 @@ export default class Matic {
!options.nonce
? await web3.eth.getTransactionCount(from, "pending")
: options.nonce,
- !options.chainId ? await web3.eth.net.getId() : options.chainId
+ !options.chainId ? await web3.eth.net.getId() : options.chainId,
])
return {
@@ -371,7 +371,7 @@ export default class Matic {
gasPrice: gasPrice,
nonce,
chainId,
- value: options.value || 0
+ value: options.value || 0,
}
}
@@ -394,9 +394,9 @@ export default class Matic {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
- ...headers
+ ...headers,
},
- body: data.body ? JSON.stringify(data.body) : null
+ body: data.body ? JSON.stringify(data.body) : null,
}).then(res => {
return res.json()
})

MODIFY
test/index.spec.js
test/index.spec.js
@@ -26,7 +26,7 @@ describe("Matic SDK", () => {
maticObject = new Matic({
maticProvider: "https://kovan.infura.io",
- parentProvider: "https://kovan.infura.io"
+ parentProvider: "https://kovan.infura.io",
})
})

MODIFY
webpack.config.js
webpack.config.js
/* global __dirname, require, module */
const path = require("path")
const env = require("yargs").argv.env // use --env with webpack 2
-const CleanWebpackPlugin = require('clean-webpack-plugin')
const libraryName = "matic"
@@ -15,32 +14,28 @@ const clientConfig = {
mode,
entry: `${__dirname}/src/index.js`,
target: 'web',
- devtool: "source-map",
output: {
- path: `${__dirname}/lib`,
+ path: `${__dirname}/dist`,
filename: `${libraryName}.umd.js`,
library: libraryName,
libraryTarget: "umd",
libraryExport: "default",
- umdNamedDefine: true
+ umdNamedDefine: true,
},
module: {
rules: [
{
test: /\.(js)$/,
loader: "babel-loader",
- exclude: /(node_modules|bower_components)/
+ exclude: /(node_modules|bower_components)/,
},
{
test: /\.(js)$/,
loader: "eslint-loader",
- exclude: /node_modules/
- }
- ]
+ exclude: /node_modules/,
},
- plugins: [
- new CleanWebpackPlugin(['lib']),
],
+ },
externals : {
web3: 'web3',
'ethereumjs-util': 'ethereumjs-util',
@@ -48,7 +43,7 @@ const clientConfig = {
},
resolve: {
modules: [path.resolve("./node_modules"), path.resolve("./src")],
- extensions: [".json", ".js"]
+ extensions: [".json", ".js"],
},
}
@@ -56,8 +51,8 @@ const serverConfig = {
...clientConfig,
target: 'node',
output: {
- path: `${__dirname}/lib`,
- filename: `${libraryName}.esm.js`,
+ path: `${__dirname}/dist`,
+ filename: `${libraryName}.node.js`,
libraryTarget: "commonjs2",
},
}

fix: pre-commit hook setup