本工具經過如下三種方式爲你(及你的團隊)節省大量時間:javascript
安裝:html
npm i standard -g
關於JavaScript 代碼規範, 你能夠點擊連接看一下。vue
實際上JavaScript Standard Style有一個FAQ, 說明了如何使用。java
可是有一點很是重要的做者沒有提到,就是eslint-plugin-html這個插件必需要安裝3.x.x版本的
, 如今eslint-plugin-html
, 已經升級到4.x版本,默認不寫版本號安裝的就是4.x版本的,因此會出現問題。參考react
ESLint v4 is only supported by eslint-plugin-html v3, so you can't use eslint-plugin-html v1.5.2 with it (I should add a warning about this when trying to use the plugin with an incompatible version on ESLint).If you do not use ESLint v4, please provide more information (package.json, a gist to reproduce, ...)git
// FAQ How to lint script tag in vue or html files? You can lint them with eslint-plugin-html, just install it first, then enable linting for those file types in settings.json with: "standard.validate": [ "javascript", "javascriptreact", "html" ], "standard.options": { "plugins": ["html"] }, "files.associations": { "*.vue": "html" }, If you want to enable autoFix for the new languages, you should enable it yourself: "standard.validate": [ "javascript", "javascriptreact", { "language": "html", "autoFix": true } ], "standard.options": { "plugins": ["html"] }
npm i -g standard
npm i -g eslint-plugin-html@3.2.2
必須是3x版本npm i -g eslint
以上三個包都是全局安裝的,若是你想看看全局安裝了哪些包能夠用npm list -g --depth=0
查看github
"standard.validate": [ "javascript", "javascriptreact", { "language": "html", "autoFix": true } ], "standard.options": { "plugin": ["html"] }, "files.associations": { "*.vue": "html" },
"standard.autoFixOnSave": true