1. First open VsCode, search for eslint in the plugin extension store, click install, and reload;
2. Once installed, configure ESLint, open files ==> Preferences ==> Settings; Select User ==> extension ==>ESLint; Go to and open “Edit in Settings. json” and configure the following code:
{// Automatically fix format "editor.codeActionsOnSave": {" source.fixall. eslint": true}, // Add vue support for "eslint.validate": [ "javascript", "javascriptreact", "vue" ], }Copy the code
ESLint can now inspect the code in the project.
3.ESLint checks are strict. If you want vUE to format code according to ESLint, do the following:
1) Install the plugin Vetur, which is a popular plugin for Vue. Js code hints, syntax highlighting, etc.
2) Vetur uses prettier formatting by default in the default configuration after installation
3) Install the plugin prettier, which formats differently from esLint, so add the following configuration to the user configuration:
// semicolon "prettier.semi": false, // wrapping string "prettier.singlequote ": True, / / HTML formatting to rely on the default value is none "vetur. Format. DefaultFormatter. HTML" : "Js - beautify - HTML / / function before add Spaces" javascript. The format. InsertSpaceBeforeFunctionParenthesis ": True, / / no under the do not over "vetur. Format. DefaultFormatter. Js" : "vscode - typescript,"Copy the code