-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [no-unsafe-assignment/return] allow assigning any => unknown #2371
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): [no-unsafe-assignment/return] allow assigning any => unknown #2371
Conversation
… relaxations for any to unknow
Thanks for the PR, @yasarsid! 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 Report
@@ Coverage Diff @@
## master #2371 +/- ##
==========================================
+ Coverage 93.10% 93.15% +0.05%
==========================================
Files 285 285
Lines 9125 9150 +25
Branches 2504 2513 +9
==========================================
+ Hits 8496 8524 +28
+ Misses 302 301 -1
+ Partials 327 325 -2
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.
Thanks for doing this! The changes LGTM.
One request:
could you please add some tests for isUnsafeAssignment
into
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/tests/util/isUnsafeAssignment.test.ts
Great work!
@bradzacher - Good catch for missing UTs. 👍 As suggested - have added tests in |
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.
ezpz - thanks for your work!
The last few versions of `@typescript/eslint` have contained fixes to deal with the changes in the TypeScript 4 AST. They should still work against TypeScript 3. This also pulls in typescript-eslint/typescript-eslint#2371 which allows assigning `any` to `unknown` in more situations.
The last few versions of `@typescript/eslint` have contained fixes to deal with the changes in the TypeScript 4 AST. They should still work against TypeScript 3. This also pulls in typescript-eslint/typescript-eslint#2371 which allows assigning `any` to `unknown` in more situations.
Fixes #2325
Overview
This PR looks to relax restrictions to allow any => unknown assignment for
no-unsafe-assignment
andno-unsafe-return
.Approach
Initially we are checking for
Any
orAnyArray
assenderType
, if found we used to stop processing with the relevant message.Now we additionally check if the
recieverType
isUnknown
orUnknown
array. If yes - then we do not treat this as an error case.Special Focus
I would like you to specifically look at the coding style, so that we don't adversely affect future contributors. I have tried to align with the existing style. Feel free to point out where we could align more.
Checklist