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

jsx-no-target-blank to check for forms with target="_blank" #1617

Merged
merged 1 commit into from Aug 11, 2021

Conversation

jaaberg
Copy link
Contributor

@jaaberg jaaberg commented Dec 17, 2017

This should fix #1143.

I am not sure if this should be an option or not (as suggested in the issue)(?).

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.

Yes, let’s please put this behind an option, such that “a” and “form” can be separately controlled, but “a” defaults to being checked and “form” does not. That way, it’ll be semver-minor instead of semver-major.

@ljharb ljharb added the bug label Dec 17, 2017
@jaaberg
Copy link
Contributor Author

jaaberg commented Dec 18, 2017

Added option preventInForms to opt-in to validating target-blank in forms with tests and docs.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2017

@jaaberg what about a schema like this:

{
  "forms": <boolean>, // default false
  "links": <boolean>, // default true
}

That way it's an easy change to flip the default from false to true in the next semver-major, and the schema is also extensible if we want to add other categories in the future?

@jaaberg
Copy link
Contributor Author

jaaberg commented Dec 19, 2017

@ljharb Thanks for feedback :) Updated the PR.

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.

LGTM, thanks!

}, context.options[0]);

if (
(config.links ? node.parent.name.name !== 'a' : true) &&
Copy link
Member

Choose a reason for hiding this comment

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

!config.links || node.parent.name.name !== 'a'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was thinking about it, do you think it is more readable?

Copy link
Member

@ljharb ljharb Dec 19, 2017

Choose a reason for hiding this comment

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

hm, i'm not really sure. i'm not a fan of ternaries that select booleans, but as-is might be more readable in this case.

Copy link
Collaborator

@EvHaus EvHaus left a comment

Choose a reason for hiding this comment

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

LGTM. Great test coverage on this MR.

@ljharb
Copy link
Member

ljharb commented May 25, 2019

Rebased, and added a global formComponents setting to go with the linkComponents setting that was added after this PR was created.

@ljharb
Copy link
Member

ljharb commented Aug 9, 2021

@jaaberg i think this can land if it's rebased on top of the newly added allowReferrer and warnOnSpreadAttributes options.

@ljharb ljharb marked this pull request as draft August 9, 2021 21:24
@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2021

Codecov Report

Merging #1617 (2705431) into master (30ae98b) will decrease coverage by 0.12%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1617      +/-   ##
==========================================
- Coverage   97.49%   97.37%   -0.13%     
==========================================
  Files         111      111              
  Lines        7396     7423      +27     
  Branches     2700     2714      +14     
==========================================
+ Hits         7211     7228      +17     
- Misses        185      195      +10     
Impacted Files Coverage Δ
lib/rules/jsx-no-target-blank.js 87.61% <82.00%> (-7.19%) ⬇️
lib/util/linkComponents.js 95.23% <90.00%> (-4.77%) ⬇️

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 30ae98b...2705431. Read the comment docs.

@jaaberg jaaberg force-pushed the target-blank-form branch 2 times, most recently from 7f9cf10 to 2705431 Compare August 10, 2021 13:27
@jaaberg jaaberg marked this pull request as ready for review August 10, 2021 13:32
@ljharb ljharb merged commit 49e4bb6 into jsx-eslint:master Aug 11, 2021
@jaaberg jaaberg deleted the target-blank-form branch August 11, 2021 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Add or modify rule for no target="_blank" to include form elements
4 participants