我有一个简单的项目,只有几个html和js文件。将ESLint扩展安装到VS代码,并将ESLint设置为默认格式化程序:
此外,此设置已全部
这是我的settings.json文件:
"window.zoomLevel": 1,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript"],
"git.enableSmartCommit": true,
"eslint.alwaysShowStatus": true,
"files.autoSave": "off",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"git.ignoreWindowsGit27Warning": true,
"eslint.options": {
"eslint brace-style": [
"error",
"allman",
{
"allowSingleLine": true
}
]
},
"eslint.codeAction.showDocumentation": {
"enable": true
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"eslint.format.enable": true
}
当按下保存时,ESLint无法在我的js文件上运行(不纠正方括号,空格等)。我之前在React应用程序中使用过ESLint,所以一年前就可以使用。