React Vite 模板

提供React与Vite集成的最小化开发模板,支持HMR和ESLint规则配置。

  • by angelolev
  • CSS
  • 本地部署
  • 更新于
在 GitHub 查看 angelolev/mcp-test

使用说明

React+TypeScript+Vite

这个模板提供了一个最小的设置,让React在Vite中使用HMR和一些ESLint规则。

目前,有两个官方插件可用:

扩展ESLint配置

如果您正在开发生产应用程序,我们建议更新配置以启用类型感知的lint规则:

export default tseslint.config([
  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...
    },
  },
])

您还可以安装 eslint-plugin-react-x 和 eslint插件反应dom 对于React特定的lint规则:

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

export default tseslint.config([
  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...
    },
  },
])