diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 5d158af..0000000 --- a/.npmignore +++ /dev/null @@ -1,138 +0,0 @@ -# Created by https://www.gitignore.io/api/node,macos,linux,windows - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### macOS ### -*.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Node ### -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - - -### Windows ### -# Windows thumbnail cache files -Thumbs.db -ehthumbs.db -ehthumbs_vista.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# End of https://www.gitignore.io/api/node,macos,linux,windows - -# Pre-transpiled source code -src/ - -# Tests -*.spec.js - -# Vagrant development environment -.vagrant/ -Vagrantfile -puphpet/ diff --git a/README.md b/README.md index 18d2d3b..05c78c2 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build Status](https://travis-ci.org/wimpyprogrammer/react-component-update.svg?branch=master)](https://travis-ci.org/wimpyprogrammer/react-component-update) [![codecov](https://codecov.io/gh/wimpyprogrammer/react-component-update/branch/master/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/react-component-update) [![Known Vulnerabilities](https://snyk.io/test/github/wimpyprogrammer/react-component-update/badge.svg)](https://snyk.io/test/github/wimpyprogrammer/react-component-update) +[![Greenkeeper badge](https://badges.greenkeeper.io/wimpyprogrammer/react-component-update.svg)](https://greenkeeper.io/) Adds convenience lifecycle events to your React components. diff --git a/package.json b/package.json index 864f4a9..2c7960a 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,11 @@ { "name": "react-component-update", - "version": "1.1.0", + "version": "1.1.1", "description": "Extends the native React Component to streamline updates", "main": "lib/index.js", + "files": [ + "lib/**/!(*.spec).js" + ], "scripts": { "clean": "rimraf lib", "build": "npm run clean && babel src --out-dir lib", @@ -24,29 +27,29 @@ "homepage": "https://github.com/wimpyprogrammer/react-component-update#readme", "devDependencies": { "babel-cli": "^6.26.0", - "babel-jest": "^20.0.3", + "babel-jest": "^21.2.0", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "chai": "^4.0.2", - "codecov": "^2.3.0", + "codecov": "^3.0.0", "create-react-class": "^15.6.0", "dirty-chai": "^2.0.0", "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.0.1", - "eslint": "^3.19.0", - "eslint-config-airbnb": "^15.0.1", + "eslint": "^4.12.1", + "eslint-config-airbnb": "^16.1.0", "eslint-plugin-import": "^2.3.0", - "eslint-plugin-jsx-a11y": "^5.0.3", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.1.0", - "jest": "^20.0.4", + "jest": "^21.2.1", "lodash.uniqueid": "^4.0.1", "publish-please": "^2.3.1", "react": "*", "react-dom": "*", "react-test-renderer": "*", "rimraf": "^2.6.1", - "sinon": "^3.2.1", + "sinon": "^4.1.2", "sinon-chai": "^2.13.0" }, "peerDependencies": { @@ -55,7 +58,13 @@ "jest": { "coverageDirectory": "./coverage/", "collectCoverage": true, - "setupTestFrameworkScriptFile": "/test-setup.js", + "collectCoverageFrom": [ + "src/**/!(*.spec).js" + ], + "setupFiles": [ + "/test-shims.js", + "/test-setup.js" + ], "testMatch": [ "**/src/*.spec.js?(x)" ] diff --git a/src/component.spec.js b/src/component.spec.js index 15e06bc..04f38b0 100644 --- a/src/component.spec.js +++ b/src/component.spec.js @@ -232,7 +232,9 @@ describe('Component extension with overrides calling super()', () => { it('runs user code in override on mount', () => { sinon.assert.callOrder( - userComponentWillMountBefore, callbackWill, userComponentWillMountAfter, + userComponentWillMountBefore, + callbackWill, + userComponentWillMountAfter, ); }); @@ -244,7 +246,9 @@ describe('Component extension with overrides calling super()', () => { it('runs user code in override on props update', () => { component.setProps(getUniqueProps()); sinon.assert.callOrder( - userComponentWillReceivePropsBefore, callbackWill, userComponentWillReceivePropsAfter, + userComponentWillReceivePropsBefore, + callbackWill, + userComponentWillReceivePropsAfter, ); }); @@ -261,7 +265,9 @@ describe('Component extension with overrides calling super()', () => { it('runs user code in override on mount', () => { sinon.assert.callOrder( - userComponentDidMountBefore, callbackDid, userComponentDidMountAfter, + userComponentDidMountBefore, + callbackDid, + userComponentDidMountAfter, ); }); @@ -273,7 +279,9 @@ describe('Component extension with overrides calling super()', () => { it('runs user code in override on props update', () => { component.setProps(getUniqueProps()); sinon.assert.callOrder( - userComponentDidUpdateBefore, callbackDid, userComponentDidUpdateAfter, + userComponentDidUpdateBefore, + callbackDid, + userComponentDidUpdateAfter, ); }); @@ -285,7 +293,9 @@ describe('Component extension with overrides calling super()', () => { it('runs user code in override on state update', () => { component.setState(getUniqueState()); sinon.assert.callOrder( - userComponentDidUpdateBefore, callbackDid, userComponentDidUpdateAfter, + userComponentDidUpdateBefore, + callbackDid, + userComponentDidUpdateAfter, ); }); }); diff --git a/src/pureComponent.spec.js b/src/pureComponent.spec.js index 8550d21..5dfaaa9 100644 --- a/src/pureComponent.spec.js +++ b/src/pureComponent.spec.js @@ -227,7 +227,9 @@ descriptor('PureComponent extension with overrides calling super()', () => { it('runs user code in override on mount', () => { sinon.assert.callOrder( - userComponentWillMountBefore, callbackWill, userComponentWillMountAfter, + userComponentWillMountBefore, + callbackWill, + userComponentWillMountAfter, ); }); @@ -239,7 +241,9 @@ descriptor('PureComponent extension with overrides calling super()', () => { it('runs user code in override on props update', () => { component.setProps(getUniqueProps()); sinon.assert.callOrder( - userComponentWillReceivePropsBefore, callbackWill, userComponentWillReceivePropsAfter, + userComponentWillReceivePropsBefore, + callbackWill, + userComponentWillReceivePropsAfter, ); }); @@ -256,7 +260,9 @@ descriptor('PureComponent extension with overrides calling super()', () => { it('runs user code in override on mount', () => { sinon.assert.callOrder( - userComponentDidMountBefore, callbackDid, userComponentDidMountAfter, + userComponentDidMountBefore, + callbackDid, + userComponentDidMountAfter, ); }); @@ -268,7 +274,9 @@ descriptor('PureComponent extension with overrides calling super()', () => { it('runs user code in override on props update', () => { component.setProps(getUniqueProps()); sinon.assert.callOrder( - userComponentDidUpdateBefore, callbackDid, userComponentDidUpdateAfter, + userComponentDidUpdateBefore, + callbackDid, + userComponentDidUpdateAfter, ); }); @@ -280,7 +288,9 @@ descriptor('PureComponent extension with overrides calling super()', () => { it('runs user code in override on state update', () => { component.setState(getUniqueState()); sinon.assert.callOrder( - userComponentDidUpdateBefore, callbackDid, userComponentDidUpdateAfter, + userComponentDidUpdateBefore, + callbackDid, + userComponentDidUpdateAfter, ); }); }); diff --git a/test-setup.js b/test-setup.js index cf91e3a..eea9bcb 100644 --- a/test-setup.js +++ b/test-setup.js @@ -1,5 +1,5 @@ /* eslint-disable global-require, import/no-extraneous-dependencies, import/no-unresolved */ -const configure = require('enzyme').configure; +const { configure } = require('enzyme'); const reactVersion = require('react').version; const [majorReactVersion, minorReactVersion] = reactVersion.split('.'); diff --git a/test-shims.js b/test-shims.js new file mode 100644 index 0000000..c9488be --- /dev/null +++ b/test-shims.js @@ -0,0 +1,3 @@ +global.requestAnimationFrame = (callback) => { + setTimeout(callback, 0); +};