Skip to content

Commit 1c3c27b

Browse files
committed
refactor: migrate to Create React App v5
1 parent 138b0d3 commit 1c3c27b

File tree

11 files changed

+3319
-6056
lines changed

11 files changed

+3319
-6056
lines changed

.browserslistrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# https://github.com/browserslist/browserslist#readme
22

3-
>= 0.5%
4-
last 2 major versions
3+
[production]
4+
>0.2%
55
not dead
6-
Chrome >= 60
7-
Firefox >= 60
8-
Firefox ESR
9-
iOS >= 12
10-
Safari >= 12
11-
not Explorer <= 11
6+
not op_mini all
7+
8+
[development]
9+
last 1 chrome version
10+
last 1 firefox version
11+
last 1 safari version

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
},
1515
extends: [
1616
'react-app',
17+
'react-app/jest',
1718
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
1819
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
1920
],

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# dependencies
44
/node_modules
5-
package-lock.json
5+
/.pnp
6+
.pnp.js
67

78
# testing
89
/coverage

CRA.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13+
14+
The page will reload when you make changes.\
15+
You may also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
35+
36+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39+
40+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63+
64+
### Deployment
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67+
68+
### `npm run build` fails to minify
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
"@coreui/react": "^4.1.0",
3636
"@coreui/react-chartjs": "^2.0.0",
3737
"@coreui/utils": "^1.3.1",
38-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
3938
"chart.js": "^3.6.0",
4039
"classnames": "^2.3.1",
4140
"core-js": "^3.19.1",
42-
"enzyme": "^3.11.0",
4341
"prop-types": "^15.7.2",
4442
"react": "^17.0.2",
4543
"react-app-polyfill": "^2.0.0",
@@ -50,13 +48,16 @@
5048
"simplebar-react": "^2.3.6"
5149
},
5250
"devDependencies": {
51+
"@testing-library/jest-dom": "^5.16.1",
52+
"@testing-library/react": "^12.1.2",
53+
"@testing-library/user-event": "^13.5.0",
5354
"auto-changelog": "~2.3.0",
54-
"eslint": "^7.32.0",
5555
"eslint-config-prettier": "^8.3.0",
5656
"eslint-plugin-prettier": "^4.0.0",
5757
"prettier": "2.5.0",
58-
"react-scripts": "^4.0.3",
59-
"sass": "^1.43.5"
58+
"react-scripts": "5.0.0",
59+
"sass": "^1.43.5",
60+
"web-vitals": "^2.1.2"
6061
},
6162
"engines": {
6263
"node": ">=10",

src/App.test.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import React from 'react'
2-
import { shallow } from 'enzyme/build'
2+
import { render, screen } from '@testing-library/react'
33
import App from './App'
4-
import Dashboard from './views/dashboard/Dashboard.js'
54

6-
it('mounts App without crashing', () => {
7-
const wrapper = shallow(<App />)
8-
wrapper.unmount()
9-
})
10-
11-
it('mounts Dashboard without crashing', () => {
12-
const wrapper = shallow(<Dashboard />)
13-
wrapper.unmount()
5+
test('renders learn react link', () => {
6+
render(<App />)
7+
const linkElement = screen.getByText(/learn react/i)
8+
expect(linkElement).toBeInTheDocument()
149
})

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'core-js'
33
import React from 'react'
44
import ReactDOM from 'react-dom'
55
import App from './App'
6-
import * as serviceWorker from './serviceWorker'
6+
import reportWebVitals from './reportWebVitals'
77
import { Provider } from 'react-redux'
88
import store from './store'
99

@@ -14,7 +14,7 @@ ReactDOM.render(
1414
document.getElementById('root'),
1515
)
1616

17-
// If you want your app to work offline and load faster, you can change
18-
// unregister() to register() below. Note this comes with some pitfalls.
19-
// Learn more about service workers: http://bit.ly/CRA-PWA
20-
serviceWorker.unregister()
17+
// If you want to start measuring performance in your app, pass a function
18+
// to log results (for example: reportWebVitals(console.log))
19+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20+
reportWebVitals()

src/reportWebVitals.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const reportWebVitals = (onPerfEntry) => {
2+
if (onPerfEntry && onPerfEntry instanceof Function) {
3+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4+
getCLS(onPerfEntry)
5+
getFID(onPerfEntry)
6+
getFCP(onPerfEntry)
7+
getLCP(onPerfEntry)
8+
getTTFB(onPerfEntry)
9+
})
10+
}
11+
}
12+
13+
export default reportWebVitals

src/serviceWorker.js

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

src/setupTests.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
import { configure } from 'enzyme'
2-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'
3-
4-
configure({ adapter: new Adapter() })
5-
6-
if (global.document) {
7-
document.createRange = () => ({
8-
setStart: () => {},
9-
setEnd: () => {},
10-
commonAncestorContainer: {
11-
nodeName: 'BODY',
12-
ownerDocument: document,
13-
},
14-
})
15-
}
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import '@testing-library/jest-dom';

0 commit comments

Comments
 (0)