Skip to content

Commit

Permalink
fix config & doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Jul 30, 2024
1 parent b54b3f0 commit 9f6a689
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
28 changes: 15 additions & 13 deletions packages/create-vite/template-react-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,37 @@ If you are developing a production application, we recommend updating the config
- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: __dirname,
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
}
})
```

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

```js
// eslint.config.js
import react from 'eslint-plugin-react'

export default {
// other rules...
export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
}
})
```
5 changes: 1 addition & 4 deletions packages/create-vite/template-react-ts/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config({
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
ignores: ['dist'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parser: tseslint.parser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'@typescript-eslint': tseslint.plugin,
},
rules: {
...js.configs.recommended.rules,
...tseslint.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
Expand Down

0 comments on commit 9f6a689

Please sign in to comment.