Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] jsx-no-target-blank: Improve readme #3169

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [readme] change [`jsx-runtime`] link from branch to sha ([#3160][] @tatsushitoji)
* [Docs] HTTP => HTTPS ([#3133][] @Schweinepriester)
* [readme] Some grammar fixes ([#3186][] @JJ)
* [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper)

[#3186]: https://github.com/yannickcr/eslint-plugin-react/pull/3186
[#3174]: https://github.com/yannickcr/eslint-plugin-react/pull/3174
[#3169]: https://github.com/yannickcr/eslint-plugin-react/pull/3169
[#3167]: https://github.com/yannickcr/eslint-plugin-react/pull/3167
[#3163]: https://github.com/yannickcr/eslint-plugin-react/pull/3163
[#3160]: https://github.com/yannickcr/eslint-plugin-react/pull/3160
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/jsx-no-target-blank.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ This rule supports the ability to use custom components for forms. To enable thi

## When To Override It

Modern browsers (Chrome ≥ 88, Edge ≥ 88, Firefox ≥ 79 and Safari ≥ 12.2) automatically imply `rel="noopener"`. Therefore this rule is no longer needed, if legacy browsers are not supported. See https://web.dev/external-anchors-use-rel-noopener/ and https://caniuse.com/mdn-html_elements_a_implicit_noopener for more details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this interact with the browser support paragraph on line 130?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least to my knowledge there are three stages regarding empty ref:

  • legacy: noreferrer is needed (e.g. because of IE11). noopener is not good enough.
  • in-between: In non IE11 browsers noopener is good enough (e.g. with Chrome 49 and newer)
  • modern: In modern browser there is no need to specify noopener because it is automatically implied (e.g. with Chrome 88).

So basically: If you still support IE11 use the default of this eslint-rule. If you're not supporting IE11 but old versions of chrome or safari use the allowReferrer rule. If you're using modern browsers you don't need this rule at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, i see, thanks.


For links to a trusted host (e.g. internal links to your own site, or links to a another host you control, where you can be certain this security vulnerability does not exist), you may want to keep the HTTP Referer header for analytics purposes.

If you do not support Internet Explorer (any version), Chrome < 49, Opera < 36, Firefox < 52, desktop Safari < 10.1 or iOS Safari < 10.3, you may set `allowReferrer` to `true`, keep the HTTP Referer header and only add `rel="noopener"` to your links.
Expand Down