Skip to content

Commit ef62655

Browse files
committed
chore: upgrade to React 17 with v7.0.0 release
1 parent b48b0ae commit ef62655

19 files changed

+5567
-8744
lines changed

.all-contributorsrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"files": [
33
"README.md"
44
],
5-
"imageSize": 100,
6-
"contributorsPerLine": 5,
5+
"imageSize": 80,
6+
"contributorsPerLine": 6,
77
"skipCi": true,
88
"contributors": [
99
{
@@ -25,7 +25,10 @@
2525
"avatar_url": "https://avatars.githubusercontent.com/u/25670841?v=4",
2626
"profile": "https://github.com/iamdarshshah",
2727
"contributions": [
28-
"infra"
28+
"infra",
29+
"code",
30+
"review",
31+
"maintenance"
2932
]
3033
}
3134
],

.eslintrc.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,27 @@ module.exports = {
1414
'eslint:recommended',
1515
'plugin:@typescript-eslint/eslint-recommended',
1616
'plugin:react/recommended',
17+
'plugin:react/jsx-runtime',
1718
'plugin:@typescript-eslint/recommended',
1819
'plugin:@typescript-eslint/recommended-requiring-type-checking',
1920
'prettier',
20-
'prettier/@typescript-eslint',
21-
'prettier/react',
2221
],
22+
settings: {
23+
react: {
24+
version: '17.0',
25+
},
26+
},
2327
rules: {
24-
'@typescript-eslint/prefer-regexp-exec': 1,
25-
'@typescript-eslint/ban-ts-ignore': 0,
26-
'@typescript-eslint/unbound-method': 1,
28+
'@typescript-eslint/prefer-regexp-exec': 'warn',
29+
'@typescript-eslint/ban-ts-comment': 'off',
30+
'@typescript-eslint/unbound-method': 'warn',
31+
'@typescript-eslint/no-explicit-any': 'warn',
32+
'@typescript-eslint/no-unused-expressions': 'warn',
33+
'@typescript-eslint/no-unsafe-return': 'warn',
34+
'@typescript-eslint/no-unsafe-assignment': 'warn',
35+
'@typescript-eslint/no-unsafe-call': 'warn',
36+
'@typescript-eslint/no-unsafe-argument': 'warn',
37+
'@typescript-eslint/no-empty-object-type': 'warn',
38+
'react/no-deprecated': 'warn',
2739
},
2840
};

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
node-version: [16.x, 18.x, 20.x]
14+
node-version: [18.x, 20.x, 22.x]
1515

