babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)
https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser
MIT License
2.96k stars 208 forks source link

Fix `no-undef` for several cases #750

Closed pnevyk closed 4 years ago

pnevyk commented 5 years ago

This PR deals with #625. It fixes three things (implementations are split into separate commits for convenient review):

One thing I am not sure about is this part. The root cause of function generics misbehavior was that _visitTypeAnnotation was treating type parameters of function type annotation as variable references instead of variable declarations. But I am not sure if this is the best fix, especially whether _nestTypeParamScope is used correctly.

I must have change some tests which were imho incorrect (1, 2).


I would like to tackle the other half of #625 issue as well, either in this PR or in a separate one. But I want to be sure that my reasoning is correct:

In my opinion, declare ... statements should not emit no-unused-vars regardless if they are referenced in the file or not, since they serve as library definitions (ie. typed interface with outside world for code without Flow types in sources). Therefore I propose to reference these declarations automatically.


Also, I think that this known issue can be removed from the README, as it is not issue anymore for some time already.

gajus commented 4 years ago

Any reason this has not been merged?

kaicataldo commented 4 years ago

Active development has moved to the babel/babel monorepo. We are working to get the new packages out the door, and appreciate your patience!

kaicataldo commented 4 years ago

Thank you for the PR. Now that @babel/eslint-parser has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.