没有特别的幸运,那么就特别的努力!!!
示例
方法一:提交无阻碍
根目录(package.json平级)新建.eslintignore文件
src
src 意思是只要src下面的文件都 不 进行eslint检测
方法二:保存自动纠正
安装拓展ESLint,Prettier
找到setting.json文件
修改setting.json文件
{
"git.autofetch": true,
// "editor.fontFamily": "'Courier New', Consolas, monospace",
// "editor.fontSize": 16,
"files.autoGuessEncoding": true,
"files.autoSave": "off", //自动保存
// "editor.lineNumbers": "on", //打开行号
"editor.quickSuggestions": {
//开启自动显示建议
"other": true,
"comments": true,
"strings": true
},
"editor.tabSize": 2, //制表符符号eslint
// "editor.formatOnSave": true, //保存时自动格式化
"source.fixAll.eslint": true, //保存时自动将代码按ESLint格式进行修复
// Use 'prettier-eslint' instead of 'prettier
"prettier.eslintIntegration": true, // 让prettier使用eslint的代码格式进行校验
"prettier.semi": false, //去掉代码结尾的分号
"prettier.singleQuote": true, //使用单引号替代双引号
"javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和后面的括号之间加个空格
"vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
"vetur.format.defaultFormatter.js": "vscode-typescript", //让vue中的js按编辑器自带的ts格式进行格式化
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
// "wrap_attributes": "force-aligned", //属性强制折行对齐
"wrap_line_length": 200,
"wrap_attributes": "auto",
"end_with_newline": false
}
},
"eslint.validate": ["javascript", "javascriptreact", "vue-html"],
"emmet.triggerExpansionOnTab": true,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"git.enableSmartCommit": true,
"liveServer.settings.donotShowInfoMsg": true,
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"workbench.sideBar.location": "left",
"[jsonc]": {
"editor.defaultFormatter": "codeco.prettier-eslint-vscode"
},
"beautify.ignore": "",
"explorer.confirmDelete": false,
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[scss]": {
"editor.defaultFormatter": "svipas.prettier-plus"
},
"path-intellisense.mappings": {
"path-intellisense.mappings": {
"@": "${workspaceRoot}/src"
}
},
"explorer.confirmDragAndDrop": false,
"files.exclude": {
"**/node_modules": true
},
"workbench.startupEditor": "newUntitledFile"
}
希望能帮助到大家,同时祝愿大家在开发旅途中愉快!!!