Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(eslint-plugin): [restrict-template-expressions] check base types in allow list#11764
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
fix(eslint-plugin): [restrict-template-expressions] check base types in allow list#11764
Conversation
Allow derived types in template expressions when base types are in allow listFixestypescript-eslint#11759
Thanks for the PR,@Higangssh! 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 onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedNov 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify project configuration. |
nx-cloudbot commentedNov 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
View yourCI Pipeline Execution ↗ for commit80be898
☁️Nx Cloud last updated this comment at |
codecovbot commentedNov 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #11764 +/- ##==========================================- Coverage 90.49% 90.48% -0.01%========================================== Files 522 523 +1 Lines 53367 53393 +26 Branches 8918 8919 +1 ==========================================+ Hits 48293 48315 +22- Misses 5059 5063 +4 Partials 15 15
Flags with carried forward coverage won't be shown.Click here to find out more.
🚀 New features to boost your workflow:
|
JoshuaKGoldberg left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good! ✨
Just a few cleanup/refactor requests, nothing on the core logic. Thanks for getting this started!
packages/eslint-plugin/tests/rules/restrict-template-expressions.test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/eslint-plugin/src/rules/restrict-template-expressions.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/eslint-plugin/src/rules/restrict-template-expressions.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…te-expressions-base-types
- Remove unnecessary test comments- Extract hasBaseTypes to shared util- Create matchesTypeOrBaseType with matcher pattern
Higangssh commentedNov 18, 2025
Thanks for the review! I've addressed all the feedback:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
[Testing] Oh, sory, I just realized - this is missing test coverage for extending multiple classes.
A extends B, CwhereBis listedA extends B, CwhereCis listedA extends B, C+B extends D, EwhereEis listed
etc.
JoshuaKGoldberg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry, a bit more testing please
Higangssh commentedNov 18, 2025
@JoshuaKGoldberg Added tests for multiple interface inheritance. Thanks for the thorough review - really |
JoshuaKGoldberg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
💯 thanks! Very thorough, nicely done.
906cc3c intotypescript-eslint:mainUh oh!
There was an error while loading.Please reload this page.

Fixes#11759
PR Checklist
3Aopen+is%3Aissue+label%3A%22accepting+prs%22)
Overview
This PR fixes an issue where the
restrict-template-expressionsrule incorrectly rejects derived class instancesin template literals when their base class is in the allow list.
Problem
Currently, when a base class is included in the
allowoption, derived classes extending it are still flagged aserrors, violating the Liskov Substitution Principle where subtypes should be substitutable for their supertypes.
Example:
Solution
Implemented recursive base type checking following the pattern established in the no-base-to-string rule:
Changes
scenario