Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): [consistent-type-imports] ignore files with decorators, experimentalDecorators, and emitDecoratorMetadata#8335
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR,@bradzacher! 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 commentedFeb 1, 2024 • 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 site configuration. |
…rators, experimentalDecorators, and emitDecoratorMetadata
f3525d4 to1c1f9f4Comparecodecovbot commentedFeb 1, 2024 • 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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #8335 +/- ##==========================================+ Coverage 87.38% 87.98% +0.59%========================================== Files 254 404 +150 Lines 12489 14045 +1556 Branches 3919 4110 +191 ==========================================+ Hits 10914 12358 +1444- Misses 1304 1382 +78- Partials 271 305 +34
Flags with carried forward coverage won't be shown.Click here to find out more.
|
Uh oh!
There was an error while loading.Please reload this page.
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.
Really nice solution, +1 from me on the direction!
Requesting changes mainly on extracting the deeper explanations out of the rule file and into a blog post. Also for at least resolving the breaking change discussion.
But the rule's new implementation looks great to me (thanks for the whitespace suggestion!). ✨
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
ZackMFleischman commentedFeb 9, 2024
@bradzacher Thanks for building this solution! I'm eagerly awaiting it being merged so I can use it in my project where I've been forced to just turn this rule off entirely for the moment. Also hi@JoshuaKGoldberg! Always fun to see your name pop up. Thanks for fighting the good fight and keeping high-quality open source software available! 😄 |
JoshuaKGoldberg commentedFeb 10, 2024
Haha hey@ZackMFleischman, great to see you pop up too! 😄 |
nx-cloudbot commentedMar 18, 2024 • 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.
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.
Awesome! I'm super happy with the implementation, and think I understand this much better now thanks to the docs & comments. Thanks!
Left some proofreading thoughts on the blog post. That's the only real blocker from me - and there's nothing I likely can't be convinced otherwise on.
🔥
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.md OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.md OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.md OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.mdShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.md OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.md OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.md OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
packages/website/blog/2024-03-25-changes-to-consistent-type-imports-with-decorators.mdShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
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.
Whoop, this is great - useful userland fixing and really solid explanations@bradzacher! 👏
| <!-- prettier-ignore--> | ||
| ```ts | ||
| var _a; |
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.
Nit: this isn't used later.
| var _a; |
If TypeScript is producing an_a despite never using it, then that's a bug we can ignore.
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.
Oh nah it was there cos the code has no types so this is an extra case I (purposely) didn't mention. In this case when TS can't determine the type but it can see its a value-import - instead TS emits[typeof _a = (typeof Foo !== "undefined" && Foo) === "function" ? _a : Object]. Which is some funky code-golf heh.
Can remove it though yeah as it's not necessary for the examples I'm mentioning.
…rators, experimentalDecorators, and emitDecoratorMetadata (typescript-eslint#8335)
…rators, experimentalDecorators, and emitDecoratorMetadata (typescript-eslint#8335)

PR Checklist
Overview
Note: I've labelled this as a
featon purpose to mark it for a minor bump. It's technically a "bug fix" but it's also a change in behaviour. One might classify it as a breaking change because a specific usecase will require a config change - but given that usecases is also already broken, I didn't think that it truly qualified as breaking.This PR implements a sledge-hammer approach to fixing the problem in#5468 - I have opted to just completely ignore a file if it passes all three of the following conditions:
experimentalDecorators: trueemitDecoratorMetadata: trueOriginally in#5468 I suggested going with the the approach of specifically ignoring imports that are used in locations that might be passed to decorator metadata. However I ultimately chose not to go down this path because:
experimentalDecoratorsis considered legacyverbatimModuleSyntaxexists for the above usecaseexperimentalDecoratorsThis PR:
scope-managerexperimentalDecoratorsparser option that is auto-populated from type info if availableexperimentalDecoratorsandemitDecoratorMetadataon the parser servicesconsistent-type-imports:NOTE:: I strongly suggest turning on the no-whitespace diff when reviewing this PR.