Skip to content

feat(linter): auto-fixer for extra cases in unicorn/prefer-query-selector#16787

Merged
camc314 merged 1 commit intooxc-project:mainfrom
hamirmahal:feat/fix-for-prefer-query-selector-getElementById
Dec 13, 2025
Merged

feat(linter): auto-fixer for extra cases in unicorn/prefer-query-selector#16787
camc314 merged 1 commit intooxc-project:mainfrom
hamirmahal:feat/fix-for-prefer-query-selector-getElementById

Conversation

@hamirmahal
Copy link
Contributor

Closes #16786

@hamirmahal hamirmahal requested a review from camc314 as a code owner December 12, 2025 23:56
Copilot AI review requested due to automatic review settings December 12, 2025 23:56
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Dec 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the prefer-query-selector linter rule to provide automatic fixes for getElementById calls with non-literal arguments (e.g., variables, expressions). The fix transforms these calls into querySelector calls using template literal interpolation.

Key Changes:

  • Added auto-fix support for getElementById with non-literal arguments by wrapping them in template literals with the # selector prefix
  • Added test case demonstrating the fix for getElementById(searchInputId)querySelector(\#${searchInputId}`)`

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 13, 2025

CodSpeed Performance Report

Merging #16787 will not alter performance

Comparing hamirmahal:feat/fix-for-prefer-query-selector-getElementById (7f29287) with main (67bde85)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@hamirmahal hamirmahal force-pushed the feat/fix-for-prefer-query-selector-getElementById branch from 83412ad to df4f680 Compare December 13, 2025 00:24
@hamirmahal hamirmahal requested a review from Copilot December 13, 2025 00:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hamirmahal hamirmahal force-pushed the feat/fix-for-prefer-query-selector-getElementById branch from df4f680 to 7f29287 Compare December 13, 2025 00:39
@connorshea connorshea changed the title feat(linter): fix for prefer-query-selector feat(linter): auto-fixer for eslint/prefer-query-selector Dec 13, 2025
@connorshea connorshea changed the title feat(linter): auto-fixer for eslint/prefer-query-selector feat(linter): auto-fixer for unicorn/prefer-query-selector Dec 13, 2025
@connorshea connorshea changed the title feat(linter): auto-fixer for unicorn/prefer-query-selector feat(linter): auto-fixer for extra cases in unicorn/prefer-query-selector Dec 13, 2025
@connorshea
Copy link
Member

Feel free to adjust the title further, just wanted to make sure the title was clear about fixing a bug vs. adding autofixer logic

@camc314 camc314 merged commit 1f42ad3 into oxc-project:main Dec 13, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: add auto-fix for document.getElementById(variableForId)

4 participants