Skip to content

Commit 10aa2c3

Browse files
committed
feat: Add React+TypeScript+Vite project template
Initialize the basic structure of React+TypeScript+Vite project, including: - Vite configuration file and type declaration - TypeScript configuration file - ESLint configuration - Basic React components and styles - Project documentation and example code - Development environment configuration
1 parent bce3359 commit 10aa2c3

File tree

18 files changed

+2948
-5
lines changed

18 files changed

+2948
-5
lines changed

.vscode/settings.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
// Disable the default formatter, use eslint instead
3+
"prettier.enable": false,
4+
"editor.formatOnSave": false,
5+
6+
// Auto fix
7+
"editor.codeActionsOnSave": {
8+
"source.fixAll.eslint": "explicit",
9+
"source.organizeImports": "never"
10+
},
11+
12+
"eslint.runtime": "node",
13+
14+
/**
15+
These rules are mainly related to code style
16+
(such as indentation, spaces, quotation marks, semicolon, etc.),
17+
and hiding their error prompts can avoid excessive warnings
18+
in the editor while still maintaining the automatic repair function.
19+
**/
20+
"eslint.rules.customizations": [
21+
{ "rule": "style/*", "severity": "off", "fixable": true },
22+
{ "rule": "*-indent", "severity": "off", "fixable": true },
23+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
24+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
25+
{ "rule": "*-order", "severity": "off", "fixable": true },
26+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
27+
{ "rule": "*-newline", "severity": "off", "fixable": true },
28+
{ "rule": "*quotes", "severity": "off", "fixable": true },
29+
{ "rule": "*semi", "severity": "off", "fixable": true }
30+
],
31+
32+
// Enable eslint for all supported languages
33+
"eslint.validate": [
34+
"javascript",
35+
"javascriptreact",
36+
"typescript",
37+
"typescriptreact",
38+
"html",
39+
],
40+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { avenger } from '@sj-distributor/eslint-config';
2+
3+
export default avenger(
4+
{
5+
ignores: ['dist'],
6+
},
7+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1, user-scalable=no" />
6+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Vite + React + TS</title>
9+
</head>
10+
<body>
11+
<div id="root"></div>
12+
<script type="module" src="/src/main.tsx"></script>
13+
</body>
14+
</html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "template-react-ts",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"react": "^19.1.0",
14+
"react-dom": "^19.1.0"
15+
},
16+
"devDependencies": {
17+
"@sj-distributor/eslint-config": "^0.2.0",
18+
"@types/react": "^19.1.2",
19+
"@types/react-dom": "^19.1.2",
20+
"@vitejs/plugin-react": "^4.4.1",
21+
"eslint": "^9.28.0",
22+
"eslint-plugin-react-hooks": "^5.2.0",
23+
"eslint-plugin-react-refresh": "^0.4.19",
24+
"globals": "^16.0.0",
25+
"typescript": "~5.8.3",
26+
"typescript-eslint": "^8.30.1",
27+
"vite": "^6.3.5"
28+
}
29+
}

0 commit comments

Comments
 (0)