Skip to content

Commit

Permalink
feat: 添加vite-plugin-checker插件
Browse files Browse the repository at this point in the history
  • Loading branch information
huangmingfu committed Dec 17, 2024
1 parent c63c229 commit 4daa910
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 6 deletions.
1 change: 0 additions & 1 deletion README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ Besides code structure standardization, the project integrates various code qual
├── lint-staged.config.js # Lint-Staged configuration file for running Linters before Git commits
├── package.json # Project dependency configuration file
├── tsconfig.json # TypeScript configuration file
├── tsconfig.node.json # Node.js environment TypeScript configuration file
└── vite.config.ts # Vite configuration file for build and service options
```

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ GitHub 项目地址:[React-Ts-Template](https://github.com/huangmingfu/react-t
├── lint-staged.config.js # Lint-Staged 配置文件,用于在 Git 提交前自动运行 Linters
├── package.json # 项目依赖配置文件
├── tsconfig.json # TypeScript 配置文件
├── tsconfig.node.json # Node.js 环境的 TypeScript 配置文件
└── vite.config.ts # Vite 配置文件,用于定义 Vite 项目的构建和服务选项
```

Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default tseslint.config(
},
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
project: ['./tsconfig.json'],
tsconfigRootDir: import.meta.dirname
}
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@
"stylelint-order": "^6.0.4",
"typescript": "~5.7.2",
"typescript-eslint": "^8.18.0",
"vite": "^6.0.3"
"vite": "^6.0.3",
"vite-plugin-checker": "^0.8.0"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0",
"pnpm": ">=9"
}
}
}
136 changes: 136 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react-swc';
import { resolve } from 'node:path';
import process from 'node:process';
import { ConfigEnv, UserConfig, defineConfig, loadEnv } from 'vite';
import checker from 'vite-plugin-checker';

export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
// 获取`.env`环境配置文件
Expand All @@ -15,7 +16,14 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
* 点击页面元素,IDE直接打开对应代码插件(本项目配置的快捷键是:ctrl+alt+q,详见main.tsx)
* @see https://react-dev-inspector.zthxxx.me/docs/inspector-component#setup
*/
inspectorServer()
inspectorServer(),
// 在浏览器中直接看到上报的类型错误(更严格的类型校验)
checker({
typescript: true,
eslint: {
lintCommand: 'eslint "./src/**/*.{ts,tsx}"'
}
})
],
resolve: {
alias: {
Expand Down

0 comments on commit 4daa910

Please sign in to comment.