vue eslint configuration specification
In order to unify the code format, to avoid low-level errors or unreasonable, is forced to use eslint
the standard
specifications
Project Configuration
It is currently provided by the use of scaffolding vue development, though vue-cli 3.0
, but the company because the configuration of OAuth sake, or only temporary use vue-cli 2.0
,
and thus the current configuration will be described in conjunction with two versions
purpose
Can be prompted by the editor (vscode) can be repaired at the same time, so it is the best
vue-cli 2.0
Select New Project
standard
format
Test eslint (pick a place to play a few spaces)
When saving can automatically fix (or repair when formatting codes)
Since the
vetur
format used isprettier
the way, not what we wantstandard
, currently two modes of operation
- Scenario 1 : If able to
prettier
read what we want, this is the best - Scenario 2 : do not change
prettier
, but when you save then in accordance withstandard
the form of preservation does not depend on the
For the above description, it is currently using a second scheme (not the first way to find a solution)
- Use
方案2
, the operation flow- Install plug
ESLint
vscode
setting.json
add configuration// 开启 "eslint.enable": true, // 保存 "eslint.autoFixOnSave": true, "eslint.run": "onType", "eslint.options": { "extensions": [".js",".vue"] }, "eslint.validate": [ // 此处保存时,自动修复 { "language": "vue", "autoFix": true }, "javascript", "html", "vue-html" ]
effect
- Install plug
- Scenario 1 : If able to
vue-cli 3.0
The same operation (not described in the first subtle differences)
eslint brief description
eslint There are two large branches
airbnb more stringent standard than the rules require, and this is the reason why the choice of standard, because the rules are not a hundred percent in line with each company, which will be on this basis, a private custom eslint-config-vue specific rules described see eslint official website
Close to a particular eslint check users
to sum up
- If it can be repaired in time code formatting, this is the best
- How to customize their own rules, some of this hard (difficult to reach)
- Follow then add it (or some scattered between points)