1616
steps:
1717
- uses: actions/checkout@v4

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn run ts-check && npx lint-staged

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ module.exports = {
7979
// A preset that is used as a base for Jest's configuration
8080
preset: 'ts-jest',
8181

82+
// ts-jest configuration for React 17 JSX transform
83+
transform: {
84+
'^.+\\.tsx?$': [
85+
'ts-jest',
86+
{
87+
tsconfig: {
88+
jsx: 'react-jsx',
89+
},
90+
},
91+
],
92+
},
93+
8294
// Run tests from one or more projects
8395
// projects: null,
8496

package.json

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "react-infinite-scroll-component",
3-
"version": "6.1.1",
3+
"version": "7.0.0",
44
"description": "An Infinite Scroll component in react.",
5+
"engines": {
6+
"node": ">=18.18.0"
7+
},
58
"source": "src/index.tsx",
69
"main": "dist/index.js",
710
"unpkg": "dist/index.umd.js",
@@ -18,7 +21,8 @@
1821
"prettier:check": "prettier --check 'src/**/*'",
1922
"prettify": "prettier --write 'src/**/*'",
2023
"ts-check": "tsc -p tsconfig.json --noEmit",
21-
"test": "jest"
24+
"test": "jest",
25+
"prepare": "husky"
2226
},
2327
"repository": {
2428
"type": "git",
@@ -39,64 +43,54 @@
3943
},
4044
"homepage": "https://github.com/ankeetmaini/react-infinite-scroll-component#readme",
4145
"peerDependencies": {
42-
"react": ">=16.0.0"
46+
"react": "^17.0.0",
47+
"react-dom": "^17.0.0"
4348
},
4449
"devDependencies": {
45-
"@babel/core": "^7.6.2",
50+
"@babel/core": "^7.20.0",
4651
"@storybook/addon-actions": "^5.2.1",
4752
"@storybook/addon-info": "^5.2.1",
4853
"@storybook/addon-links": "^5.2.1",
4954
"@storybook/addons": "^5.2.1",
50-
"@storybook/react": "^5.2.1",
51-
"@testing-library/react": "^9.2.0",
52-
"@types/jest": "^24.0.18",
53-
"@types/react": "^16.9.2",
54-
"@types/react-dom": "^16.9.1",
55+
"@storybook/react": "^7.0.0",
56+
"@testing-library/react": "^12.1.5",
57+
"@types/jest": "^29.5.14",
58+
"@types/react": "^17.0.0",
59+
"@types/react-dom": "^17.0.0",
5560
"@types/storybook__react": "^4.0.2",
5661
"@types/throttle-debounce": "^2.1.0",
57-
"@typescript-eslint/eslint-plugin": "^2.3.2",
58-
"@typescript-eslint/parser": "^2.3.2",
62+
"@typescript-eslint/eslint-plugin": "^8.50.1",
63+
"@typescript-eslint/parser": "^8.50.1",
5964
"awesome-typescript-loader": "^5.2.1",
6065
"babel-loader": "^8.0.6",
61-
"eslint": "^6.5.1",
62-
"eslint-config-prettier": "^6.3.0",
63-
"eslint-plugin-react": "^7.15.0",
64-
"husky": ">=1",
65-
"jest": "^24.9.0",
66-
"lint-staged": ">=8",
67-
"prettier": "1.18.2",
68-
"react": "^16.10.1",
66+
"eslint": "^8",
67+
"eslint-config-prettier": "^10.1.8",
68+
"eslint-plugin-react": "^7.37.5",
69+
"husky": "^9.0.0",
70+
"jest": "^29.7.0",
71+
"jest-environment-jsdom": "^29.7.0",
72+
"lint-staged": "^15.0.0",
73+
"prettier": "^2.8.0",
74+
"react": "^17.0.2",
6975
"react-docgen-typescript-loader": "^3.2.1",
70-
"react-dom": "^16.10.1",
76+
"react-dom": "^17.0.2",
7177
"rimraf": "^3.0.0",
7278
"rollup": "^1.26.3",
7379
"rollup-plugin-node-resolve": "^5.2.0",
7480
"rollup-plugin-typescript2": "^0.25.2",
75-
"ts-jest": "^24.1.0",
76-
"typescript": "^3.7.2"
81+
"ts-jest": "^29.4.6",
82+
"typescript": "^4.9.0"
7783
},
7884
"dependencies": {
7985
"throttle-debounce": "^2.1.0"
8086
},
81-
"husky": {
82-
"hooks": {
83-
"pre-commit": "yarn run ts-check && lint-staged"
84-
}
85-
},
8687
"lint-staged": {
8788
"*.{js,css,json,md}": [
88-
"prettier --write",
89-
"git add"
90-
],
91-
"*.js": [
92-
"prettier --write",
93-
"eslint --fix",
94-
"git add"
89+
"prettier --write"
9590
],
9691
"*.{ts,tsx}": [
9792
"prettier --write",
98-
"eslint --fix",
99-
"git add"
93+
"eslint --fix"
10094
]
10195
}
10296
}

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ export default {
2121
name: 'InfiniteScroll',
2222
},
2323
],
24-
external: [...Object.keys(pkg.peerDependencies || {})],
24+
external: [...Object.keys(pkg.peerDependencies || {}), 'react/jsx-runtime'],
2525
plugins: [resolve(), typescript({ useTsconfigDeclarationDir: true })],
2626
};

src/__tests__/bottom.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { render, cleanup } from '@testing-library/react';
32
import InfiniteScroll from '../index';
43

src/__tests__/hasChildren.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { render, cleanup } from '@testing-library/react';
32
import InfiniteScroll from '../index';
43

src/__tests__/index.test.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { render, cleanup } from '@testing-library/react';
32
import InfiniteScroll from '../index';
43

@@ -57,6 +56,7 @@ describe('React Infinite Scroll Component', () => {
5756

5857
it('calls scroll handler if provided, when user scrolls', () => {
5958
jest.useFakeTimers();
59+
const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
6060
const onScrollMock = jest.fn();
6161

6262
const { container } = render(
@@ -79,21 +79,23 @@ describe('React Infinite Scroll Component', () => {
7979

8080
node.dispatchEvent(scrollEvent);
8181
jest.runOnlyPendingTimers();
82-
expect(setTimeout).toHaveBeenCalledTimes(1);
82+
expect(setTimeoutSpy).toHaveBeenCalled();
8383
expect(onScrollMock).toHaveBeenCalled();
84+
setTimeoutSpy.mockRestore();
8485
});
8586

8687
describe('When missing the dataLength prop', () => {
8788
it('throws an error', () => {
88-
console.error = jest.fn();
89+
const consoleSpy = jest
90+
.spyOn(console, 'error')
91+
.mockImplementation(() => {});
8992
const props = { loader: 'Loading...', hasMore: false, next: () => {} };
9093

9194
// @ts-ignore
92-
expect(() => render(<InfiniteScroll {...props} />)).toThrow(Error);
93-
// @ts-ignore
94-
expect(console.error.mock.calls[0][0]).toContain(
95-
'"dataLength" is missing'
95+
expect(() => render(<InfiniteScroll {...props} />)).toThrow(
96+
'mandatory prop "dataLength" is missing'
9697
);
98+
consoleSpy.mockRestore();
9799
});
98100
});
99101

0 commit comments

Comments
 (0)