Registry / security / eslint-plugin-no-wildcard-postmessage

eslint-plugin-no-wildcard-postmessage

JSON →
library0.2.0jsnpmunverified

ESLint plugin that enforces a custom rule disallowing calls to `postMessage` with a wildcard target origin (`"*"`). Stable version 0.2.0, no frequent updates. This is a security-focused lint rule used internally at Mozilla to prevent unsafe cross-origin messaging; it only targets the `postMessage` API and is a lightweight, single-rule plugin.

npm install eslint-plugin-no-wildcard-postmessage
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NO-W
E
eslint-plugin-no-wildcard-postmessage
securityjavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

no-wildcard-postmessage
plugins: ['no-wildcard-postmessage']
plugins: ['eslint-plugin-no-wildcard-postmessage']
In ESLint config, omit the 'eslint-plugin-' prefix when referencing the plugin name.
rule: no-wildcard-postmessage/no-wildcard-postmessage
rules: { 'no-wildcard-postmessage/no-wildcard-postmessage': 'error' }
rules: { 'no-wildcard-postmessage': 'error' }
The rule is namespaced under the plugin name; the full rule name is 'no-wildcard-postmessage/no-wildcard-postmessage'.
rules: ["@mozilla/gaia/postmessage"] (deprecated)
rules: { 'no-wildcard-postmessage/no-wildcard-postmessage': 'error' }
rules: { '@mozilla/gaia/postmessage': 'error' }
The rule was previously under a different namespace in older versions; using the old namespace no longer works.

Shows installation, ESLint configuration, and example violations/allowed usage for the no-wildcard-postmessage rule.

// Install the plugin npm install --save-dev eslint-plugin-no-wildcard-postmessage // .eslintrc.json { "plugins": ["no-wildcard-postmessage"], "rules": { "no-wildcard-postmessage/no-wildcard-postmessage": "error" } } // Example violation: // frame.postMessage(obj, "*"); // ESLint will report error // Allowed: // frame.postMessage(obj, "https://example.com"); // postMessage(obj); // in a worker // Important: The rule only checks postMessage calls where the second argument is a string literal "*". Variables or computed values are not checked.
Debug
Known issues
gotchaThe rule only flags literal string '*' as the second argument. Expressions like `frame.postMessage(obj, target)` where `target` is a variable set to '*' will not be caught.
fix
Use additional linting or runtime checks to ensure variables used as target origin are not wildcard.
affects: >=0.0.0
gotchaThe plugin has a single rule that is duplicated in its full name: plugin name and rule name are both 'no-wildcard-postmessage'.
fix
In ESLint config, use the rule name 'no-wildcard-postmessage/no-wildcard-postmessage'.
affects: >=0.0.0
deprecatedThe rule was originally named '@mozilla/gaia/postmessage' in internal Mozilla usage. That namespace is deprecated and not available in the npm package.
fix
Use 'no-wildcard-postmessage/no-wildcard-postmessage' instead.
affects: >=0.0.0
Errors
Common errors & fixes
ESLint: Configuration for rule "no-wildcard-postmessage" is invalid.
Using the rule name without the plugin prefix.
fix
Use 'no-wildcard-postmessage/no-wildcard-postmessage' as the rule key.
Cannot find module 'eslint-plugin-no-wildcard-postmessage'
Missing npm install or module resolution issue.
fix
Run 'npm install --save-dev eslint-plugin-no-wildcard-postmessage' and ensure eslint can resolve the plugin.
Definition for rule 'no-wildcard-postmessage/no-wildcard-postmessage' was not found.
Plugin not loaded in ESLint config.
fix
Add 'plugins: ["no-wildcard-postmessage"]' to your ESLint config.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to load the plugin as an ESLint rule
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
eslint-plugin-no-wildcard-postmessage — npm install eslint-plugin-no-wildcard-postmessage · libregistry