2
eslint 如何能自动导入缺失的模块?
source link: https://www.v2ex.com/t/849256
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
经常会遇到 eslint 报错 no-undef 的错误,但是是因为模块没有导入,怎样能用 eslint 自动导入缺失的模块呢
2 条回复 • 2022-04-25 23:54:01 +08:00
ChefIsAwesome 3 小时 56 分钟前 via Android
一个变量没定义能等同于这个变量是没引进去的模块?
YuTengjing 3 小时 55 分钟前
如果你是用的 VSCode ,并且没开自动保存,可以配置在保存时自动导入:
```
"editor.codeActionsOnSave": [
"source.addMissingImports"
]
```
相关文档: https://code.visualstudio.com/updates/v1_46#_add-all-missing-imports-source-action
如果你设置了自动保存,一般情况在使用的时候就会自动导入,如果没有,那么你可以使用自动修复,或者修复全部,相关快捷键你直接在快捷键表里面搜 auto fix 和 fix all
```
"editor.codeActionsOnSave": [
"source.addMissingImports"
]
```
相关文档: https://code.visualstudio.com/updates/v1_46#_add-all-missing-imports-source-action
如果你设置了自动保存,一般情况在使用的时候就会自动导入,如果没有,那么你可以使用自动修复,或者修复全部,相关快捷键你直接在快捷键表里面搜 auto fix 和 fix all
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK