如何配置代码自动校验功能
这里你需要下载安装 VScode编辑器:
- 下载安装VScode编辑器
- 安装eslint 和 preitter插件
安装完可以看到底部配置项内容:
- 修改eslint配置项
修改内容为:
右边的内容为:
{
"window.zoomLevel": 0,
// Controls the font size in pixels.
"editor.fontSize": 14,
// The number of spaces a tab is equal to. This setting is overridden based on the file contents when `editor.detectIndentation` is on.
"editor.tabSize": 2,
// Always show the ESlint status bar item.
"eslint.alwaysShowStatus": true,
// An array of language ids which should be validated by ESLint
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "vue",
"autoFix": true
},
"html",
"vue"
],
// Turns auto fix on save on or off.
"eslint.autoFixOnSave": true
}
因为这个项目我使用了vue, r如果是react或者其他语言配置相似,适当修改内容。