-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-use-before-define] import * as React
marked as error in TSX/JSX file
#2502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Huh. That's an interesting side-effect. I hadn't thought about that rule doing that. The usage is in exactly the same place as the definition, so it shouldn't be reporting. Seems like a bit of a bug in the rule that I will have to worm around. |
I figured as much - the rule does |
Along with this issue, @typescript-eslint/parser 4.0.2-alpha.12 started to trigger @bradzacher should I file a new issue? |
nah don't worry. I was actually just thinking about that. I'll have a PR in a sec. |
Just tried alpha18 — the abovementioned issues are gone. Thank you! |
@bradzacher import React, { useState, useEffect } from "react"; produces
Did this change not make the alpha 20? Or somehow still broken? |
Thanks a lot, wasn't aware of that. Will keep in mind in the future. |
Hi @nstrelow, did you find a solution for this? I'm also having the same message... should I disable this rule? |
@gasscoelho did you actually read the thread...? I have already replied with the answer. |
I did but I didn't quite follow. I had a project configured on 3.10.1 which didn't have the [no-use-before-define] error on |
"eslint-plugin-react": "^7.20.6", error 'React' was used before it was defined no-use-before-define I dont know, feel confused |
I'm also still getting this error with: |
Hi confused guys, just use this in your config:
Maybe it is just our preset don't aware of this rule yet, you can enable this new rule by hand:
|
I'm going to go ahead and lock this to prevent further noise. linonetwo's very helpful comments (thanks!) plus the FAQ and v4 release notes should be enough to solve this. Please ensure you read them all, and understand that you need to manually update your config appropriately. |
Repro
.eslintrc.js
tsconfig.json
Expected Result
No lint errors
Actual Result
foo.tsx 1:13 React was used before it was defined. @typescript-eslint/no-use-before-define
Additional Info
Versions
@typescript-eslint/eslint-plugin
4.0.2-alpha.15
@typescript-eslint/parser
4.0.2-alpha.15
TypeScript
4.0.2
ESLint
7.8.1
node
10.16.3
The text was updated successfully, but these errors were encountered: