Skip to content

Commit feeba29

Browse files
committed
Updating all deps and moving from CRA to vite for example
1 parent b065db4 commit feeba29

30 files changed

+3825
-26230
lines changed

example/.eslintrc.cjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
ignorePatterns: ['dist', '.eslintrc.cjs'],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': [
14+
'warn',
15+
{ allowConstantExport: true },
16+
],
17+
},
18+
}

example/.gitignore

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
8-
# testing
9-
/coverage
10-
11-
# production
12-
/build
13-
14-
# misc
15-
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
20-
1+
# Logs
2+
logs
3+
*.log
214
npm-debug.log*
225
yarn-debug.log*
236
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

example/README.md

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,30 @@
1-
# Getting Started with Create React App
1+
# React + TypeScript + Vite
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
44

5-
## Available Scripts
5+
Currently, two official plugins are available:
66

7-
In the project directory, you can run:
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
89

9-
### `yarn start`
10+
## Expanding the ESLint configuration
1011

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
1313

14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
14+
- Configure the top-level `parserOptions` property like this:
1615

17-
### `yarn test`
16+
```js
17+
export default {
18+
// other rules...
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
sourceType: 'module',
22+
project: ['./tsconfig.json', './tsconfig.node.json'],
23+
tsconfigRootDir: __dirname,
24+
},
25+
}
26+
```
1827

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-
### `yarn 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-
### `yarn 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/).
28+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

example/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

example/package.json

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,28 @@
11
{
22
"name": "example",
3-
"version": "0.1.0",
43
"private": true,
5-
"dependencies": {
6-
"react": "^18.1.0",
7-
"react-dom": "^18.1.0"
8-
},
4+
"version": "0.0.0",
5+
"type": "module",
96
"scripts": {
10-
"start": "react-scripts start",
11-
"build": "react-scripts build",
12-
"test": "react-scripts test",
13-
"eject": "react-scripts eject",
14-
"lint": ""
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10+
"preview": "vite preview"
1511
},
16-
"eslintConfig": {
17-
"extends": [
18-
"react-app",
19-
"react-app/jest"
20-
]
21-
},
22-
"browserslist": {
23-
"production": [
24-
">0.2%",
25-
"not dead",
26-
"not op_mini all"
27-
],
28-
"development": [
29-
"last 1 chrome version",
30-
"last 1 firefox version",
31-
"last 1 safari version"
32-
]
12+
"dependencies": {
13+
"react": "^18.2.0",
14+
"react-dom": "^18.2.0"
3315
},
3416
"devDependencies": {
35-
"@testing-library/jest-dom": "^5.16.4",
36-
"@testing-library/react": "^13.2.0",
37-
"@testing-library/user-event": "^14.2.0",
38-
"@types/jest": "^27.5.1",
39-
"@types/node": "^17.0.33",
40-
"@types/react": "^18.0.9",
41-
"@types/react-dom": "^18.0.4",
42-
"react-scripts": "^5.0.1",
43-
"typescript": "^4.6.4",
44-
"web-vitals": "^2.1.4"
17+
"@types/react": "^18.2.43",
18+
"@types/react-dom": "^18.2.17",
19+
"@typescript-eslint/eslint-plugin": "^6.14.0",
20+
"@typescript-eslint/parser": "^6.14.0",
21+
"@vitejs/plugin-react": "^4.2.1",
22+
"eslint": "^8.55.0",
23+
"eslint-plugin-react-hooks": "^4.6.0",
24+
"eslint-plugin-react-refresh": "^0.4.5",
25+
"typescript": "^5.2.2",
26+
"vite": "^5.0.8"
4527
}
4628
}

example/public/favicon.ico

-3.78 KB
Binary file not shown.

example/public/index.html

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

example/public/logo192.png

-5.22 KB
Binary file not shown.

example/public/logo512.png

-9.44 KB
Binary file not shown.

example/public/manifest.json

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

0 commit comments

Comments
 (0)