使用React在VSCODE中自动导入不起作用
我有一个问题,不知道原因或如何解决。 VS代码不会强调导入的不正确路径,以防万一。同样,自动导入行不通。我尝试设置一个JSCONFIG文件以使用绝对路径,但没有任何结果。 我使用此 Extension> Extension> Extension for Auto Import。
JSCONFIG.JSON
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"],
"exclude": ["node_modules"]
}
ESLINTRC.JSON
{
"env": {
"node": true,
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "prettier", "prettier/prettier", "plugin:prettier/recommended", "eslint:recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks"],
"rules": {
"no-return-await": "warn",
"camelcase": "error",
"react/jsx-key": "off",
"react/prop-types": "off",
"prettier/prettier": ["off", { "singleQuote": true }],
"react/jsx-filename-extension": [
"warn",
{
"extensions": [".jsx"]
}
],
"max-len": [
"warn",
{
"code": 140
}
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "off",
"import/prefer-default-export": "off"
},
"settings": {
"react": {
"version": "detect"
}
}
}
是否有人知道我该怎么做才能突出显示错误的导入和自动导入工作?提前致谢!
I have an issue and don't know the reason or how to fix it. VS Code doesn't underline the incorrect path for imports in case if they are wrong. Also the auto import does not work. I tried to setup a jsconfig file to use the absolute paths, but without any result.
I use this extension for auto import.
jsconfig.json
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"],
"exclude": ["node_modules"]
}
eslintrc.json
{
"env": {
"node": true,
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "prettier", "prettier/prettier", "plugin:prettier/recommended", "eslint:recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks"],
"rules": {
"no-return-await": "warn",
"camelcase": "error",
"react/jsx-key": "off",
"react/prop-types": "off",
"prettier/prettier": ["off", { "singleQuote": true }],
"react/jsx-filename-extension": [
"warn",
{
"extensions": [".jsx"]
}
],
"max-len": [
"warn",
{
"code": 140
}
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "off",
"import/prefer-default-export": "off"
},
"settings": {
"react": {
"version": "detect"
}
}
}
Does anybody know what I should do to get the wrong imports highlighted and the auto import working? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论