Skip to content

fix(eslint-plugin-template): [prefer-template-literal] handle parentheses in autofix #2418

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

Conversation

g-drouard
Copy link
Contributor

@g-drouard g-drouard commented May 12, 2025

Examples of autofix error cases

In some cases (when autofix result is a template), a parenthesis is removed but not both.

'prefix-' + (condition ? 'true' : 'false') => `prefix-${condition ? 'true' : 'false'}`)

('value' | pipe) + "-suffix" => (`${'value' | pipe}-suffix`

Fix

If node is surronded by parentheses remove them, with template literal they become useless

Copy link

nx-cloud bot commented May 12, 2025

View your CI Pipeline Execution ↗ for commit 49342bb.

Command Status Duration Result
nx run-many -t e2e-suite --parallel 1 ✅ Succeeded 23s View ↗
nx run-many -t test --codeCoverage ✅ Succeeded 1m 15s View ↗
nx run-many -t build,typecheck,check-rule-docs,... ✅ Succeeded 1m 7s View ↗
nx-cloud record -- pnpm nx sync:check ✅ Succeeded 2s View ↗
nx-cloud record -- pnpm format-check ✅ Succeeded 6s View ↗
nx run-many -t test ✅ Succeeded 25s View ↗
nx run-many -t build ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-12 10:08:20 UTC

Copy link

codecov bot commented May 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.72%. Comparing base (5303199) to head (49342bb).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2418      +/-   ##
==========================================
+ Coverage   92.70%   92.72%   +0.02%     
==========================================
  Files         195      195              
  Lines        4056     4071      +15     
  Branches      930      937       +7     
==========================================
+ Hits         3760     3775      +15     
  Misses        228      228              
  Partials       68       68              
Flag Coverage Δ
unittest 92.72% <100.00%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
...ugin-template/src/rules/prefer-template-literal.ts 98.33% <100.00%> (+0.55%) ⬆️
...plate/tests/rules/prefer-template-literal/cases.ts 100.00% <ø> (ø)
🚀 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.

@g-drouard g-drouard changed the title fix(prefer-template-literal): Autofix doesn't handle parentheses fix(eslint-plugin-template): [prefer-template-literal] Autofix doesn't handle parentheses May 12, 2025
@JamesHenry JamesHenry changed the title fix(eslint-plugin-template): [prefer-template-literal] Autofix doesn't handle parentheses fix(eslint-plugin-template): [prefer-template-literal] handle parentheses in autofix May 13, 2025
@JamesHenry JamesHenry merged commit 286546f into angular-eslint:main May 13, 2025
25 checks passed
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.

2 participants