脚本宝典收集整理的这篇文章主要介绍了如何在vscode中用standard style 风格去验证 vue文件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本工具通过以下三种方式为你(及你的团队)节省大量时间:
安装:
npm i standard -g
关于JavaScript 代码规范, 你可以点击链接看一下。
实际上JavaScript Standard Style有一个FAQ, 说明了如何使用。
但是有一点非常重要的作者没有提到,就是eslint-plugin-html这个插件必须要安装3.x.x版本的
, 现在eslint-plugin-html
, 已经升级到4.x版本,默认不写版本号安装的就是4.x版本的,所以会出现问题。参考
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, ...)
// 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
查看
"standard.validate": [
"javascript",
"javascriptreact",
{
"language": "html",
"autoFix": true
}
],
"standard.options": {
"plugin": ["html"]
},
"files.associations": {
"*.vue": "html"
},
"standard.autoFixOnSave": true
以上是脚本宝典为你收集整理的如何在vscode中用standard style 风格去验证 vue文件全部内容,希望文章能够帮你解决如何在vscode中用standard style 风格去验证 vue文件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。