Skip to content
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

fix: no-invalid-this false positive in class field initializer #15495

merged 2 commits into from Jan 15, 2022


Copy link

@mdjermanovic mdjermanovic commented Jan 7, 2022

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Fixes #15477.

What changes did you make? (Give an overview)

Refactored no-invalid-this to use code path analysis, which is better for handling edge cases with PropertyDefinition > *.value and fixes the #15477 bug where this appears directly as a class field initializer.

Is there anything you'd like reviewers to focus on?

@mdjermanovic mdjermanovic added bug rule accepted labels Jan 7, 2022
Copy link

@btmills btmills left a comment

LGTM! The code path implementation is quite a bit easier to follow.

@btmills btmills merged commit a8db9a5 into main Jan 15, 2022
14 checks passed
@btmills btmills deleted the issue15477 branch Jan 15, 2022
Copy link

gfyoung commented Jan 16, 2022

@btmills @mdjermanovic: I saw this got released in 5.7.0 (over 5.6.0), but I believe this is in fact a breaking change, as the downstream typescript-eslint/eslint-plugin library relies on FunctionExpression/FunctionExpression:exit (see their most recent v5.9.1 release). Is this over-reliance on internal implementation?

Copy link

btmills commented Jan 16, 2022

@bradzacher heads up that this change might affect typescript-eslint's extended no-invalid-this implementation.

@gfyoung rule implementations aren't part of ESLint's official public API. When we added package.json exports as a breaking change in ESLint v8, we left the use-at-your-own-risk export that typescript-eslint uses to extend built-in rules. The tradeoff is having to keep a closer eye on changes to those rules. Thanks for noticing the impact so I could give the typescript-eslint team a heads up above.

Copy link

bradzacher commented Jan 16, 2022

Feel free raise an issue across in typescript-eslint/typescript-eslint to track this!

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jul 15, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age label Jul 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
accepted archived due to age bug rule
None yet

Successfully merging this pull request may close these issues.

4 participants