如何防止npm run lint自动修复错误?

4
我使用Vue CLI创建了一个Vue3应用程序,并设置了Prettier / Eslint。在修改main.ts文件时,
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";

createApp(App)
.use(router).mount("#app");

当我运行npm run serve时,我得到以下警告:

6:15 warning Delete prettier/prettier

如预期。 运行npm run lint可以修复它。但是,哪个标志需要仅检查样式? 我有一个GitHub操作工作流来检查代码风格,并且使用npm run lint是错误的,因为工作流会修复代码风格并通过。 在搜索标志时,我运行了npx vue-cli-service help lint,它告诉我使用--no-fix

enter image description here

但是运行npm run lint --no-fix,它仍然会修复文件。

enter image description here

那么在我的GitHub操作中,我应该使用哪个命令来确保工作流在代码风格无效时失败?

1个回答

5
在使用参数之前,需要在参数前面加上双破折号,因此请使用npm run lint -- --no-fix,其中--是额外的前缀,而不是npm run lint --no-fix。请参见此答案

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接