diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_blank_target.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_blank_target.rs index d9283472c67e..030a14ada9f7 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_blank_target.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_blank_target.rs @@ -30,9 +30,15 @@ declare_rule! { /// ```jsx,expect_diagnostic /// child /// ``` + /// /// ```jsx,expect_diagnostic /// child /// ``` + /// + /// ```jsx,expect_diagnostic + /// child + /// ``` + /// /// ```jsx,expect_diagnostic /// // case-insensitive /// child @@ -40,7 +46,8 @@ declare_rule! { /// ### Valid /// /// ```jsx - /// child + /// let a = child; + /// let a = child; /// ``` pub(crate) UseBlankTarget { version: "10.0.0", diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_key_with_click_events.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_key_with_click_events.rs index 3954cf6ea916..6a50f7782abf 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_key_with_click_events.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_key_with_click_events.rs @@ -40,6 +40,10 @@ declare_rule! { /// // this rule doesn't apply to user created component /// {}} /> ///``` + /// + /// ```jsx, + ///
{}} {...spread}>
+ /// ``` pub(crate) UseKeyWithClickEvents { version: "10.0.0", name: "useKeyWithClickEvents", diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_valid_anchor.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_valid_anchor.rs index 8cd3fafe8642..3ece30e1dc16 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_valid_anchor.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_valid_anchor.rs @@ -235,15 +235,10 @@ impl Rule for UseValidAnchor { (None, Some(on_click_attribute)) => Some(UseValidAnchorState::CantBeAnchor( on_click_attribute.syntax().text_trimmed_range(), )), - (None, None) => { - if !node.has_spread_attribute()? { - Some(UseValidAnchorState::MissingHrefAttribute( - node.syntax().text_trimmed_range(), - )) - } else { - None - } - } + (None, None) if !node.has_spread_attribute()? => Some( + UseValidAnchorState::MissingHrefAttribute(node.syntax().text_trimmed_range()), + ), + _ => None, } } diff --git a/website/src/docs/lint/rules/useBlankTarget.md b/website/src/docs/lint/rules/useBlankTarget.md index 146b1fd1322a..573c14c7aea8 100644 --- a/website/src/docs/lint/rules/useBlankTarget.md +++ b/website/src/docs/lint/rules/useBlankTarget.md @@ -58,6 +58,26 @@ and the [the noopener documentation](https://html.spec.whatwg.org/multipage/link +++++++++++ {% endraw %} +```jsx +child +``` + +{% raw %}
nursery/useBlankTarget.js:1:43 lint/nursery/useBlankTarget  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+   Avoid using target="_blank" without rel="noreferrer".
+  
+  > 1 │ <a {...props} href='http://external.link' target='_blank' rel="noopener">child</a>
+                                             ^^^^^^^^^^^^^^^
+    2 │ 
+  
+   Opening external links in new tabs without rel="noreferrer" is a security risk. See the explanation for more details.
+  
+   Safe fix: Add the "noreferrer" to the existing attribute.
+  
+    1 │ <a·{...props}·href='http://external.link'·target='_blank'·rel="noreferrer·noopener">child</a>
+                                                                 +++++++++++                   
+
{% endraw %} + ```jsx // case-insensitive child @@ -83,6 +103,7 @@ and the [the noopener documentation](https://html.spec.whatwg.org/multipage/link ### Valid ```jsx -child +let a = child; +let a = child; ``` diff --git a/website/src/docs/lint/rules/useKeyWithClickEvents.md b/website/src/docs/lint/rules/useKeyWithClickEvents.md index 1917777c5e46..dc8b5e70a789 100644 --- a/website/src/docs/lint/rules/useKeyWithClickEvents.md +++ b/website/src/docs/lint/rules/useKeyWithClickEvents.md @@ -78,3 +78,7 @@ Enforce to have the `onClick` mouse event with the `onKeyUp`, the `onKeyDown`, o {}} /> ``` +```jsx +
{}} {...spread}>
+``` +