From 9379608e5454e08d5a4c3f725c34ebc24a9380f7 Mon Sep 17 00:00:00 2001 From: Rajat Sancheti Date: Tue, 26 Nov 2019 13:07:16 +0530 Subject: [PATCH 1/3] Adds typescript rules --- .eslintrc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 2d2d2a0..5b7d1c0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,5 +22,7 @@ module.exports = { ], rules: { '@typescript-eslint/prefer-regexp-exec': 1, + '@typescript-eslint/ban-ts-ignore': 0, + '@typescript-eslint/unbound-method': 1, }, }; From 4536256b51639b2a67e0069ac6e419e6d354cf2b Mon Sep 17 00:00:00 2001 From: Rajat Sancheti Date: Tue, 26 Nov 2019 13:10:51 +0530 Subject: [PATCH 2/3] Runs prettier --- src/__tests__/index.test.tsx | 10 ++++++---- src/index.tsx | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/__tests__/index.test.tsx b/src/__tests__/index.test.tsx index 6f18ac7..b647e5c 100644 --- a/src/__tests__/index.test.tsx +++ b/src/__tests__/index.test.tsx @@ -86,14 +86,16 @@ describe('React Infinite Scroll Component', () => { describe('When missing the dataLength prop', () => { it('throws an error', () => { console.error = jest.fn(); - const props = { loader: 'Loading...', hasMore: false, next: (() => {}) } + const props = { loader: 'Loading...', hasMore: false, next: () => {} }; // @ts-ignore - expect(() => render()).toThrow(Error) + expect(() => render()).toThrow(Error); // @ts-ignore - expect(console.error.mock.calls[0][0]).toContain('"dataLength" is missing') + expect(console.error.mock.calls[0][0]).toContain( + '"dataLength" is missing' + ); }); - }) + }); describe('When user scrolls to the bottom', () => { it('does not show loader if hasMore is false', () => { diff --git a/src/index.tsx b/src/index.tsx index 3067df2..a7b8624 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -69,8 +69,8 @@ export default class InfiniteScroll extends Component { if (typeof this.props.dataLength === 'undefined') { throw new Error( `mandatory prop "dataLength" is missing. The prop is needed` + - ` when loading more content. Check README.md for usage` - ) + ` when loading more content. Check README.md for usage` + ); } this._scrollableNode = this.getScrollableTarget(); From 34cdef6d2acba851feda4f67d9791fc4211f6b8b Mon Sep 17 00:00:00 2001 From: Rajat Sancheti Date: Tue, 26 Nov 2019 13:12:54 +0530 Subject: [PATCH 3/3] Adds prettier to pre-commit hook --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 120c102..69ef32c 100644 --- a/package.json +++ b/package.json @@ -89,10 +89,12 @@ "git add" ], "*.js": [ + "prettier --write", "eslint --fix", "git add" ], "*.{ts,tsx}": [ + "prettier --write", "eslint --fix", "git add" ]