简体   繁体   English

vscode如何格式化vue文件以符合eslint规则

[英]vscode how to format vue file to comply with eslint rules

bascially what I want is the consistency between:基本上我想要的是以下之间的一致性

  • how vscode format my.vue file vscode如何格式化my.vue文件
  • how eslint checker scan my.vue file when I run npm run.... to start the server or build the target当我运行npm run....以启动服务器或构建目标时,eslint 检查器如何扫描 my.vue 文件

currently I format my document in vscode and then run npm run dev , eslint checker will raise lots of warnings and errors, it seems that their foramting/linting rules come from different source, I haven't figure out a way to make them use the same rules目前我在 vscode 中格式化我的文档,然后运行npm run dev ,eslint checker 会引发很多警告和错误,似乎他们的格式化/linting规则来自不同的来源,我还没有找到让他们使用的方法相同的规则

First, install these extensions:首先,安装这些扩展:

Then write these settings in your settings.json :然后将这些设置写入您的settings.json

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM