-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore: enable no-unsafe-assignment internally #3280
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
chore: enable no-unsafe-assignment internally #3280
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. |
Codecov Report
@@ Coverage Diff @@
## master #3280 +/- ##
=======================================
Coverage 92.68% 92.68%
=======================================
Files 318 318
Lines 11100 11100
Branches 3152 3152
=======================================
Hits 10288 10288
Misses 361 361
Partials 451 451
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
const ReferenceTrackerREAD: unique symbol = eslintUtils.ReferenceTracker.READ; | ||
const ReferenceTrackerCALL: unique symbol = eslintUtils.ReferenceTracker.CALL; | ||
const ReferenceTrackerCONSTRUCT: unique symbol = | ||
eslintUtils.ReferenceTracker.CONSTRUCT; | ||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */ |
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.
we could probably just improve the internal types here?
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/experimental-utils/typings/eslint-utils.d.ts
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.
I went down a bit of a rabbit hole on this one... In theory we could turn them into their own unique symbol
s, and use typeof ...
for the types here.
Unfortunately that then means that the eslint-utils/ReferenceTracker.d.ts
output file now has an import from eslint-utils
, which causes compile complaints:
Error: @typescript-eslint/eslint-plugin-internal: ../experimental-utils/dist/ast-utils/eslint-utils/ReferenceTracker.d.ts(1,30): error TS7016: Could not find a declaration file for module 'eslint-utils'. '/home/runner/work/typescript-eslint/typescript-eslint/node_modules/eslint-utils/index.js' implicitly has an 'any' type.
At that point I gave up.
@@ -5,4 +5,5 @@ export { | |||
} from '@typescript-eslint/typescript-estree'; | |||
|
|||
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder | |||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | |||
export const version: string = require('../package.json').version; |
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.
perhaps we should add a global type declaration to the project.
Something like
declare module '../package.json' {
export const version = string;
}
would that fix this problem?
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.
I don't think so 😕 , in @types/node/globals.d.ts
NodeJS.Require
is typed as returning any
from its (id: string)
function signature.
interface Require {
(id: string): any;
packages/scope-manager/tests/util/serializers/baseSerializer.ts
Outdated
Show resolved
Hide resolved
I'm waiting to update this and continue internal linting work until #3281 is in, btw. |
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
const ReferenceTrackerREAD: unique symbol = eslintUtils.ReferenceTracker.READ; | ||
const ReferenceTrackerCALL: unique symbol = eslintUtils.ReferenceTracker.CALL; | ||
const ReferenceTrackerCONSTRUCT: unique symbol = | ||
// TODO: FILE ISSUE(S) SOMEWHERE |
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 like this is just... how it has to be! https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html
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 turning this on!
Continues #3278.
Most of the files that already contained numerous errors also disabled
@typescript-eslint/no-explicit-any
.