Skip to content

linter: unicorn/require-post-message-target-origin false positive #10106

@tmr232

Description

@tmr232

What version of Oxlint are you using?

0.16.3

What command did you run?

oxlint -D suspicious

What does your .oxlintrc.json config file look like?

Not using a config file.

What happened?

When running on the code of a VSCode extension, it warned me that the .postMessage are missing the targetOrigin argument:

  × eslint-plugin-unicorn(require-post-message-target-origin): Missing the `targetOrigin` argument.
    ╭─[src/vscode/overview-view.ts:35:45]
 34 │     if (this._view) {
 35 │       this._view.webview.postMessage(message);
    ·                                             ─
 36 │     }
    ╰────
  help: Insert `, self.location.origin`

While this is true in the browser, for window.postMessage, it is not the case for VSCode's webview .postMessage (see https://code.visualstudio.com/api/references/vscode-api#Webview) which only takes a message argument.
I would expect the linter to infer the correct signature and not warn here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions