admin管理员组文章数量:1302266
Similar question to this post on StackOverflow but I cannot seem to get rid of this warning after trying everything I could find on the internet. Github Issue.
Line 1:8: 'React' was used before it was defined @typescript-eslint/no-use-before-define
I've tried adding these to the rules in .eslintrc.json
but neither seem to remove the warning.
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off"
"no-use-before-define": [0],
"@typescript-eslint/no-use-before-define": [1]
This issue doesn't exist on my other projects. I've tried copying package.json
and .eslintrc.json
from the other projects and re-installing node_modules
, however it still persists.
Does anyone have any other suggestions to resolve the warning? Thanks in advance!
Similar question to this post on StackOverflow but I cannot seem to get rid of this warning after trying everything I could find on the internet. Github Issue.
Line 1:8: 'React' was used before it was defined @typescript-eslint/no-use-before-define
I've tried adding these to the rules in .eslintrc.json
but neither seem to remove the warning.
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off"
"no-use-before-define": [0],
"@typescript-eslint/no-use-before-define": [1]
This issue doesn't exist on my other projects. I've tried copying package.json
and .eslintrc.json
from the other projects and re-installing node_modules
, however it still persists.
Does anyone have any other suggestions to resolve the warning? Thanks in advance!
Share asked Sep 11, 2020 at 12:38 allen762xallen762x 1011 gold badge1 silver badge4 bronze badges 3- 1 Where's the code that producing this error? – Prateek Thapa Commented Sep 11, 2020 at 12:41
-
You can try downgrading
@typescript-eslint
version as suggested here stackoverflow./a/63862578/3872362 – sashko Commented Sep 12, 2020 at 16:47 - 2 Does this answer your question? 'React' was used before it was defined – clemlatz Commented Sep 13, 2020 at 12:50
1 Answer
Reset to default 6that is because:
This is a pretty mon 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.
So pls try to write that rules in your .eslintrc.json
:
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
related link:
https://github./typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
https://github./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
本文标签: javascriptquot39React39 was used before it was definedquot eslint warningStack Overflow
版权声明:本文标题:javascript - "'React' was used before it was defined." eslint warning - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741705367a2393527.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论