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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(require-hook): check variables are either const or declarations #959

Merged
merged 3 commits into from Oct 17, 2021

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Oct 16, 2021

While I documented it, I completely forgot to actually implement checking for this 馃う (likewise for re-assignments, which I'll do in a follow-up PR).

Right now I'm not allowing initialization, but wouldn't be surprised if we supported that in the future since some people like doing that explicitly.

@G-Rath
Copy link
Collaborator Author

@G-Rath G-Rath commented Oct 17, 2021

Ironically I just realised I'm one of those people that require initialization in the rare times when I'm writing vanilla Javascript, as a way of hinting what the expected type is 馃

Unfortunately I don't think we can confidently confirm that a let variable is assigned to in a hook due to all the possible branching that could occur with nested describes (thought maybe it's acceptable if we say you should just be declaring the variable in each describe block? 馃).

I still think it's a valuable check to have since the class of bugs it prevents tend to be very painful, so I think a good middle-ground that I'll do is to allow initialization to null or undefined only since those two values tend to be very static - you can't mutate them, and they are literally only two possible values (unlike other simple primitives e.g. numbers, which can be any number).

SimenB
SimenB approved these changes Oct 17, 2021
Copy link
Member

@SimenB SimenB left a comment

works for me 馃憤

@SimenB SimenB merged commit ce8cd61 into main Oct 17, 2021
29 checks passed
@SimenB SimenB deleted the require-hook-fix branch Oct 17, 2021
github-actions bot pushed a commit that referenced this issue Oct 17, 2021
## [25.2.2](v25.2.1...v25.2.2) (2021-10-17)

### Bug Fixes

* **require-hook:** check variables are either `const` or declarations ([#959](#959)) ([ce8cd61](ce8cd61))
@github-actions
Copy link

@github-actions github-actions bot commented Oct 17, 2021

馃帀 This PR is included in version 25.2.2 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants