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(eslint-plugin): [strict-boolean-expressions] account for truthy literals #3236

Conversation

JoshuaKGoldberg
Copy link
Member

Fixes #3115.

I hadn't seen this version of the code with phrases like is('nullish', 'string'). Very clever & readable! The code as-is does a lot of loop iterations, but I guess that's fine because type unions are typically very small?

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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.

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the strict-boolean-expressions-truthy-literals branch from d7020d4 to 2487479 Compare March 29, 2021 04:08
@JoshuaKGoldberg
Copy link
Member Author

Well this is an error I haven't seen in a while 😄 :

[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.6.2.tgz: Request failed \"500 Internal Server Error\"".

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the strict-boolean-expressions-truthy-literals branch from 2487479 to 201ac41 Compare March 29, 2021 04:10
@codecov
Copy link

codecov bot commented Mar 29, 2021

Codecov Report

Merging #3236 (42fae56) into master (5414bf2) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3236      +/-   ##
==========================================
- Coverage   92.93%   92.82%   -0.11%     
==========================================
  Files         316      318       +2     
  Lines       10851    10983     +132     
  Branches     3067     3104      +37     
==========================================
+ Hits        10084    10195     +111     
- Misses        342      349       +7     
- Partials      425      439      +14     
Flag Coverage Δ
unittest 92.82% <100.00%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...int-plugin/src/rules/strict-boolean-expressions.ts 98.78% <100.00%> (+0.07%) ⬆️
packages/eslint-plugin/src/rules/no-unsafe-call.ts 95.23% <0.00%> (-4.77%) ⬇️
...-plugin/src/rules/no-unnecessary-type-assertion.ts 92.30% <0.00%> (-2.36%) ⬇️
...eslint-plugin/src/rules/no-unsafe-member-access.ts 97.82% <0.00%> (-2.18%) ⬇️
...ckages/eslint-plugin/src/rules/no-unsafe-return.ts 98.24% <0.00%> (-1.76%) ⬇️
...es/eslint-plugin/src/rules/no-unsafe-assignment.ts 92.96% <0.00%> (-0.26%) ⬇️
packages/eslint-plugin/src/rules/no-type-alias.ts 100.00% <0.00%> (ø)
...ages/eslint-plugin/src/rules/no-unsafe-argument.ts 81.15% <0.00%> (ø)
...ckages/eslint-plugin/src/util/getThisExpression.ts 84.61% <0.00%> (ø)

@bradzacher bradzacher added the bug Something isn't working label Mar 29, 2021
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! almost there - one comment

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Apr 2, 2021
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet - thanks for this!

@bradzacher bradzacher changed the title fix(eslint-plugin): account for truthy literals in strict-boolean-expressions fix(eslint-plugin): [strict-boolean-expressions] account for truthy literals Apr 5, 2021
@bradzacher bradzacher merged commit 0913f40 into typescript-eslint:master Apr 5, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
@JoshuaKGoldberg JoshuaKGoldberg deleted the strict-boolean-expressions-truthy-literals branch November 17, 2021 07:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[strict-boolean-expressions] False positive with union types having only one falsey value
2 participants