vite/packages/create-vite/template-react-ts
2024-10-04 17:36:42 +08:00
..
public feat(create-vite): align template styles with docs (#8478) 2022-06-08 09:36:56 +02:00
src chore: update all url references of vitejs.dev to vite.dev (#18276) 2024-10-04 17:36:42 +08:00
_gitignore chore(create-vite): add more gitignore (#6247) 2021-12-28 04:52:51 +01:00
eslint.config.js fix(create-vite): move ESLint "ignores" config to a separate object in React templates (#17885) 2024-08-15 14:51:12 +08:00
index.html chore(deps): update dependency prettier to v3 (#13759) 2023-07-19 09:53:25 +02:00
package.json chore(deps): update all non-major dependencies (#17991) 2024-09-02 11:20:05 +08:00
README.md feat(create-vite): add eslint.config.js to React templates (#12860) 2024-07-31 12:53:49 +08:00
tsconfig.app.json fix(create-vite): avoid usage of composite in TS configs (#17774) 2024-07-31 16:19:13 +08:00
tsconfig.json fix(create-vite): avoid usage of composite in TS configs (#17774) 2024-07-31 16:19:13 +08:00
tsconfig.node.json fix(create-vite): avoid usage of composite in TS configs (#17774) 2024-07-31 16:19:13 +08:00
vite.config.ts chore: update all url references of vitejs.dev to vite.dev (#18276) 2024-10-04 17:36:42 +08:00

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:

Expanding the ESLint configuration

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

  • Configure the top-level parserOptions property like this:
export default tseslint.config({
  languageOptions: {
    // other options...
    parserOptions: {
      project: ['./tsconfig.node.json', './tsconfig.app.json'],
      tsconfigRootDir: import.meta.dirname,
    },
  },
})
  • Replace tseslint.configs.recommended to tseslint.configs.recommendedTypeChecked or tseslint.configs.strictTypeChecked
  • Optionally add ...tseslint.configs.stylisticTypeChecked
  • Install eslint-plugin-react and update the config:
// eslint.config.js
import react from 'eslint-plugin-react'

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,
  },
})