Skip to content

Latest commit

Β 

History

History
31 lines (21 loc) Β· 1.39 KB

File metadata and controls

31 lines (21 loc) Β· 1.39 KB

require-post-message-target-origin

πŸ“ 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, '*');