Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/create-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,11 @@ function setupReactCompiler(root: string, isTs: boolean) {
)
updateReactCompilerReadme(
root,
'The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.\n\nNote: This will impact Vite dev & build performances.',
`The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.

Note: This will impact Vite dev & build performances.

Additionally, you may want to switch linting to ESLint to use [lint rules powered by the React Compiler](https://react.dev/reference/eslint-plugin-react-hooks).`,
)
}

Expand All @@ -824,12 +828,15 @@ function updateReactCompilerReadme(root: string, newBody: string) {
const h2Start = content.indexOf('## React Compiler')
const bodyStart = content.indexOf('\n\n', h2Start)
const compilerSectionEnd = content.indexOf('\n## ', bodyStart)
if (h2Start === -1 || bodyStart === -1 || compilerSectionEnd === -1) {
if (h2Start === -1 || bodyStart === -1) {
console.warn('Could not update compiler section in README.md')
return content
}
return content.replace(
content.slice(bodyStart + 2, compilerSectionEnd - 1),
content.slice(
bodyStart + 2,
compilerSectionEnd === -1 ? undefined : compilerSectionEnd - 1,
),
newBody,
)
})
Expand Down
14 changes: 14 additions & 0 deletions packages/create-vite/template-react-ts/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"env": {
"browser": true
},
"ignorePatterns": ["dist"],
"plugins": ["unicorn", "typescript", "oxc", "react"],
"categories": {},
"rules": {
"react/jsx-no-target-blank": "off",
"react/only-export-components": ["warn", { "allowConstantExport": true }],
"react/rules-of-hooks": "error"
}
}
63 changes: 1 addition & 62 deletions packages/create-vite/template-react-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,4 @@ Currently, two official plugins are available:

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```

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:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). Additionally, you may want to switch linting to ESLint to use [lint rules powered by the React Compiler](https://react.dev/reference/eslint-plugin-react-hooks).
23 changes: 0 additions & 23 deletions packages/create-vite/template-react-ts/eslint.config.js

This file was deleted.

9 changes: 2 additions & 7 deletions packages/create-vite/template-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"lint": "oxlint --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@eslint/js": "^9.38.0",
"@types/node": "^24.9.1",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^5.1.0",
"eslint": "^9.38.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.4.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.46.2",
"oxlint": "^1.25.0",
"vite": "^7.1.12"
}
}
14 changes: 14 additions & 0 deletions packages/create-vite/template-react/.oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"env": {
"browser": true
},
"ignorePatterns": ["dist"],
"plugins": ["unicorn", "oxc", "react"],
"categories": {},
"rules": {
"react/jsx-no-target-blank": "off",
"react/only-export-components": ["warn", { "allowConstantExport": true }],
"react/rules-of-hooks": "error"
}
}
6 changes: 1 addition & 5 deletions packages/create-vite/template-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ Currently, two official plugins are available:

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). If you are developing a production application, we recommend starting with the TypeScript template instead.
29 changes: 0 additions & 29 deletions packages/create-vite/template-react/eslint.config.js

This file was deleted.

8 changes: 2 additions & 6 deletions packages/create-vite/template-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"lint": "oxlint --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@eslint/js": "^9.38.0",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^5.1.0",
"eslint": "^9.38.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.4.0",
"oxlint": "^1.25.0",
"vite": "^7.1.12"
}
}
16 changes: 16 additions & 0 deletions packages/create-vite/vite-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@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

## React Compiler

The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.

Note: This will impact Vite dev & build performances.

Additionally, you may want to switch linting to ESLint to use [lint rules powered by the React Compiler](https://react.dev/reference/eslint-plugin-react-hooks).