Skip to content

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

nayounsang
Copy link
Contributor

@nayounsang nayounsang commented Jun 28, 2025

PR Checklist

Overview

ref: https://github.com/estree/estree/blob/2bc9ea235184b6164e31b1088575447657e686c6/es2018.md?plain=1#L34

  • Add a flag isInTaggedTemplate indicating whether template literal is tagged
  • Function to validate escape
  • Add test case

@typescript-eslint
Copy link
Contributor

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.

Copy link

netlify bot commented Jun 28, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit b85dda1
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/688f6db3a3d70d0008421a89
😎 Deploy Preview https://deploy-preview-11355--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (no change from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@nayounsang nayounsang marked this pull request as draft June 28, 2025 08:59
@nayounsang nayounsang changed the title fix(typescript-estree): If the template literal is tagged and the text has an invalid escape, cooked will be null fix(typescript-estree): if the template literal is tagged and the text has an invalid escape, cooked will be null Jun 28, 2025
Copy link

nx-cloud bot commented Jun 28, 2025

View your CI Pipeline Execution ↗ for commit b85dda1

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 6s View ↗
nx run-many -t lint ✅ Succeeded 3m 20s View ↗
nx run-many -t typecheck ✅ Succeeded 2m 27s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 22s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 11s View ↗
nx run generate-configs ✅ Succeeded 16s View ↗
nx run types:build ✅ Succeeded 10s View ↗
nx run integration-tests:test ✅ Succeeded 5s View ↗
Additional runs (27) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-08-03 14:22:06 UTC

@nayounsang
Copy link
Contributor Author

nayounsang commented Jun 28, 2025

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?


typescript-estree has a dependency on types. TemplateElement comes from types
TemplateElement in types is auto-generated by ast-spec.
In nx cloud, types is hitting cache in CI.
So, changes are not updated and an error occurs.
Do I need to do something separate?

@nayounsang
Copy link
Contributor Author

nayounsang commented Jul 20, 2025

hi @JamesHenry
Thank you for your efforts on this difficult problem.

  • Can I continue working on this PR?
  • Is it okay if I merge with the main branch and resolve conflicts freely?
  • If CI-related work is not completed, can I help?

@JamesHenry
Copy link
Member

@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

@JamesHenry
Copy link
Member

@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

@nayounsang
Copy link
Contributor Author

@JamesHenry Sorry, I will push after resolving all failures that occurred in CI next time.

When I work on the command for the project locally, my laptop has a performance issue that makes it not work for a long time. So I tried to check the work result in CI. Still, I was in a hurry.

@@ -8,9 +8,6 @@
{
"path": "../typescript-estree/tsconfig.build.json"
},
{
"path": "../types/tsconfig.build.json"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this message by nx,

NX   The workspace is out of sync

[@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on or contain outdated project references.

? Would you like to sync the identified changes to get your workspace up to date? … 
Yes, sync the changes and run the tasks
No, run the tasks without syncing the changes

There are a lot of changes like this due to sync, but even after reading the documentation, I'm not sure if this is correct.
I reverted all dependency related changes.

Copy link

codecov bot commented Aug 2, 2025

Codecov Report

❌ Patch coverage is 71.84466% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.95%. Comparing base (b872e2b) to head (8a67d05).
⚠️ Report is 1 commits behind head on main.

⚠️ Current head 8a67d05 differs from pull request most recent head b85dda1

Please upload reports for the commit b85dda1 to get more accurate results.

Files with missing lines Patch % Lines
packages/typescript-estree/src/convert.ts 77.77% 20 Missing ⚠️
...lugin-internal/src/rules/plugin-test-formatting.ts 14.28% 6 Missing ⚠️
...es/eslint-plugin/src/rules/no-unsafe-assignment.ts 40.00% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (71.84%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11355      +/-   ##
==========================================
+ Coverage   90.86%   90.95%   +0.08%     
==========================================
  Files         503      503              
  Lines       51052    51139      +87     
  Branches     8416     8448      +32     
==========================================
+ Hits        46390    46512     +122     
+ Misses       4648     4614      -34     
+ Partials       14       13       -1     
Flag Coverage Δ
unittest 90.95% <71.84%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...slint-plugin/src/rules/no-duplicate-enum-values.ts 100.00% <100.00%> (ø)
...es/eslint-plugin/src/rules/no-unsafe-assignment.ts 96.72% <40.00%> (-0.80%) ⬇️
...lugin-internal/src/rules/plugin-test-formatting.ts 90.16% <14.28%> (-1.13%) ⬇️
packages/typescript-estree/src/convert.ts 33.27% <77.77%> (+3.06%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nayounsang
Copy link
Contributor Author

nayounsang commented Aug 2, 2025

What is this err on CI?
https://cloud.nx.app/runs/Ol9VgADs38/task/eslint-plugin%3Atypecheck

> tsc --build --emitDeclarationOnly

vitest.config.mts(4,34): error TS6305: Output file '/home/runner/work/typescript-eslint/typescript-eslint/dist/vitest.config.base.d.mts' has not been built from source file '/home/runner/work/typescript-eslint/typescript-eslint/vitest.config.base.mts'.
> tsc --build --emitDeclarationOnly

vitest.config.mts(4,34): error TS6305: Output file '/home/runner/work/typescript-eslint/typescript-eslint/dist/vitest.config.base.d.mts' has not been built from source file '/home/runner/work/typescript-eslint/typescript-eslint/vitest.config.base.mts'.
Warning: command "tsc --build --emitDeclarationOnly" exited with non-zero status code

This is my first time seeing this and I don't know how to fix it in local as content of err msg and success in the local.

expr: TSESTree.TaggedTemplateExpression,
): void {
if (text == null) {
Copy link
Contributor Author

@nayounsang nayounsang Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change affects three rules.
Would it be better to simply ignore it? How should I handle it?
Once this is decided, I will also add tests.

continue;
}

const nextChar = text[index + 1];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't care about if nextChar doesn't exist because of typescript error & parsing error.

@nayounsang nayounsang marked this pull request as ready for review August 3, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Wrong cooked value of TemplateElement in TaggedTemplateExpression
2 participants