require-post-message-target-origin
March 27, 2026 ยท View on GitHub
๐ Enforce using the targetOrigin argument with window.postMessage().
๐ซ This rule is disabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ก This rule is manually fixable by editor suggestions.
When calling window.postMessage() without the targetOrigin argument, the message cannot be received by any window.
This rule cannot distinguish between window.postMessage() and other calls like Worker#postMessage(), MessagePort#postMessage(), Client#postMessage(), and BroadcastChannel#postMessage(). Use on your own risk.
Examples
// โ
window.postMessage(message);
// โ
window.postMessage(message, 'https://example.com');
// โ
window.postMessage(message, '*');