React Vite 模板

提供React与Vite集成的最小化配置模板,支持热模块替换和ESLint规则。

  • by Yuyz0112
  • TypeScript
  • 本地部署
  • 6 星标
  • 更新于
在 GitHub 查看 Yuyz0112/mcp-client-server-demo

使用说明

React+TypeScript+Vite

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

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

扩展ESLint配置

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

  • 配置顶级 parserOptions 这样的属性:
export default tseslint.config({
  languageOptions: {
    // other options...
    parserOptions: {
      project: ['./tsconfig.node.json', './tsconfig.app.json'],
      tsconfigRootDir: import.meta.dirname,
    },
  },
})
  • 替换 tseslint.configs.recommended 向 tseslint.configs.recommendedTypeChecked 或 tseslint.configs.strictTypeChecked
  • 可选择添加 ...tseslint.configs.stylisticTypeChecked
  • 安装 eslint插件反应 并更新配置:
// 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,
  },
})