gpt4 book ai didi

javascript - "' react ' was used before it was defined."eslint 警告

转载 作者:行者123 更新时间:2023-12-03 16:59:01 35 4
gpt4 key购买 nike

this post on StackOverflow 类似的问题但是在尝试了我在互联网上可以找到的所有内容之后,我似乎无法摆脱这个警告。 Github Issue.

 Line 1:8:  'React' was used before it was defined  @typescript-eslint/no-use-before-define
我尝试将这些添加到 .eslintrc.json 中的规则中但似乎都没有删除警告。
 "no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off"

"no-use-before-define": [0],
"@typescript-eslint/no-use-before-define": [1]
这个问题在我的其他项目中不存在。我试过复制 package.json.eslintrc.json从其他项目中重新安装 node_modules ,但它仍然存在。
有没有人有任何其他建议来解决警告?提前致谢!

最佳答案

那是因为:

This is a pretty common thing because TypeScript adds new features that ESLint doesn't know about.The first step is to check our list of "extension" rules here. An extension rule is simply a rule which extends the base ESLint rules to support TypeScript syntax. If you find it in there, give it a go to see if it works for you. You can configure it by disabling the base rule, and turning on the extension rule.


因此,请尝试在您的 .eslintrc.json 中写入该规则:
   "no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
相关链接:
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code

关于javascript - "' react ' was used before it was defined."eslint 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63847262/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com