Vue project reports eslint format error solution

Vue Vue-cli Eslint automatically formats code in vscode

96 
HuaRongSAOFollow  
2017.10.19 11:28*  Word Count 189  Read 10396 Comments 5

vue eslint code automatic formatting

The code style of vue-cli is  JavaScript Standard Style  . The code inspection specification is strict, and it cannot be run if you are not careful. Using eslint's autoFixOnSave can automatically format the code when saving the code.

  • VSCode extension plugin recommendation (applicable to HTML, Node, Vue, React development)

Suggested reading:

Body eslint auto-formatting

Configuration Environment:

npm i -g eslint-plugin-vue
#or
npm i -S eslint-plugin-vue

Create the project and the files under the path: .eslintrc | .eslint.js

// 添加插件
"plugins": [
    "vue"
]

In your vscode settings file add:

  • 1. Add eslint plugin to vscode
  • 2. Add vetur plugin to vscode
  • 3. Modify your setting.json
// 添加进你的vscode的 setting.json

"eslint.autoFixOnSave": true,
"eslint.validate": [
    "javascript",{ "language": "vue", "autoFix": true },"html", "vue" ], 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325345585&siteId=291194637