From 777d63b4807683d574b3e29f67501539e332cd21 Mon Sep 17 00:00:00 2001 From: Dan Bovey Date: Sun, 23 Dec 2018 17:11:12 +0000 Subject: [PATCH] 1.2.3 --- .eslintrc | 31 ------------------- .eslintrc.js | 28 +++++++++++++++++ .prettierrc | 7 +++++ dist/InfiniteScroll.js | 62 ++++++++++++++++++------------------- package-lock.json | 49 +++++++++-------------------- package.json | 2 +- src/InfiniteScroll.js | 16 +++++----- test/infiniteScroll_test.js | 8 ++--- 8 files changed, 94 insertions(+), 109 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.js create mode 100644 .prettierrc diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 2041823..0000000 --- a/.eslintrc +++ /dev/null @@ -1,31 +0,0 @@ -{ - "extends": [ - "last", - "prettier", - "prettier/react", - "plugin:react/recommended" - ], - "plugins": [ - "react", - "prettier" - ], - "globals": { - "document": true, - "window": true, - "describe": true, - "it": true, - "module": true, - "exports": true, - "require": true - }, - "rules": { - "no-unused-vars": [ - "off", - { - "vars": "all", - "args": "after-used", - "ignoreRestSiblings": false - } - ] - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..8fd0d4e --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,28 @@ +const fs = require('fs'); + +const prettierOptions = JSON.parse(fs.readFileSync('./.prettierrc', 'utf8')); + +module.exports = { + extends: ['last', 'prettier', 'prettier/react', 'plugin:react/recommended'], + plugins: ['react', 'prettier'], + globals: { + document: true, + window: true, + describe: true, + it: true, + module: true, + exports: true, + require: true + }, + rules: { + 'prettier/prettier': ['error', prettierOptions], + 'no-unused-vars': [ + 'off', + { + vars: 'all', + args: 'after-used', + ignoreRestSiblings: false + } + ] + } +}; diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..1b0cca8 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true +} diff --git a/dist/InfiniteScroll.js b/dist/InfiniteScroll.js index d6b13e9..6dde570 100644 --- a/dist/InfiniteScroll.js +++ b/dist/InfiniteScroll.js @@ -1,7 +1,7 @@ 'use strict'; Object.defineProperty(exports, '__esModule', { - value: true, + value: true }); var _createClass = (function() { @@ -52,7 +52,7 @@ function _classCallCheck(instance, Constructor) { function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError( - "this hasn't been initialised - super() hasn't been called", + "this hasn't been initialised - super() hasn't been called" ); } return call && (typeof call === 'object' || typeof call === 'function') @@ -64,7 +64,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError( 'Super expression must either be null or a function, not ' + - typeof superClass, + typeof superClass ); } subClass.prototype = Object.create(superClass && superClass.prototype, { @@ -72,8 +72,8 @@ function _inherits(subClass, superClass) { value: subClass, enumerable: false, writable: true, - configurable: true, - }, + configurable: true + } }); if (superClass) Object.setPrototypeOf @@ -91,8 +91,8 @@ var InfiniteScroll = (function(_Component) { this, (InfiniteScroll.__proto__ || Object.getPrototypeOf(InfiniteScroll)).call( this, - props, - ), + props + ) ); _this.scrollListener = _this.scrollListener.bind(_this); @@ -105,7 +105,7 @@ var InfiniteScroll = (function(_Component) { value: function componentDidMount() { this.pageLoaded = this.props.pageStart; this.attachScrollListener(); - }, + } }, { key: 'componentDidUpdate', @@ -119,14 +119,14 @@ var InfiniteScroll = (function(_Component) { this.loadMore = false; } this.attachScrollListener(); - }, + } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.detachScrollListener(); this.detachMousewheelListener(); - }, + } // Set a defaut loader for all your `InfiniteScroll` components }, @@ -134,7 +134,7 @@ var InfiniteScroll = (function(_Component) { key: 'setDefaultLoader', value: function setDefaultLoader(loader) { this.defaultLoader = loader; - }, + } }, { key: 'detachMousewheelListener', @@ -147,9 +147,9 @@ var InfiniteScroll = (function(_Component) { scrollEl.removeEventListener( 'mousewheel', this.mousewheelListener, - this.props.useCapture, + this.props.useCapture ); - }, + } }, { key: 'detachScrollListener', @@ -162,14 +162,14 @@ var InfiniteScroll = (function(_Component) { scrollEl.removeEventListener( 'scroll', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); scrollEl.removeEventListener( 'resize', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); - }, + } }, { key: 'getParentElement', @@ -180,13 +180,13 @@ var InfiniteScroll = (function(_Component) { return scrollParent; } return el && el.parentNode; - }, + } }, { key: 'filterProps', value: function filterProps(props) { return props; - }, + } }, { key: 'attachScrollListener', @@ -205,23 +205,23 @@ var InfiniteScroll = (function(_Component) { scrollEl.addEventListener( 'mousewheel', this.mousewheelListener, - this.props.useCapture, + this.props.useCapture ); scrollEl.addEventListener( 'scroll', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); scrollEl.addEventListener( 'resize', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); if (this.props.initialLoad) { this.scrollListener(); } - }, + } }, { key: 'mousewheelListener', @@ -231,7 +231,7 @@ var InfiniteScroll = (function(_Component) { if (e.deltaY === 1) { e.preventDefault(); } - }, + } }, { key: 'scrollListener', @@ -277,7 +277,7 @@ var InfiniteScroll = (function(_Component) { this.loadMore = true; } } - }, + } }, { key: 'calculateOffset', @@ -290,7 +290,7 @@ var InfiniteScroll = (function(_Component) { this.calculateTopPosition(el) + (el.offsetHeight - scrollTop - window.innerHeight) ); - }, + } }, { key: 'calculateTopPosition', @@ -299,7 +299,7 @@ var InfiniteScroll = (function(_Component) { return 0; } return el.offsetTop + this.calculateTopPosition(el.offsetParent); - }, + } }, { key: 'render', @@ -334,7 +334,7 @@ var InfiniteScroll = (function(_Component) { 'threshold', 'useCapture', 'useWindow', - 'getScrollParent', + 'getScrollParent' ]); props.ref = function(node) { @@ -357,8 +357,8 @@ var InfiniteScroll = (function(_Component) { } } return _react2.default.createElement(element, props, childrenArray); - }, - }, + } + } ]); return InfiniteScroll; @@ -377,7 +377,7 @@ InfiniteScroll.propTypes = { getScrollParent: _propTypes2.default.func, threshold: _propTypes2.default.number, useCapture: _propTypes2.default.bool, - useWindow: _propTypes2.default.bool, + useWindow: _propTypes2.default.bool }; InfiniteScroll.defaultProps = { element: 'div', @@ -390,7 +390,7 @@ InfiniteScroll.defaultProps = { isReverse: false, useCapture: false, loader: null, - getScrollParent: null, + getScrollParent: null }; exports.default = InfiniteScroll; module.exports = exports['default']; diff --git a/package-lock.json b/package-lock.json index 297736a..3cdbd47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3181,7 +3181,6 @@ "version": "0.0.9", "bundled": true, "dev": true, - "optional": true, "requires": { "inherits": "~2.0.0" } @@ -3190,7 +3189,6 @@ "version": "2.10.1", "bundled": true, "dev": true, - "optional": true, "requires": { "hoek": "2.x.x" } @@ -3207,8 +3205,7 @@ "buffer-shims": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "caseless": { "version": "0.12.0", @@ -3225,14 +3222,12 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "combined-stream": { "version": "1.0.5", "bundled": true, "dev": true, - "optional": true, "requires": { "delayed-stream": "~1.0.0" } @@ -3245,14 +3240,12 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "cryptiles": { "version": "2.0.5", @@ -3298,8 +3291,7 @@ "delayed-stream": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "delegates": { "version": "1.0.0", @@ -3325,8 +3317,7 @@ "extsprintf": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "forever-agent": { "version": "0.6.1", @@ -3497,7 +3488,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3511,8 +3501,7 @@ "isarray": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "isstream": { "version": "0.1.2", @@ -3585,14 +3574,12 @@ "mime-db": { "version": "1.27.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "mime-types": { "version": "2.1.15", "bundled": true, "dev": true, - "optional": true, "requires": { "mime-db": "~1.27.0" } @@ -3666,8 +3653,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "oauth-sign": { "version": "0.8.2", @@ -3725,8 +3711,7 @@ "process-nextick-args": { "version": "1.0.7", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "punycode": { "version": "1.4.1", @@ -3764,7 +3749,6 @@ "version": "2.2.9", "bundled": true, "dev": true, - "optional": true, "requires": { "buffer-shims": "~1.0.0", "core-util-is": "~1.0.0", @@ -3816,8 +3800,7 @@ "safe-buffer": { "version": "5.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "semver": { "version": "5.3.0", @@ -3875,7 +3858,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3886,7 +3868,6 @@ "version": "1.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.0.1" } @@ -3915,7 +3896,6 @@ "version": "2.2.1", "bundled": true, "dev": true, - "optional": true, "requires": { "block-stream": "*", "fstream": "^1.0.2", @@ -3971,8 +3951,7 @@ "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "uuid": { "version": "3.0.1", @@ -5850,7 +5829,8 @@ "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true }, "mixin-deep": { "version": "1.3.1", @@ -5877,6 +5857,7 @@ "version": "0.5.1", "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, "requires": { "minimist": "0.0.8" } diff --git a/package.json b/package.json index bb524cf..43c0329 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-infinite-scroller", - "version": "1.2.2", + "version": "1.2.3", "description": "Infinite scroll component for React in ES6", "main": "index.js", "jsnext:main": "src/InfiniteScroll.js", diff --git a/src/InfiniteScroll.js b/src/InfiniteScroll.js index 63c0670..8bf3f67 100644 --- a/src/InfiniteScroll.js +++ b/src/InfiniteScroll.js @@ -15,7 +15,7 @@ export default class InfiniteScroll extends Component { getScrollParent: PropTypes.func, threshold: PropTypes.number, useCapture: PropTypes.bool, - useWindow: PropTypes.bool, + useWindow: PropTypes.bool }; static defaultProps = { @@ -29,7 +29,7 @@ export default class InfiniteScroll extends Component { isReverse: false, useCapture: false, loader: null, - getScrollParent: null, + getScrollParent: null }; constructor(props) { @@ -74,7 +74,7 @@ export default class InfiniteScroll extends Component { scrollEl.removeEventListener( 'mousewheel', this.mousewheelListener, - this.props.useCapture, + this.props.useCapture ); } @@ -87,12 +87,12 @@ export default class InfiniteScroll extends Component { scrollEl.removeEventListener( 'scroll', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); scrollEl.removeEventListener( 'resize', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); } @@ -124,17 +124,17 @@ export default class InfiniteScroll extends Component { scrollEl.addEventListener( 'mousewheel', this.mousewheelListener, - this.props.useCapture, + this.props.useCapture ); scrollEl.addEventListener( 'scroll', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); scrollEl.addEventListener( 'resize', this.scrollListener, - this.props.useCapture, + this.props.useCapture ); if (this.props.initialLoad) { diff --git a/test/infiniteScroll_test.js b/test/infiniteScroll_test.js index 0cbd99e..b18263c 100644 --- a/test/infiniteScroll_test.js +++ b/test/infiniteScroll_test.js @@ -20,7 +20,7 @@ describe('InfiniteScroll component', () => {
{children}
- , + ); expect(wrapper.find('.child-class').length).to.equal(3); }); @@ -40,7 +40,7 @@ describe('InfiniteScroll component', () => {
{children}
- , + ); expect(InfiniteScroll.prototype.componentDidMount.callCount).to.equal(1); InfiniteScroll.prototype.componentDidMount.restore(); @@ -68,7 +68,7 @@ describe('InfiniteScroll component', () => { >
{children}
- , + ); expect(InfiniteScroll.prototype.attachScrollListener.callCount).to.equal(1); expect(InfiniteScroll.prototype.scrollListener.callCount).to.equal(1); @@ -84,7 +84,7 @@ describe('InfiniteScroll component', () => {
Child Text
- , + ); const component = wrapper.find(InfiniteScroll);