Skip to content

Commit 2fd39cd

Browse files
artem-kurchenkoAlisherAmonulloevDevExpressExampleBot
authored
Migrate from create-react-app to vite (#43)
* migrate to vite * README auto update [skip ci] * test new app * update yml to install node * update tsconfig * Update package.json * Update package-lock.json * Update .eslintrc.cjs * remove files and fix lint errors * updates and fixes * add optionaldepth * fix lint rules for JSX and depths * update package files * update tsc and lint rules * update readme --------- Co-authored-by: AlisherAmonulloev <AlisherAmonulloev@users.noreply.github.com> Co-authored-by: DevExpressExampleBot <fake@test.test>
1 parent a0d1059 commit 2fd39cd

27 files changed

+8595
-14586
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ jobs:
7373
uses: actions/checkout@v3
7474

7575
- name: Use Node.js
76-
uses: actions/setup-node@v3
76+
uses: actions/setup-node@v4
77+
with:
78+
node-version: '20'
7779

7880
- name: Restore npm cache
7981
uses: actions/cache@v3

.github/workflows/typescript.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ jobs:
4444
uses: actions/checkout@v3
4545

4646
- name: Use Node.js
47-
uses: actions/setup-node@v3
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '20'
4850

4951
- name: Restore npm cache
5052
uses: actions/cache@v3

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!-- default badges list -->
2-
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/340354634/24.2.3%2B)
32
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1129779)
43
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
54
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)

React/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/*
22
build/*
33
.eslintrc.js
4+
dist/assets/*

React/.eslintrc.js renamed to React/.eslintrc.cjs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ module.exports = {
1111
parserOptions: {
1212
project: './tsconfig.json',
1313
'createDefaultProgram': true,
14-
'ecmaVersion': 6,
14+
ecmaVersion: 2022,
15+
sourceType: 'module',
16+
},
17+
rules: {
18+
"react/react-in-jsx-scope": "off",
19+
"import/no-extraneous-dependencies": ["error", {
20+
"devDependencies": [
21+
"**/vitest.config.ts", // allow vitest in config file
22+
"**/vite.config.ts", // allow vite in config file
23+
"**/*.test.tsx", // allow test files if needed
24+
"**/setupTests.ts", // allow setup tests file
25+
]
26+
}]
1527
},
1628
globals: {
1729
System: false,
@@ -22,15 +34,11 @@ module.exports = {
2234
react: {
2335
createClass: 'createReactClass',
2436
'pragma': 'React',
25-
version: '16.2',
26-
flowVersion: '0.53',
37+
version: '18.2',
2738
},
2839
propWrapperFunctions: [
2940
'forbidExtraProps',
3041
],
3142
},
32-
}, {
33-
files: ['*.test.tsx'],
34-
extends: ['devextreme/jest']
3543
}]
36-
};
44+
};

React/.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?

React/README.md

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,60 @@
1-
# React
2-
3-
Take a look at the following files of this example to see the required code:
4-
5-
Your files go here
6-
7-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
8-
9-
## Available Scripts
10-
11-
In the project directory, you can run:
12-
13-
### `npm start`
14-
15-
Runs the app in the development mode.<br>
16-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
17-
18-
The page will reload if you make edits.<br>
19-
You will also see any lint errors in the console.
20-
21-
### `npm run build`
22-
23-
Builds the app for production to the `build` folder.<br>
24-
It correctly bundles React in production mode and optimizes the build for the best performance.
25-
26-
The build is minified and the filenames include the hashes.<br>
27-
Your app is ready to be deployed!
28-
29-
See the section about [deployment](https://create-react-app.dev/docs/deployment/) for more information.
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
13+
14+
```js
15+
export default tseslint.config({
16+
extends: [
17+
// Remove ...tseslint.configs.recommended and replace with this
18+
...tseslint.configs.recommendedTypeChecked,
19+
// Alternatively, use this for stricter rules
20+
...tseslint.configs.strictTypeChecked,
21+
// Optionally, add this for stylistic rules
22+
...tseslint.configs.stylisticTypeChecked,
23+
],
24+
languageOptions: {
25+
// other options...
26+
parserOptions: {
27+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
28+
tsconfigRootDir: import.meta.dirname,
29+
},
30+
},
31+
})
32+
```
33+
34+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
35+
36+
```js
37+
// eslint.config.js
38+
import reactX from 'eslint-plugin-react-x'
39+
import reactDom from 'eslint-plugin-react-dom'
40+
41+
export default tseslint.config({
42+
plugins: {
43+
// Add the react-x and react-dom plugins
44+
'react-x': reactX,
45+
'react-dom': reactDom,
46+
},
47+
rules: {
48+
// other rules...
49+
// Enable its recommended typescript rules
50+
...reactX.configs['recommended-typescript'].rules,
51+
...reactDom.configs.recommended.rules,
52+
},
53+
})
54+
```
3055

3156
## Further help
3257

33-
You can learn more about React in the [Create React App documentation](https://create-react-app.dev/docs/getting-started/).
34-
35-
To get more help on DevExtreme submit an issue on [GitHub](https://github.com/DevExpress/devextreme/issues) or [Support Center](https://www.devexpress.com/Support/Center/Question/Create)
36-
37-
58+
You can learn more about React in the [React documentation](https://18.react.dev/learn).
3859

60+
To get more help on DevExtreme submit an issue in the [Support Center](https://www.devexpress.com/Support/Center/Question/Create)

React/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>

0 commit comments

Comments
 (0)