Skip to content

Commit 9f6a689

Browse files
committed
fix config & doc
1 parent b54b3f0 commit 9f6a689

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,37 @@ If you are developing a production application, we recommend updating the config
1414
- Configure the top-level `parserOptions` property like this:
1515

1616
```js
17-
export default {
18-
// other rules...
19-
parserOptions: {
20-
ecmaVersion: 'latest',
21-
sourceType: 'module',
22-
project: ['./tsconfig.json', './tsconfig.node.json', './tsconfig.app.json'],
23-
tsconfigRootDir: __dirname,
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+
},
2424
},
25-
}
25+
})
2626
```
2727

28-
- Replace `tseslint.configs.recommended.rules` to `tseslint.configs['recommended-type-checked'].rules` or `tseslint.configs['strict-type-checked'].rules`
29-
- Optionally add `tseslint.configs['stylistic-type-checked'].rules`
28+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
3030
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
3131

3232
```js
3333
// eslint.config.js
3434
import react from 'eslint-plugin-react'
3535

36-
export default {
37-
// other rules...
36+
export default tseslint.config({
37+
// Set the react version
38+
settings: { react: { version: '18.3' } },
3839
plugins: {
3940
// Add the react plugin
4041
react,
4142
},
4243
rules: {
44+
// other rules...
4345
// Enable its recommended rules
4446
...react.configs.recommended.rules,
4547
...react.configs['jsx-runtime'].rules,
4648
},
47-
}
49+
})
4850
```

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@ import reactRefresh from 'eslint-plugin-react-refresh'
55
import tseslint from 'typescript-eslint'
66

77
export default tseslint.config({
8+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
89
files: ['**/*.{ts,tsx}'],
910
ignores: ['dist'],
1011
languageOptions: {
1112
ecmaVersion: 2020,
1213
globals: globals.browser,
13-
parser: tseslint.parser,
1414
},
1515
plugins: {
1616
'react-hooks': reactHooks,
1717
'react-refresh': reactRefresh,
18-
'@typescript-eslint': tseslint.plugin,
1918
},
2019
rules: {
21-
...js.configs.recommended.rules,
22-
...tseslint.configs.recommended.rules,
2320
...reactHooks.configs.recommended.rules,
2421
'react-refresh/only-export-components': [
2522
'warn',

0 commit comments

Comments
 (0)