background
The golden rule of coding: No matter how many people are working on a project, make sure every line of code looks like it was written by the same person.
Every line of code should appear to be written by a single person, no matter the number of contributors.
This requires that we always follow the same set of coding specifications in a project. Before the development of the project, develop a set of effective coding specifications, and each project team member should code according to this specification. With so many products in the company’s entire product line, there should be a common, uniform code inspection and formatting standard. Plus the company’s unified front-end code specification to constrain the whole front-end research and development process; Because people’s behavior is not able to carry out a good self-unity constraints; Have a personal style; Based on this background, a set of uniform inspection, code formatting configuration specification is organized.
Install esLint dependencies
npm install eslint --save-dev
or
yarn add eslint --dev
or
pnpm install eslint --save-dev
Copy the code
Run the eslint command line
To start installing eslint-plugin-vue@latest eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 Eslint plugin – node @ ^ 11.1.0 eslint plugin – promise @ ^ 2 | | ^ 5.0.0 dependence, etc
Generated. Eslintrc. Js
module.exports = {
env: {
browser: true.es2021: true.node: true
},
extends: ['plugin:vue/essential'.'standard'].parserOptions: {
ecmaVersion: 12.sourceType: 'module'
},
plugins: ['vue'].rules: {
indent: 'off'.'space-before-function-paren': 0.'vue/multi-word-component-names': 0.camelcase: 0.'vue/return-in-computed-property': 0.semi: ['error'.'always']}};Copy the code
Front-end project configuration eslint+vscode formatting (2)