-
-
Notifications
You must be signed in to change notification settings - Fork 686
fix(linter): postmessage is not called on window (#12026) #14192
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
base: main
Are you sure you want to change the base?
fix(linter): postmessage is not called on window (#12026) #14192
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
There was a problem hiding this 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.
crates/oxc_linter/src/rules/unicorn/require_post_message_target_origin.rs
Outdated
Show resolved
Hide resolved
if let Expression::Identifier(ident) = expr | ||
&& matches!(ident.name.as_str(), "port" | "port1" | "port2" | "messagePort") |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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>
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.