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
Allow custom components in jsx-no-target-blank #2116
Allow custom components in jsx-no-target-blank #2116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good, but maybe we should add something to the overall settings so that all rules that care about links can use the same list. https://github.com/yannickcr/eslint-plugin-react#configuration
@ljharb I'm not too familiar with all the specific rules. A quick search for |
I think the current schema for the components array would work fine as a plugin-level setting; we can enhance it in the future as needed. |
I've updated the settings as I think you intend. Please let me know if you need any further changes. |
Is there anything else I can do to this PR? |
1bc4d66
to
da8c6b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice new feature! I just recommended a few documentation changes below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is this?
The following PR allows for customising additional components used jsx-no-target-blank.
Closes #1075
Why do this
It's reasonable common for projects to implement
<Link>
or<Hyperlink>
components and use them literally instead of<a>
elements.How does it work
From the docs
components
An array specifying the names of additional components that should also be validated.
Each array element can either be a string with the component name or object specifying the name and url attribute:
When using an object like so:
The following patterns are considered errors:
The following patterns are not considered errors:
When you use a string such as
'Link'
, it's equivalent to: