Before reading this article you should know why esLint is used in your projectCopy the code

First of all, what is ESLint? ESLint is a JavaScript checker;

What’s the use? Generally used for code specifications;

How to use it? In conjunction with webpack, when you run the NPM command, esLint will read the rule checking code in the.eslintrc file under the project and report an error if it does not conform to the specification. Here I’ll take a look at some of esLint’s standard portal Go, using the wechat applets created by MPvue as a reference

If you don’t use esLint at the beginning of the project, you can install NPM istall later via NPM -g eslint, where vscode also installs formatting plugins prettier, Beautify, and eslint

Go to the preferences in vscode -> Settings -> click the small icon in the upper right corner to enter Settings

  "editor.tabSize": 2, // the TAB symbol eslint"editor.formatOnSave": false// Automatically format each save"eslint.autoFixOnSave": true// Fix the code in ESLint format every time you save it"prettier.eslintIntegration": true// Let Prettier use esLint's code format for validation"prettier.semi": false// Remove the semicolon at the end of the code"prettier.singleQuote": true// Use quotes instead of double quotes"javascript.format.insertSpaceBeforeFunctionParenthesis": true// Add a space between the function (name) and the following parentheses"vetur.format.defaultFormatter.html": "js-beautify-html"// Format.vue HTML"vetur.format.defaultFormatter.js": "vscode-typescript"// Format the JS in vue according to the ts format that comes with the editor"vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-aligned"// Force line alignment}},"eslint.validate": [// enables error checking in.vue files"javascript"."javascriptreact",
    {
      "language": "html"."autoFix": true
    },
    {
      "language": "vue"."autoFix": true}]Copy the code

Then you can use ESLint, see ☟☟☟

Automated formatting tools may not be perfect at this point, but it is recommended that you make adjustments based on your need for code specifications