-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
require-post-message-target-origin
shouldn't trigger for incompatible APIs
#1396
Comments
Sorry, didn't know this. As I understand, |
You understood right, |
Do you think disable this rule in your file or project is a good idea? If you are developing a browser extension, you probably don't need call window.postMessage. |
Yep, you're right, I shouldn't be using Thanks for the quick response! |
But is it common to use worker in extension? In that case people may need |
Wait, worker.postMessage second parameter is not |
I think we should turn this rule off... |
I'm not sure why this rule exists, the parameter
|
Our rule should support JavasScript,
|
Ok got it, the problem is more that browsers fail silently instead of throwing an exception. What if this rule only triggers for rules: {
'unicorn/require-post-message-target-origin': ['error', 'window' | 'any'],
} |
This rule should not trigger on const msg: MainToWorkerMessage = { sharedBuffer, id, args }
new Worker('', {}).postMessage(msg) |
I think this rule is safe only if types are available:
Can that be done? |
I don't think so, without type info, we can't know where the |
👆 Yes I'm talking about a TypeScript-only rule. My question was about looking into the types of the to ensure that the matches our expectation. |
That will be meaningless if this #1396 (comment) is true. |
Indeed it is! So this rule can be dropped altogether as far as I'm concerned. |
So |
Reopen this since |
@2000yeshu What's your solution for this? |
require-post-message-target-origin
shouldn't trigger in web extension contextrequire-post-message-target-origin
shouldn't trigger for incompatible APIs
What's wrong
I'm currently developing a browser extension that communicates with native software:
Which rule is buggy
require-post-message-target-origin
is triggered but the method only accepts one argument (see runtime.Port).Ideas
window
,document
or the likes.'webextension-polyfill'
/'webextension-polyfill-ts'
.The text was updated successfully, but these errors were encountered: