Vue 3 + Vite + Eslint + prettier + husky + lint-staged 搭建基础项目

本文档详细介绍了如何使用Vue 3、Vite搭建项目,并集成Eslint、Prettier进行代码规范,通过Husky和Lint-staged设置Pre-commit检查,确保代码质量。同时,还涵盖了vue-router和Pinia的集成,用于实现应用的路由管理和状态管理。
摘要由CSDN通过智能技术生成

项目搭建

pnpm create vite 

代码规范

集成 editorconfig 配置

  • EditorConfig 有助于为不同 IDE 编辑器上处理同一项目的多个开发人员维护一致的编码风格。
# http://editorconfig.org

root = true

[*] # 表示所有文件适用
charset = utf-8 # 设置文件字符集为 utf-8
indent_style = space # 缩进风格(tab | space)
indent_size = 2 # 缩进大小
end_of_line = lf # 控制换行类型(lf | cr | crlf)
trim_trailing_whitespace = true # 去除行首的任意空白字符
insert_final_newline = true # 始终在文件末尾插入一个新行

[*.md] # 表示仅 md 文件适用以下规则
max_line_length = off
trim_trailing_whitespace = false 
  • VSCode 需要安装一个插件:EditorConfig for VS Code

image-20210722215138665

配置 eslint、prettier

pnpm i eslint prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-vue @typescript-eslint/parser @typescript-eslint/eslint-plugin vue-global-api -D 
  • 在根目录下建立 eslint 配置文件: .eslintrc.js
module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  globals: {
    Message: true,
    env:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值