-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): add rule non-nullable-type-assertion-style
#2624
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
feat(eslint-plugin): add rule non-nullable-type-assertion-style
#2624
Conversation
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. |
ed64bf9
to
7f691fd
Compare
7f691fd
to
33853dd
Compare
33853dd
to
7c4e7ed
Compare
Codecov Report
@@ Coverage Diff @@
## master #2624 +/- ##
==========================================
+ Coverage 92.75% 92.77% +0.02%
==========================================
Files 309 310 +1
Lines 10335 10367 +32
Branches 2927 2934 +7
==========================================
+ Hits 9586 9618 +32
Misses 346 346
Partials 403 403
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Code itself LGTM.
I wonder if this rule could also check for this case:
type T = string | null;
declare const x: T;
const y = x as NonNullable<T>;
// should be
const y = x!;
packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts
Outdated
Show resolved
Hide resolved
Adding |
Amusingly, even though I took a month and a half to get back to this, it's already supported: the logic just checks for whether the types are the same but for |
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.
LGTM - thanks for your work!
non-nullable-type-assertion-style
Fixes #202.