-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(typescript-estree): if the template literal is tagged and the text has an invalid escape, cooked will be null
#11355
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for the PR, @nayounsang! 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 project configuration. |
cooked will be nullcooked will be null
|
View your CI Pipeline Execution ↗ for commit f43e69b
☁️ Nx Cloud last updated this comment at |
|
It's strange. In my local, I cleared the cache and the changed types were built in the types package. Isn't the CI environment a new virtual machine that runs anyway?
|
|
hi @JamesHenry
|
|
@nayounsang Yes, sorry I forgot about this one, I obviously kept iterating on your other one to discover that one wasn't a caching issue. This one might be related to your other one or it might be totally separate. Please revert my changes when you fix up the conflicts and let's get back to a clean slate. If it's still failing unexpectedly after that I can take another look |
|
@nayounsang I see you're doing a lot of pushes that result in failed tasks. Are you running these things locally before pushing? Ideally you would iterate locally to get the high priority tasks passing and then push up to CI to verify in a neutral environment |
|
CI is failed again.. I guess more work is needed |
packages/eslint-plugin-internal/tests/rules/plugin-test-formatting.test.ts
Outdated
Show resolved
Hide resolved
| ) { | ||
| key = receiverProperty.key.quasis[0].value.cooked; | ||
| const cooked = receiverProperty.key.quasis[0].value.cooked; | ||
| if (cooked == null) { |
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.
This is an impossible condition (and the test provided doesn't reach it).
This branch refers to keys whose node type is a TemplateLiteral... Which necessarily means they are untagged. If it were tagged it would have the TaggedTemplateExpression.
Suggestion:
Use nullThrows() instead
| value = member.initializer.quasis[0].value.cooked; | ||
| // cooked can only be null inside a TaggedTemplateExpression, which is not possible. | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| value = member.initializer.quasis[0].value.cooked!; |
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.
Suggestion: Use nullThrows() here instead
| node, | ||
| ), | ||
| }); | ||
| const result = this.createNode<TSESTree.TaggedTemplateExpression>( |
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.
Revert?

PR Checklist
TemplateElementinTaggedTemplateExpression#11353Overview
ref: https://github.com/estree/estree/blob/2bc9ea235184b6164e31b1088575447657e686c6/es2018.md?plain=1#L34
cookedin theast-spec