Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
chore: code suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 21, 2022
1 parent 83cd5ee commit 8d05644
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@ declare_rule! {
/// ```jsx,expect_diagnostic
/// <a href='http://external.link' target='_blank'>child</a>
/// ```
///
/// ```jsx,expect_diagnostic
/// <a href='http://external.link' target='_blank' rel="noopener">child</a>
/// ```
///
/// ```jsx,expect_diagnostic
/// <a {...props} href='http://external.link' target='_blank' rel="noopener">child</a>
/// ```
///
/// ```jsx,expect_diagnostic
/// // case-insensitive
/// <a href='http://external.link' target='_BlaNk'>child</a>
/// ```
/// ### Valid
///
/// ```jsx
/// <a href='http://external.link' rel='noreferrer' target='_blank'>child</a>
/// let a = <a href='http://external.link' rel='noreferrer' target='_blank'>child</a>;
/// let a = <a href='http://external.link' target='_blank' rel="noopener" {...props}>child</a>;
/// ```
pub(crate) UseBlankTarget {
version: "10.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ declare_rule! {
/// // this rule doesn't apply to user created component
/// <MyComponent onClick={() => {}} />
///```
///
/// ```jsx,
/// <div onClick={() => {}} {...spread}></div>
/// ```
pub(crate) UseKeyWithClickEvents {
version: "10.0.0",
name: "useKeyWithClickEvents",
Expand Down
13 changes: 4 additions & 9 deletions crates/rome_js_analyze/src/analyzers/nursery/use_valid_anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
23 changes: 22 additions & 1 deletion website/src/docs/lint/rules/useBlankTarget.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions website/src/docs/lint/rules/useKeyWithClickEvents.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d05644

Please sign in to comment.