From f49b3e20880adf02b6d778674a75bca3c85e3572 Mon Sep 17 00:00:00 2001 From: DonIsaac <22823424+DonIsaac@users.noreply.github.com> Date: Fri, 25 Oct 2024 01:43:55 +0000 Subject: [PATCH] fix(linter): `react/iframe-missing-sandbox` ignores vanilla JS APIs (#6872) > Closes #6750 Fixes a false positive in `react/iframe-missing-sandbox` on `document.createElement`, which is not react and has no way of passing a sandbox prop/attribute on creation. --- .../src/rules/react/iframe_missing_sandbox.rs | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs b/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs index 0fcd3f430..7d46bfca5 100644 --- a/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs +++ b/crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs @@ -8,6 +8,7 @@ use oxc_macros::declare_oxc_lint; use oxc_span::Span; use phf::{phf_set, Set}; +use crate::ast_util::is_method_call; use crate::utils::{get_prop_value, has_jsx_prop_ignore_case, is_create_element_call}; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -57,12 +58,19 @@ declare_oxc_lint!( /// /// ### Why is this bad? /// - /// The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using sandbox attribute is considered a good security practice. - /// To learn more about sandboxing, see [MDN's documentation on the `sandbox` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox). - + /// The sandbox attribute enables an extra set of restrictions for the + /// content in the iframe. Using sandbox attribute is considered a good + /// security practice. To learn more about sandboxing, see [MDN's + /// documentation on the `sandbox` + /// attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox). + /// + /// This rule checks all React `