Skip to content

Commit b1002ee

Browse files
committed
feat(create-vite): eslint -> oxlint
1 parent b1fd616 commit b1002ee

File tree

9 files changed

+47
-135
lines changed

9 files changed

+47
-135
lines changed

packages/create-vite/src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,11 @@ function setupReactCompiler(root: string, isTs: boolean) {
815815
)
816816
updateReactCompilerReadme(
817817
root,
818-
'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.',
818+
`The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
819+
820+
Note: This will impact Vite dev & build performances.
821+
822+
Additionaly, 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).`,
819823
)
820824
}
821825

@@ -824,12 +828,16 @@ function updateReactCompilerReadme(root: string, newBody: string) {
824828
const h2Start = content.indexOf('## React Compiler')
825829
const bodyStart = content.indexOf('\n\n', h2Start)
826830
const compilerSectionEnd = content.indexOf('\n## ', bodyStart)
827-
if (h2Start === -1 || bodyStart === -1 || compilerSectionEnd === -1) {
831+
if (h2Start === -1 || bodyStart === -1) {
832+
console.log(content, h2Start, bodyStart)
828833
console.warn('Could not update compiler section in README.md')
829834
return content
830835
}
831836
return content.replace(
832-
content.slice(bodyStart + 2, compilerSectionEnd - 1),
837+
content.slice(
838+
bodyStart + 2,
839+
compilerSectionEnd === -1 ? undefined : compilerSectionEnd - 1,
840+
),
833841
newBody,
834842
)
835843
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"env": {
4+
"browser": true
5+
},
6+
"ignorePatterns": ["dist"],
7+
"plugins": ["unicorn", "typescript", "oxc", "react"],
8+
"categories": {},
9+
"rules": {
10+
"react/jsx-no-target-blank": "off",
11+
"react/only-export-components": "warn",
12+
"react/exhaustive-deps": "warn",
13+
"react/rules-of-hooks": "error"
14+
}
15+
}

packages/create-vite/template-react-ts/README.md

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,4 @@ Currently, two official plugins are available:
99

1010
## React Compiler
1111

12-
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).
13-
14-
## Expanding the ESLint configuration
15-
16-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17-
18-
```js
19-
export default defineConfig([
20-
globalIgnores(['dist']),
21-
{
22-
files: ['**/*.{ts,tsx}'],
23-
extends: [
24-
// Other configs...
25-
26-
// Remove tseslint.configs.recommended and replace with this
27-
tseslint.configs.recommendedTypeChecked,
28-
// Alternatively, use this for stricter rules
29-
tseslint.configs.strictTypeChecked,
30-
// Optionally, add this for stylistic rules
31-
tseslint.configs.stylisticTypeChecked,
32-
33-
// Other configs...
34-
],
35-
languageOptions: {
36-
parserOptions: {
37-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
38-
tsconfigRootDir: import.meta.dirname,
39-
},
40-
// other options...
41-
},
42-
},
43-
])
44-
```
45-
46-
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:
47-
48-
```js
49-
// eslint.config.js
50-
import reactX from 'eslint-plugin-react-x'
51-
import reactDom from 'eslint-plugin-react-dom'
52-
53-
export default defineConfig([
54-
globalIgnores(['dist']),
55-
{
56-
files: ['**/*.{ts,tsx}'],
57-
extends: [
58-
// Other configs...
59-
// Enable lint rules for React
60-
reactX.configs['recommended-typescript'],
61-
// Enable lint rules for React DOM
62-
reactDom.configs.recommended,
63-
],
64-
languageOptions: {
65-
parserOptions: {
66-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
67-
tsconfigRootDir: import.meta.dirname,
68-
},
69-
// other options...
70-
},
71-
},
72-
])
73-
```
12+
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). Additionaly, 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).

packages/create-vite/template-react-ts/eslint.config.js

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

packages/create-vite/template-react-ts/package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,20 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc -b && vite build",
9-
"lint": "eslint .",
9+
"lint": "oxlint --max-warnings 0",
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
1313
"react": "^19.2.0",
1414
"react-dom": "^19.2.0"
1515
},
1616
"devDependencies": {
17-
"@eslint/js": "^9.38.0",
1817
"@types/node": "^24.9.1",
1918
"@types/react": "^19.2.2",
2019
"@types/react-dom": "^19.2.2",
2120
"@vitejs/plugin-react": "^5.1.0",
22-
"eslint": "^9.38.0",
23-
"eslint-plugin-react-hooks": "^5.2.0",
24-
"eslint-plugin-react-refresh": "^0.4.24",
25-
"globals": "^16.4.0",
2621
"typescript": "~5.9.3",
27-
"typescript-eslint": "^8.46.2",
22+
"oxlint": "^1.25.0",
2823
"vite": "^7.1.12"
2924
}
3025
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"env": {
4+
"browser": true
5+
},
6+
"ignorePatterns": ["dist"],
7+
"plugins": ["unicorn", "oxc", "react"],
8+
"categories": {},
9+
"rules": {
10+
"react/jsx-no-target-blank": "off",
11+
"react/only-export-components": "warn",
12+
"react/exhaustive-deps": "warn",
13+
"react/rules-of-hooks": "error"
14+
}
15+
}

packages/create-vite/template-react/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@ Currently, two official plugins are available:
99

1010
## React Compiler
1111

12-
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).
13-
14-
## Expanding the ESLint configuration
15-
16-
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.
12+
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.

packages/create-vite/template-react/eslint.config.js

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

packages/create-vite/template-react/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vite build",
9-
"lint": "eslint .",
9+
"lint": "oxlint --max-warnings 0",
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
1313
"react": "^19.2.0",
1414
"react-dom": "^19.2.0"
1515
},
1616
"devDependencies": {
17-
"@eslint/js": "^9.38.0",
1817
"@types/react": "^19.2.2",
1918
"@types/react-dom": "^19.2.2",
2019
"@vitejs/plugin-react": "^5.1.0",
21-
"eslint": "^9.38.0",
22-
"eslint-plugin-react-hooks": "^5.2.0",
23-
"eslint-plugin-react-refresh": "^0.4.24",
24-
"globals": "^16.4.0",
20+
"oxlint": "^1.25.0",
2521
"vite": "^7.1.12"
2622
}
2723
}

0 commit comments

Comments
 (0)