Skip to content

Conversation

@re-taro
Copy link
Contributor

@re-taro re-taro commented Dec 8, 2025

This PR adds unicorn/prefer-keyboard-event-key rule, issue #684

rule doc
rule source

@re-taro re-taro requested a review from camc314 as a code owner December 8, 2025 16:47
Copilot AI review requested due to automatic review settings December 8, 2025 16:47
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Dec 8, 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 implements the unicorn/prefer-keyboard-event-key linter rule, which enforces the use of the modern KeyboardEvent.key property over the deprecated keyCode, charCode, and which properties. The rule includes auto-fix capabilities that can automatically replace deprecated property accesses with the appropriate key comparisons when used in binary expressions.

Key Changes

  • Adds comprehensive rule implementation with support for detecting deprecated properties in direct property access and destructuring patterns
  • Implements auto-fix functionality that converts numeric key code comparisons to string key comparisons
  • Includes extensive test coverage with 47 failing cases and 20 fix test cases

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_linter/src/rules/unicorn/prefer_keyboard_event_key.rs Complete rule implementation with detection logic, auto-fix, and comprehensive test suite
crates/oxc_linter/src/rules.rs Registers the new rule in the linter's rule registry
crates/oxc_linter/src/snapshots/unicorn_prefer_keyboard_event_key.snap Test snapshot containing expected diagnostic outputs

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 8, 2025

CodSpeed Performance Report

Merging #16611 will not alter performance

Comparing re-taro:feat/prefer-keyboard-event-key (7c241e0) with main (0be98b9)

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.

@re-taro re-taro force-pushed the feat/prefer-keyboard-event-key branch from 6e1e4a1 to 438f8b2 Compare December 9, 2025 02:07
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Unfortunately it looks like CI is failing as not all the test cases are passing

@camc314 camc314 self-assigned this Dec 9, 2025
@re-taro re-taro requested a review from camc314 December 9, 2025 15:36
@camc314 camc314 force-pushed the feat/prefer-keyboard-event-key branch from 59bb678 to 7c241e0 Compare December 10, 2025 12:13
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

Thank you!

@camc314 camc314 merged commit 200d17b into oxc-project:main Dec 10, 2025
20 checks passed
@re-taro re-taro deleted the feat/prefer-keyboard-event-key branch December 10, 2025 16:09
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.

3 participants