Skip to content

Conversation

Kenzo-Wada
Copy link

fixes: #12026

Hi, oxc team!
I'm new to oxc, so if there are any rules or guidelines I should know about, please let me know.

@Kenzo-Wada Kenzo-Wada requested a review from camc314 as a code owner September 27, 2025 16:55
@Copilot Copilot AI review requested due to automatic review settings September 27, 2025 16:55
Copy link
Contributor

graphite-app bot commented Sep 27, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Sep 27, 2025
Copy link
Contributor

@Copilot 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 fixes a false positive in the require_post_message_target_origin linter rule where it was incorrectly flagging postMessage calls on MessagePort objects, which don't require a targetOrigin argument unlike window.postMessage.

  • Adds detection logic to identify MessagePort expressions and exclude them from the linter rule
  • Introduces a new helper function is_message_port_expression to check for various MessagePort patterns
  • Updates test cases to verify the fix works for different MessagePort usage patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 88 to 89
if let Expression::Identifier(ident) = expr
&& matches!(ident.name.as_str(), "port" | "port1" | "port2" | "messagePort")
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

[nitpick] The hardcoded identifier names 'port', 'port1', 'port2', 'messagePort' are magic strings that could be extracted to constants for better maintainability and reusability.

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

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

Since there was a place where it was hardcoded like Some(name) if name == "postMessage", I've left it as is for now.

Kenzo-Wada and others added 2 commits September 28, 2025 01:56
…t_origin.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Kenzo Wada <79452224+Kenzo-Wada@users.noreply.github.com>
@overlookmotel overlookmotel changed the title fix(linter/plugins): postmessage is not called on window (#12026) fix(linter): postmessage is not called on window (#12026) Sep 28, 2025
@camc314 camc314 self-assigned this Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive for eslint-plugin-unicorn(require-post-message-target-origin)

2 participants