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): [no-base-to-string] support boolean in unions #1979

Merged
merged 3 commits into from May 11, 2020

Conversation

auhsoja
Copy link
Contributor

@auhsoja auhsoja commented May 5, 2020

Fixes #1974.

Added an extra check to the no-base-to-string.ts rule to handle the case when a union includes special-case types (specifically, booleans since those tend to be the most common offenders). Whenever we know we have a union, instead of just checking if there is some useful subtype, we also check if all subtypes are useful. If all subtypes are useful, there should be no warning.

Note: This should almost certainly be removed once the boolean toString no longer requires special consideration.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @auhsoja!

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.

@codecov
Copy link

codecov bot commented May 5, 2020

Codecov Report

Merging #1979 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1979   +/-   ##
=======================================
  Coverage   93.91%   93.92%           
=======================================
  Files         171      171           
  Lines        7789     7798    +9     
  Branches     2240     2243    +3     
=======================================
+ Hits         7315     7324    +9     
  Misses        217      217           
  Partials      257      257           
Flag Coverage Δ
#unittest 93.92% <100.00%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
...kages/eslint-plugin/src/rules/no-base-to-string.ts 98.30% <100.00%> (+0.30%) ⬆️

@bradzacher bradzacher added the bug Something isn't working label May 5, 2020
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.

LGTM! thanks for this

@bradzacher bradzacher changed the title fix(eslint-plugin): [no-base-to-string] false positives due to union including boolean fix(eslint-plugin): [no-base-to-string] support boolean in unions May 11, 2020
@bradzacher bradzacher merged commit 6987ecc into typescript-eslint:master May 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[no-base-to-string] still many false positive with union values
2 participants