Skip to content

feat(eslint-plugin): [no-base-to-string] add checkUnknown Option #11128

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

developer-bandi
Copy link
Contributor

@developer-bandi developer-bandi commented May 4, 2025

PR Checklist

Overview

add checkUnknown option.

One thing I'm curious about is, is it correct to treat generic types as unknown?

function foo<T>(x: T) {
  String(x);
}

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @developer-bandi!

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.

@developer-bandi developer-bandi marked this pull request as draft May 4, 2025 15:33
Copy link

netlify bot commented May 4, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 3bdc647
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/6829e2abb016df000872d8e2
😎 Deploy Preview https://deploy-preview-11128--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

nx-cloud bot commented May 4, 2025

View your CI Pipeline Execution ↗ for commit 3bdc647.

Command Status Duration Result
nx typecheck ast-spec ✅ Succeeded <1s View ↗
nx run-many -t build --exclude website website-... ✅ Succeeded 2s View ↗
nx run-many -t clean --parallel=20 ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-19 13:15:14 UTC

@developer-bandi developer-bandi marked this pull request as ready for review May 6, 2025 06:18
@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(eslint-plugin): [no-base-to-string] add restrictUnknown Option feat(eslint-plugin): [no-base-to-string] add checkUnknown Option May 12, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg 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!

Could you please get a passing CI so we can merge this though?

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

(wrong button)

Copy link

codecov bot commented May 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.92%. Comparing base (bca8a91) to head (3bdc647).
Report is 72 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11128      +/-   ##
==========================================
+ Coverage   90.84%   90.92%   +0.08%     
==========================================
  Files         497      499       +2     
  Lines       50320    50855     +535     
  Branches     8311     8387      +76     
==========================================
+ Hits        45714    46241     +527     
- Misses       4591     4599       +8     
  Partials       15       15              
Flag Coverage Δ
unittest 90.92% <100.00%> (+0.08%) ⬆️

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

Files with missing lines Coverage Δ
...kages/eslint-plugin/src/rules/no-base-to-string.ts 98.94% <100.00%> (+0.03%) ⬆️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@developer-bandi
Copy link
Contributor Author

LGTM, thanks!

Could you please get a passing CI so we can merge this though?

I added an option description to the document because there was an error that occurred not only in the CI error but also in the document due to not adding the option.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg 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! 🚀

Just a couple small comment on the meta property, nothing we can't touch up before merge.

type: 'boolean',
default: false,
description:
'Checks the case where toString is applied to unknown type',
Copy link
Member

Choose a reason for hiding this comment

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

[Docs] A little bit of phrasing alignment:

Suggested change
'Checks the case where toString is applied to unknown type',
'Whether to also check values of type `unknown`',

@@ -46,6 +47,12 @@ export default createRule<Options, MessageIds>({
type: 'object',
additionalProperties: false,
properties: {
checkUnknown: {
type: 'boolean',
default: false,
Copy link
Member

Choose a reason for hiding this comment

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

[Cleanup] This actually doesn't do anything in our stack (long story...)

Suggested change
default: false,

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [no-base-to-string] False negative for unknown type
2 participants