rubocop / rubocop-capybara

Code style checking for Capybara files.
https://docs.rubocop.org/rubocop-capybara
MIT License
38 stars 7 forks source link

Cop idea: `first(...)` instead of `all(...)[0]` #115

Closed ydah closed 1 month ago

ydah commented 3 months ago

https://www.rubydoc.info/gems/capybara/Capybara%2FNode%2FFinders:first

# bad
all('td')[0]

# good
first('td')
boris-petrov commented 1 month ago

I just came to open an issue about that. :smile:

By the way, another case that could be replaced with first is find(..., match: :first). @ydah do you want me to open a new issue about that or you'll handle it here?

ydah commented 1 month ago

@boris-petrov Supported by https://github.com/rubocop/rubocop-capybara/pull/118 . If this is not a problem, I will merge it.

boris-petrov commented 1 month ago

Seems great! Thanks for the quick implementation as usual! :)