新版vscode配置eslint自动格式化代码


旧版配置

{
	//配置eslint
	"eslint.autoFixOnSave": true,  //  启用保存时自动修复,默认只支持.js文件
	"eslint.validate": [
	   "javascript",  //  用eslint的规则检测js文件
	   {
	     "language": "vue",   // 检测vue文件
	     "autoFix": true   //  为vue文件开启保存自动修复的功能
	   },
	   {
	     "language": "html",
	     "autoFix": true
	   }
	 ]
}

新版(>1.41.0)配置

{
	//autoFixedOnSave 设置已废弃,采用如下新的设置
	"editor.codeActionsOnSave": {
	  "source.fixAll.eslint": true
	},
	"eslint.format.enable": true,
	//autoFix默认开启,只需输入字符串数组即可
	"eslint.validate": ["javascript", "vue", "html"]

注意:配置完后重启vscode才有效


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM