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 error messages #3088

Merged

Conversation

cutiful
Copy link
Contributor

@cutiful cutiful commented Sep 29, 2021

The current error message is confusing because it complains about links missing rel="noreferrer" even if allowReferrer is set to true and so rel="noopener" is enough to satisfy it. I made it report different messages depending on allowReferrer value and state that even if rel="noopener" is enough, rel="noreferrer" is preferred as per #3044 (comment). Also clarified the docs for allowReferrer to prevent misunderstandings like #3044.

Show different error messages depending on whether referrer is allowed; clarify about `noreferrer` only being necessary in older browsers.

Closes jsx-eslint#3044.
@cutiful
Copy link
Contributor Author

cutiful commented Sep 29, 2021

Not fully sure about the phrasing of noTargetBlankWithoutNoreferrer, it may sound like the rule can be safely disabled if you don't support older browsers. On the other hand, it is soon going to be true, as in newer browsers, rel="noopener" is implied with target="_blank"; and either way the link (taken from the MDN article) explains the details.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Thanks, seems like an improvement

@ljharb ljharb force-pushed the better-jsx-no-target-blank-reporting branch from 965634d to 7844d8e Compare September 30, 2021 05:20
@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2021

Codecov Report

Merging #3088 (7844d8e) into master (8785c16) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3088   +/-   ##
=======================================
  Coverage   97.55%   97.55%           
=======================================
  Files         115      115           
  Lines        7729     7731    +2     
  Branches     2764     2766    +2     
=======================================
+ Hits         7540     7542    +2     
  Misses        189      189           
Impacted Files Coverage Δ
lib/rules/jsx-no-target-blank.js 88.79% <100.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8785c16...7844d8e. Read the comment docs.

@ljharb ljharb changed the title Better jsx-no-target-blank reporting and improved docs [Fix] jsx-no-target-blank: improve error messages Sep 30, 2021
@ljharb ljharb merged commit 7844d8e into jsx-eslint:master Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants