Skip to content

Commit bb01e17

Browse files
author
Erik Soehnel
committed
basic Vite + React setup
With prettier and strict ESlint rules.
1 parent 7a5f3d9 commit bb01e17

19 files changed

+5433
-3
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ out
9999
.nuxt
100100
dist
101101

102-
# react / gatsby
103-
public/
104-
105102
# Gatsby files
106103
.cache/
107104
# Comment in the public line in if your project uses Gatsby and not Next.js

app/.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

app/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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/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
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+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default tseslint.config({
18+
languageOptions: {
19+
// other options...
20+
parserOptions: {
21+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
})
26+
```
27+
28+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31+
32+
```js
33+
// eslint.config.js
34+
import react from 'eslint-plugin-react'
35+
36+
export default tseslint.config({
37+
// Set the react version
38+
settings: { react: { version: '18.3' } },
39+
plugins: {
40+
// Add the react plugin
41+
react,
42+
},
43+
rules: {
44+
// other rules...
45+
// Enable its recommended rules
46+
...react.configs.recommended.rules,
47+
...react.configs['jsx-runtime'].rules,
48+
},
49+
})
50+
```

app/eslint.config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import tseslint from "typescript-eslint";
6+
import react from "eslint-plugin-react";
7+
8+
export default tseslint.config(
9+
{ ignores: ["dist"] },
10+
{
11+
extends: [
12+
js.configs.recommended,
13+
...tseslint.configs.strictTypeChecked,
14+
...tseslint.configs.stylisticTypeChecked,
15+
],
16+
files: ["**/*.{ts,tsx}"],
17+
languageOptions: {
18+
ecmaVersion: 2020,
19+
globals: globals.browser,
20+
parserOptions: {
21+
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
settings: { react: { version: "18.3" } },
26+
plugins: {
27+
react: react,
28+
"react-hooks": reactHooks,
29+
"react-refresh": reactRefresh,
30+
},
31+
rules: {
32+
...reactHooks.configs.recommended.rules,
33+
"react-refresh/only-export-components": [
34+
"warn",
35+
{ allowConstantExport: true },
36+
],
37+
},
38+
},
39+
);

app/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)