diff --git a/.eslintrc.js b/.eslintrc.js index f057475..1805f01 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,5 @@ module.exports = { - extends: ['prettier', 'plugin:react/recommended'], + extends: ['prettier', 'plugin:react/recommended', 'plugin:react/jsx-runtime'], plugins: ['react', 'prettier'], env: { browser: true, @@ -7,7 +7,12 @@ module.exports = { }, parserOptions: { ecmaVersion: 'latest', - sourceType: 'module' + sourceType: 'module', + }, + settings: { + react: { + version: 'detect', + }, }, rules: { 'prettier/prettier': 'error', @@ -16,8 +21,8 @@ module.exports = { { vars: 'all', args: 'after-used', - ignoreRestSiblings: false - } - ] - } + ignoreRestSiblings: false, + }, + ], + }, }; diff --git a/package.json b/package.json index bec7b9a..3d05d04 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "mkdirp dist && tsc", "prepublish": "npm run build", "test": "jest test", - "lint": "eslint ./src ./test", + "lint": "eslint", "precommit": "lint-staged" }, "lint-staged": { diff --git a/src/InfiniteScroll.jsx b/src/InfiniteScroll.jsx index 5715958..59389a1 100644 --- a/src/InfiniteScroll.jsx +++ b/src/InfiniteScroll.jsx @@ -15,7 +15,7 @@ export default class InfiniteScroll extends React.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 React.Component { isReverse: false, useCapture: false, loader: null, - getScrollParent: null + getScrollParent: null, }; constructor(props) { @@ -69,7 +69,7 @@ export default class InfiniteScroll extends React.Component { const testOptions = { get passive() { passive = true; - } + }, }; try { @@ -87,11 +87,11 @@ export default class InfiniteScroll extends React.Component { if (this.isPassiveSupported()) { options = { useCapture: this.props.useCapture, - passive: true + passive: true, }; } else { options = { - passive: false + passive: false, }; } return options; @@ -111,7 +111,7 @@ export default class InfiniteScroll extends React.Component { scrollEl.removeEventListener( 'mousewheel', this.mousewheelListener, - this.options ? this.options : this.props.useCapture + this.options ? this.options : this.props.useCapture, ); } @@ -124,12 +124,12 @@ export default class InfiniteScroll extends React.Component { scrollEl.removeEventListener( 'scroll', this.scrollListener, - this.options ? this.options : this.props.useCapture + this.options ? this.options : this.props.useCapture, ); scrollEl.removeEventListener( 'resize', this.scrollListener, - this.options ? this.options : this.props.useCapture + this.options ? this.options : this.props.useCapture, ); } @@ -161,17 +161,17 @@ export default class InfiniteScroll extends React.Component { scrollEl.addEventListener( 'mousewheel', this.mousewheelListener, - this.options ? this.options : this.props.useCapture + this.options ? this.options : this.props.useCapture, ); scrollEl.addEventListener( 'scroll', this.scrollListener, - this.options ? this.options : this.props.useCapture + this.options ? this.options : this.props.useCapture, ); scrollEl.addEventListener( 'resize', this.scrollListener, - this.options ? this.options : this.props.useCapture + this.options ? this.options : this.props.useCapture, ); if (this.props.initialLoad) { @@ -214,7 +214,8 @@ export default class InfiniteScroll extends React.Component { // Here we make sure the element is visible as well as checking the offset if ( offset < Number(this.props.threshold) && - (el && el.offsetParent !== null) + el && + el.offsetParent !== null ) { this.detachScrollListener(); this.beforeScrollHeight = parentNode.scrollHeight; @@ -264,7 +265,7 @@ export default class InfiniteScroll extends React.Component { ...props } = renderProps; - props.ref = node => { + props.ref = (node) => { this.scrollComponent = node; if (ref) { ref(node);