Skip to content

Commit 5722579

Browse files
committed
chore: upgrade to React 17 for v7.0.0
1 parent fb9d192 commit 5722579

18 files changed

+4202
-8984
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: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ module.exports = {
2121
],
2222
settings: {
2323
react: {
24-
version: 'detect',
24+
version: '17.0',
2525
},
2626
},
2727
rules: {
28-
'@typescript-eslint/prefer-regexp-exec': 1,
29-
'@typescript-eslint/ban-ts-comment': 0,
30-
'@typescript-eslint/unbound-method': 1,
31-
'react/prop-types': 0, // Using TypeScript for prop validation
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',
3239
},
33-
ignorePatterns: ['**/*.test.ts', '**/*.test.tsx'],
3440
};

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
registry-url: 'https://registry.npmjs.org'
2323

2424
- name: Install dependencies
25-
run: yarn install
25+
run: yarn install --frozen-lockfile
2626

2727
- name: Build
2828
run: yarn build

.github/workflows/push.yml

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

1616
steps:
1717
- uses: actions/checkout@v4
@@ -23,7 +23,7 @@ jobs:
2323
cache: 'yarn'
2424

2525
- name: Install dependencies
26-
run: yarn install
26+
run: yarn install --frozen-lockfile
2727

2828
- name: Lint
2929
run: yarn lint

.github/workflows/test.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

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: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@
3939
},
4040
"homepage": "https://github.com/ankeetmaini/react-infinite-scroll-component#readme",
4141
"peerDependencies": {
42-
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
43-
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
42+
"react": "^17.0.0",
43+
"react-dom": "^17.0.0"
4444
},
4545
"devDependencies": {
46-
"@babel/core": "^7.6.2",
46+
"@babel/core": "^7.20.0",
4747
"@storybook/addon-actions": "^5.2.1",
4848
"@storybook/addon-info": "^5.2.1",
4949
"@storybook/addon-links": "^5.2.1",
5050
"@storybook/addons": "^5.2.1",
51-
"@storybook/react": "^5.2.1",
52-
"@testing-library/react": "^9.2.0",
53-
"@types/jest": "^24.0.18",
54-
"@types/react": "^18.2.0",
55-
"@types/react-dom": "^18.2.0",
51+
"@storybook/react": "^7.0.0",
52+
"@testing-library/react": "^12.1.5",
53+
"@types/jest": "^29.5.14",
54+
"@types/react": "^17.0.0",
55+
"@types/react-dom": "^17.0.0",
5656
"@types/storybook__react": "^4.0.2",
5757
"@types/throttle-debounce": "^2.1.0",
5858
"@typescript-eslint/eslint-plugin": "^8.50.1",
@@ -63,25 +63,23 @@
6363
"eslint-config-prettier": "^10.1.8",
6464
"eslint-plugin-react": "^7.37.5",
6565
"husky": ">=1",
66-
"jest": "^24.9.0",
66+
"jest": "^29.7.0",
67+
"jest-environment-jsdom": "^29.7.0",
6768
"lint-staged": ">=8",
68-
"prettier": "1.18.2",
69-
"react": "^18.2.0",
69+
"prettier": "^2.8.0",
70+
"react": "^17.0.2",
7071
"react-docgen-typescript-loader": "^3.2.1",
71-
"react-dom": "^18.2.0",
72+
"react-dom": "^17.0.2",
7273
"rimraf": "^3.0.0",
7374
"rollup": "^1.26.3",
7475
"rollup-plugin-node-resolve": "^5.2.0",
7576
"rollup-plugin-typescript2": "^0.25.2",
76-
"ts-jest": "^24.1.0",
77-
"typescript": "^5.0.0"
77+
"ts-jest": "^29.4.6",
78+
"typescript": "^4.9.0"
7879
},
7980
"dependencies": {
8081
"throttle-debounce": "^2.1.0"
8182
},
82-
"engines": {
83-
"node": ">=18.18.0"
84-
},
8583
"husky": {
8684
"hooks": {
8785
"pre-commit": "yarn run ts-check && lint-staged"

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)