Vue eslint 语法检测问题

1. 修改 prettier 配置文件

确保你的项目中有 .prettierrc 配置文件,并在其中添加或修改 endOfLine 设置为 lf,确保统一使用 LF 换行符。

.prettierrc 文件中添加:

bash 复制代码
{
  "endOfLine": "lf"
}

2. 修改 .editorconfig 文件

在项目根目录中可能有 .editorconfig 文件,确保在其中定义了换行符的格式:

bash 复制代码
# .editorconfig 文件
[*]
end_of_line = lf

3. 执行自动修复命令

你可以使用eslintprettier来自动修复文件中的格式问题。执行以下命令来修复格式问题:

bash 复制代码
# 使用 eslint 自动修复
npx eslint --ext .vue --fix src/views/systemSetting/merList/index.vue

或者使用 prettier 进行修复:

bash 复制代码
# 使用 prettier 自动修复
npx prettier --write src/views/systemSetting/merList/index.vue

4. 修改 git 换行符策略

你可以通过修改 Git 的换行符策略来防止这个问题的发生。在项目根目录添加或修改 .gitattributes 文件:

bash 复制代码
# 在 .gitattributes 中设置
* text=auto eol=lf

执行以下命令重新设置换行符:

bash 复制代码
git add --renormalize .
git commit -m "Fix line endings"

5. 重新提交代码

修复后,你可以重新尝试提交代码。如果依然有问题,可以使用 --no-verify 来跳过 husky 的 pre-commit hook:

bash 复制代码
git commit -m "Fix eslint/prettier issues" --no-verify
相关推荐
mCell1 天前
GSAP ScrollTrigger 详解
前端·javascript·动效
gnip1 天前
Node.js 子进程:child_process
前端·javascript
excel1 天前
为什么在 Three.js 中平面能产生“起伏效果”?
前端
excel1 天前
Node.js 断言与测试框架示例对比
前端
天蓝色的鱼鱼1 天前
前端开发者的组件设计之痛:为什么我的组件总是难以维护?
前端·react.js
codingandsleeping1 天前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
石金龙1 天前
[译] Composition in CSS
前端·css
白水清风1 天前
微前端学习记录(qiankun、wujie、micro-app)
前端·javascript·前端工程化
Ticnix1 天前
函数封装实现Echarts多表渲染/叠加渲染
前端·echarts
用户22152044278001 天前
new、原型和原型链浅析
前端·javascript