一、警告:warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
解決方案:關閉any類型的警告。
// 在 .eslintrc.js文件中找到rules 添加一行代碼即可
"@typescript-eslint/no-explicit-any": ["off"]
添加完成之后,重新運行項目即可。
二、使用eslint時總是提醒warning Delete `·` prettier/prettier或者405:15 warning Insert `⏎·····` prettier
解決方案:可執行代碼即可
npm run lint --fix
執行之后會自動修改,我這里看到把單引號改成了雙引號。
三、warning: Missing return type on function (@typescript-eslint/explicit-module-boundary-types) at src\main.ts:32:8
解決方案:在.eslintrc.js文件里添加規則禁用ta
"rules": { "@typescript-eslint/explicit-module-boundary-types": "off" },
四、Require statement not part of import statement.(@typescript-eslint/no-var-requires)
// 當在 vue.config.js 中:
const path = require('path') // 提示報錯:
Require statement not part of import statement.(@typescript-eslint/no-var-requires)
解決方案:在 .eslintrc.js中的 rules 屬性新增以下內容:
rules: { '@typescript-eslint/no-var-requires': 0 }
五、Unnecessary escape character: \/ no-useless-escape
通常見與寫正則時報錯:
79:17 error Unnecessary escape character: \/ no-useless-escape 79:21 error Unnecessary escape character: \[ no-useless-escape 131:22 warning Insert `,` prettier/prettier 132:4 warning Insert `,` prettier/prettier
$ Unnecessary escape character: - no-useless-escape
禁用不必要的轉義字符; \-
不必要的轉義字符,上面都給你提示了,改一下就行。
const reg = /[\/{}\[\]#%?\\]+/
// 不必要的轉義字符去掉
const reg = /[/{}[\]#%?\\]+/