mozilla / eslint-plugin-no-unsanitized

Custom ESLint rule to disallows unsafe innerHTML, outerHTML, insertAdjacentHTML and alike
Mozilla Public License 2.0
228 stars 37 forks source link

Unsupported Callee of type TypeCastExpression for CallExpression #155

Closed jdlm-stripe closed 3 years ago

jdlm-stripe commented 3 years ago

eslint-plugin-no-unsanitized version: 3.1.4

I ran into an issue with the plugin when we explicitly annotate functions in flow and try to execute them. I've repro'd the issue with a couple versions of eslint which implies it's likely a bug here. Here's a minimal repro:

index.js

// @flow
type SayHello = () => void;

const sayHello = () => { console.log('hello!') };

(sayHello: SayHello)(); // <-- error happens here

Error:

  6:2  error  Error in no-unsanitized: Unexpected Callee. Please report a minimal code snippet to the developers at https://github.com/mozilla/eslint-plugin-no-unsanitized/issues/new?title=Unsupported%20Callee%20of%20type%20TypeCastExpression%20for%20CallExpression  no-unsanitized/method

✖ 1 problem (1 error, 0 warnings)
mozfreddyb commented 3 years ago

Thank you for filing the issue!

TypeScript support is experimental, as we do not use TypeScript ourselves. But I'd be happy to mentor you or someone else getting this through, the patch should be very similar to what we did in #137.

Paging @LukeWood and @LukeWoodG for visibility.

jdlm-stripe commented 3 years ago

And thank you for your prompt response! Totally makes sense and thanks for linking that reference PR. I'll circle back in a few weeks if I can carve out the time to fix it.

LukeWood commented 3 years ago

thanks - keep me posted @jdlm-stripe. if you have any trouble creating a fix feel free to message me