mozilla / eslint-plugin-no-unsanitized

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

Add Flow TypeCastExpression Support #156

Closed tylerkrupicka-stripe closed 3 years ago

tylerkrupicka-stripe commented 3 years ago

Closes https://github.com/mozilla/eslint-plugin-no-unsanitized/issues/155

Changes to add support for the TypeCastExpression ESLint babel node type, which occurs when someone does a Flow type cast. These node types are already supported by the babel-eslint parser so no new parser is needed.

I added tests that mirror the same functionality already included for TypeScript. The Flow type cast nodes appear to behave very similarly to the TypeScript ones.

I've also tested the changes on some Flow codebases inside Stripe; the changes fixed the Unsupported Callee errors and didn't seem to introduce any other problems.

Let me know if there's anything I need to fix or improve! Thanks for maintaining the project.

tylerkrupicka-stripe commented 3 years ago

Hmm, it doesn't look like travis ran on this PR. If there's anything I need to do to fix that let me know.

mozfreddyb commented 3 years ago

Travis is broken/disabled and I have yet to switch to CircleCI. :grimacing: Thanks for the PRs! I'll reserve a bit of review time for the end of the week to get back to the CI issue (and these pull requests).

mozfreddyb commented 3 years ago

Waiting for #158

tylerkrupicka-stripe commented 3 years ago

@mozfreddyb Thanks for the review, I figured out what cases would be missed by the ignore and I think I have addressed them. I've also significantly expanded the tests for this change, and ran it on our flow codebase to make sure the syntax errors didn't reappear.

Let me know if you see anything else I need to fix! Thanks again.