Skip to content

Commit

Permalink
Merge pull request #161 from ankeetmaini/lint-fix
Browse files Browse the repository at this point in the history
Adds typescript rules
  • Loading branch information
rajatsan authored Nov 26, 2019
2 parents e899545 + 34cdef6 commit 69ab8fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ module.exports = {
],
rules: {
'@typescript-eslint/prefer-regexp-exec': 1,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/unbound-method': 1,
},
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@
"git add"
],
"*.js": [
"prettier --write",
"eslint --fix",
"git add"
],
"*.{ts,tsx}": [
"prettier --write",
"eslint --fix",
"git add"
]
Expand Down
10 changes: 6 additions & 4 deletions src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<InfiniteScroll {...props} />)).toThrow(Error)
expect(() => render(<InfiniteScroll {...props} />)).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', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default class InfiniteScroll extends Component<Props, State> {
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();
Expand Down

0 comments on commit 69ab8fd

Please sign in to comment.