一. ESLint
-
作用
????檢查Javascript
編程時的語法錯誤。 -
新建或修改文件時報錯
-
原因
???? Windows系統(tǒng) ,clone的代碼會自動把換行符LF
轉(zhuǎn)為回車符CRLF
,這時本地的代碼都是回車符??稍趐rettier.config.js中查看到文章來源:http://www.zghlxwxcb.cn/news/detail-784814.html
-
檢查配置(ESLint中是否支持JavaScript/vue語言)
(1)在VScode中,使用Ctr + 打開設置畫面(或 File - Preferences - Settings)
(2)點擊 “Edit in settings.json”(編輯設置的json文件)
(3)配置代碼文章來源地址http://www.zghlxwxcb.cn/news/detail-784814.html
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"editor.formatOnSave": true,
"editor.formatOnType": true,
"[html]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"git.openRepositoryInParentFolders": "always",
"eslint.validate": [
"javascript",
"javascriptreact",
"html",
"vue"
],
// "eslint.autoFixOnSave": true, // 改成下面的"editor.codeActionsOnSave"
// #每次保存的時候?qū)⒋a按eslint格式進行修復
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
- 解決
(1)報 ESLint錯誤時檢查是否如下所示是CRLF
(2)點擊上述步驟(1)中的 ‘CRLF’,此時在VSCode頂部選擇LF
即可
(3)解決成功
二. VSCode自動保存
- “ Ctrl + ” 或 “File - Preferences - Settings” 打開設置(Settings)界面
- 找到“Files :Auto Save”
- 下拉選項如下
其中
(1)off:不自動保存,需手動保存
(2)afterDelay:固定間隔時間,自動保存
(3)onFocusChange:當前窗口編輯內(nèi)容,失去焦點時自動保存
(3)onWindowsChange:切換窗口時自動保存
三. 參考鏈接
- ESLint:https://blog.csdn.net/LPLIFE/article/details/105655178
- 自動保存:https://www.yisu.com/zixun/328446.html
到了這里,關于【VScode】ESLint :warning Delete `CR` prettier/prettier的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!