refactor(linter): improve docs for react/jsx_no_target_blank rule (#5342)

This commit is contained in:
overlookmotel 2024-08-30 14:00:43 +01:00 committed by GitHub
parent 05636b7725
commit 89f018889d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,15 +91,15 @@ impl JsxNoTargetBlank {
declare_oxc_lint!( declare_oxc_lint!(
/// ### What it does /// ### What it does
/// This rule aims to prevent user generated link hrefs and form actions from creating security vulnerabilities by /// This rule aims to prevent user generated link hrefs and form actions from creating security vulnerabilities by
/// requiring rel='noreferrer' for external link hrefs and form actions, and optionally any dynamically generated link /// requiring `rel='noreferrer'` for external link hrefs and form actions, and optionally any dynamically generated
/// hrefs and form actions. /// link hrefs and form actions.
/// ///
/// ### Why is this bad? /// ### Why is this bad?
/// ///
/// When creating a JSX element that has an a tag, it is often desired to have the link open in a new tab using the /// When creating a JSX element that has an `a` tag, it is often desired to have the link open in a new tab using the
/// target='_blank' attribute. Using this attribute unaccompanied by rel='noreferrer', however, is a severe security /// `target='_blank'` attribute. Using this attribute unaccompanied by `rel='noreferrer'`, however, is a severe security
/// vulnerability (see noreferrer docs and noopener docs for more details) This rules requires that you accompany /// vulnerability (see [`noreferrer` docs] and [`noopener` docs] for more details).
/// target='_blank' attributes with rel='noreferrer'. /// This rules requires that you accompany `target='_blank'` attributes with `rel='noreferrer'`.
/// ///
/// ### Example /// ### Example
/// ```jsx /// ```jsx
@ -114,6 +114,9 @@ declare_oxc_lint!(
/// var Hello = <a target='_blank' href="https://example.com/"></a> /// var Hello = <a target='_blank' href="https://example.com/"></a>
/// var Hello = <a target='_blank' href={dynamicLink}></a> /// var Hello = <a target='_blank' href={dynamicLink}></a>
/// ``` /// ```
///
/// [`noreferrer` docs]: https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
/// [`noopener` docs]: https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
JsxNoTargetBlank, JsxNoTargetBlank,
correctness correctness
); );