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

Let Rails/LinkToBlank also catch cases where link_to_if++ is used #1288

Closed
fwolfst opened this issue May 30, 2024 · 0 comments · Fixed by #1289
Closed

Let Rails/LinkToBlank also catch cases where link_to_if++ is used #1288

fwolfst opened this issue May 30, 2024 · 0 comments · Fixed by #1289
Labels
enhancement New feature or request

Comments

@fwolfst
Copy link
Contributor

fwolfst commented May 30, 2024

Is your feature request related to a problem?

While the cop catches instances where link_to is used, it doesnt catch its sister implementations link_to_if and link_to_unless.

# Bad
link_to_if config.url.present?, config.url, config.url, target: '_blank'

# Good
link_to_if config.url.present?, config.url, config.url, target: '_blank', rel: 'noopener noreferrer'

Describe the solution you'd like

The same cop should catch link_to_ifs and link_to_unlesss matching the conditions

Describe alternatives you've considered

Implementing a separate cop of a configuration value for the given cop.

Additional context

There is also link_to_unless_current which might be more difficult to implement a check against.

https://www.rubydoc.info/gems/rubocop-rails/RuboCop/Cop/Rails/LinkToBlank
https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants