Recently wrote vue using the vue – admin – template, NPM run dev run there will always be eslint error, each check time-consuming, record the solution.
1. Install the plug-in
Vscode installs the following plug-ins:
- eslint
- Vetur
- Prettier – Code formatter
2. Format the vue file before saving it
Hold ·commond+ Shift +p· to search for Perferences Open Setting (json).
Add the following contents to the configuration file. Be careful not to copy all of them directly, as they may overwrite your own configuration. It is recommended to copy and remove duplicate keys.
{
"editor.suggestSelection": "first"."vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue"."explorer.confirmDelete": false."editor.tabSize": 2."files.autoSave": "onFocusChange"."editor.fontSize": 14.// Set the font
"editor.tabCompletion": "on".// Is used to automatically fill in the best recommendation value when the Tab key is pressed
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true."source.organizeImports": true // This attribute automatically adjusts the order of import statements when saved, so that your import statements are arranged alphabetically
},
"editor.formatOnSave": true.// # format js in vue as "prettier
"vetur.format.defaultFormatter.html": "js-beautify-html"."vetur.format.defaultFormatter.js":"prettier-eslint"."vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
// #vue component HTML code formatting style
"wrap_attributes": "auto".// Can also be set to "auto", the effect will be different
"wrap_line_length": 200."end_with_newline": false."semi": false."singleQuote": true
},
"prettier": {
"semi": false."singleQuote": true."editor.tabSize": 2
},
"prettyhtml": {
"printWidth": 160."singleQuote": false."wrapAttributes": false."sortAttributes": false}},"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"bracketPairColorizer.depreciation-notice": false."editor.mouseWheelZoom": true
}
Copy the code
The problem record
Format all files in the directory
Download the plug-in Start Format Files, then right-click the directory and choose Start Formatting Files.
Ignore the file configuration see marketplace.visualstudio.com/items?itemN…