Repository navigation
feat(eslint-plugin): [no-unnecessary-type-assertion] add option to ignore string const assertions - #10979
Conversation
|
Thanks for the PR, @KuSh! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
View your CI Pipeline Execution ↗ for commit fa008e4.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10979 +/- ##
==========================================
- Coverage 90.82% 90.82% -0.01%
==========================================
Files 497 497
Lines 50204 50222 +18
Branches 8274 8278 +4
==========================================
+ Hits 45600 45615 +15
- Misses 4589 4592 +3
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
There was a problem hiding this comment.
A great start, thank you 🎉! Seems like a very reasonable implementation direction. I left a few comments to expand it a bit & flip the logic.
|
@JoshuaKGoldberg I've taken your comments and suggestions into account. |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Looking good! Just a few small things requested, no actual logic changes.
I've taken your suggestions into account, thanks |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Looks like tests are failing on some unknown option names - missed a few spots? 🙂
Yeah sorry about that. It should be OK now! |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
LGTM, and a nice reorganization of tests. Thanks! 🎉
ronami
left a comment
There was a problem hiding this comment.
🚀🚀 Looking great! I've added a couple of comments.
0251979 to
7a3d342
Compare
… no-unnecessary-type-assertion rule Fixes typescript-eslint#8721
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
| datasource | package | from | to | | ---------- | -------------------------------- | ------ | ------ | | npm | @typescript-eslint/eslint-plugin | 8.29.0 | 8.31.0 | | npm | @typescript-eslint/parser | 8.29.0 | 8.31.0 | ## [v8.31.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8310-2025-04-21) ##### 🚀 Features - **eslint-plugin:** \[no-unnecessary-type-assertion] add option to ignore string const assertions ([#10979](typescript-eslint/typescript-eslint#10979)) ##### ❤️ Thank You - Nicolas Le Cam You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ## [v8.30.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8301-2025-04-14) ##### 🩹 Fixes - **eslint-plugin:** fix mistake with eslintrc config generation ([#11072](typescript-eslint/typescript-eslint#11072)) ##### ❤️ Thank You - Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ## [v8.30.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8300-2025-04-14) ##### 🚀 Features - **eslint-plugin:** \[no-explicit-any] suggest to replace keyof any with PropertyKey ([#11032](typescript-eslint/typescript-eslint#11032)) ##### 🩹 Fixes - **eslint-plugin:** \[promise-function-async] use a different error message for functions with promise and non-promise types ([#10950](typescript-eslint/typescript-eslint#10950)) ##### ❤️ Thank You - Dima Barabash [@dbarabashh](https://github.com/dbarabashh) - Ronen Amiel You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ## [v8.29.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8291-2025-04-07) ##### 🩹 Fixes - **eslint-plugin:** \[no-deprecated] report on deprecated imported variable used as property ([#10998](typescript-eslint/typescript-eslint#10998)) ##### ❤️ Thank You - Ronen Amiel You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
| datasource | package | from | to | | ---------- | -------------------------------- | ------ | ------ | | npm | @typescript-eslint/eslint-plugin | 8.29.0 | 8.31.0 | | npm | @typescript-eslint/parser | 8.29.0 | 8.31.0 | ## [v8.31.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8310-2025-04-21) ##### 🚀 Features - **eslint-plugin:** \[no-unnecessary-type-assertion] add option to ignore string const assertions ([#10979](typescript-eslint/typescript-eslint#10979)) ##### ❤️ Thank You - Nicolas Le Cam You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ## [v8.30.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8301-2025-04-14) ##### 🩹 Fixes - **eslint-plugin:** fix mistake with eslintrc config generation ([#11072](typescript-eslint/typescript-eslint#11072)) ##### ❤️ Thank You - Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ## [v8.30.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8300-2025-04-14) ##### 🚀 Features - **eslint-plugin:** \[no-explicit-any] suggest to replace keyof any with PropertyKey ([#11032](typescript-eslint/typescript-eslint#11032)) ##### 🩹 Fixes - **eslint-plugin:** \[promise-function-async] use a different error message for functions with promise and non-promise types ([#10950](typescript-eslint/typescript-eslint#10950)) ##### ❤️ Thank You - Dima Barabash [@dbarabashh](https://github.com/dbarabashh) - Ronen Amiel You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ## [v8.29.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8291-2025-04-07) ##### 🩹 Fixes - **eslint-plugin:** \[no-deprecated] report on deprecated imported variable used as property ([#10998](typescript-eslint/typescript-eslint#10998)) ##### ❤️ Thank You - Ronen Amiel You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
…nore string const assertions (typescript-eslint#10979) * feat(eslint-plugin): add option to ignore string const assertiions in no-unnecessary-type-assertion rule Fixes typescript-eslint#8721 * review: Enable const assertions on all literals by default * fix: Handle null, undefined and boolean literal expressions * Apply suggestions from code review Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com> * Apply suggestions from code review typescript-eslint#2

PR Checklist
Overview
Add new ignoreStringConstAssertion that ignores const assertions on string literals to as it is a common use case to force typescript to not widen type to string