Skip to content

chore: add new test (already passing) around function types & no-restricted-globals rule #1055

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

Merged

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Oct 8, 2019

I'm experiencing this rule to fail on similar code and I was about to raise an issue - I've tested first if it works here and it seems it does, so my issue has to be connected to my setup and need to fix it on my own.

Nevertheless, I couldn't verify quickly if that simple case is handled with the plugin here (had to check "manually" by cloning the repo and adding the test case myself) - so I thought I might send this as a PR, maybe it can help a future somebody.

If you feel this excessive then feel free to just close this.

I would have a question though, regarding this - how this plugin works exactly for rules like this? Does it hook into default ESLint scope analysis? Does it override the default behavior somehow?

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @Andarist!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@bradzacher
Copy link
Member

bradzacher commented Oct 10, 2019

Does it hook into default ESLint scope analysis?

We don't hook into it, we define our own which extends the base eslint scope analysis.
The test you modified is a sanity check to ensure we don't break the rule with those changes.

@bradzacher bradzacher merged commit 526d336 into typescript-eslint:master Oct 10, 2019
@Andarist Andarist deleted the no-restricted-globals/new-test branch October 10, 2019 18:06
@Andarist
Copy link
Contributor Author

@bradzacher Could u point me to the code lines where this extending takes place? I would be interested in taking a look how u handle that.

@bradzacher
Copy link
Member

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/src/analyze-scope.ts

tl;dr - we do it pretty poorly right now.
There was a maintainer that was working on it at the start of the year, but they stepped back from the project not long after. Nobody has had the time to pick it up since then.
There is a lot that you have to figure out about how scope analysis works in eslint, as the package that's used (https://github.com/eslint/eslint-scope) is mostly undocumented.
That's the main reason I haven't gone back to finish the work.

As an aside - this is why rules like no-unused-vars, no-use-before-define, etc that rely on correct scope information are broken - because the typescript scope analysis code isn't complete.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants