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

Add new cop Rails/LocaleAssignment #495

Closed
johnnyshields opened this issue May 23, 2021 · 0 comments · Fixed by #503
Closed

Add new cop Rails/LocaleAssignment #495

johnnyshields opened this issue May 23, 2021 · 0 comments · Fixed by #503
Labels
feature request Request for new functionality

Comments

@johnnyshields
Copy link

I propose to add a new cop Rails/LocaleAssignment which requires you to assign locale only in blocks. This would follow the same format Rails/TimeZoneAssignment.

# BAD
I18n.locale = :fr

# GOOD
I18n.with_locale(:fr) do
  # do something
end
@koic koic added the feature request Request for new functionality label May 28, 2021
koic added a commit to koic/rubocop-rails that referenced this issue Jun 7, 2021
koic added a commit to koic/rubocop-rails that referenced this issue Jun 7, 2021
Fixes rubocop#495

This PR adds new `Rails/I18nLocaleAssignment` cop.
It has a similar purpose to `Rails/TimeZoneAssignment` cop.
rubocop#458
koic added a commit to koic/rubocop-rails that referenced this issue Jun 8, 2021
Fixes rubocop#495

This PR adds new `Rails/I18nLocaleAssignment` cop.
It has a similar purpose to `Rails/TimeZoneAssignment` cop.
rubocop#458
@koic koic closed this as completed in #503 Jun 14, 2021
koic added a commit that referenced this issue Jun 14, 2021
…t_cop

[Fix #495] Add new `Rails/I18nLocaleAssignment` cop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants