Rule: erb-hash-shorthand-syntax
Description
Enforce a consistent style for Ruby's hash value omission (shorthand hash syntax, Ruby >= 3.1) inside ERB tags, most visibly in render calls with a locals: hash.
The rule should be configurable through an enforcedStyle option:
always (proposed default)
never
Examples
With enforcedStyle: "always":
✅ Good
<%= render partial: "users/featured_talk", locals: { featured: } %>
<%= render partial: "users/featured_talk", locals: { featured:, speaker: } %>
<%= render partial: "users/featured_talk", locals: { featured: @featured } %>
<%= render partial: "users/featured_talk", locals: { talk: featured } %>
🚫 Bad
<%= render partial: "users/featured_talk", locals: { featured: featured } %>
<%= render partial: "users/featured_talk", locals: { featured: featured, speaker: speaker } %>
With enforcedStyle: "never":
✅ Good
<%= render partial: "users/featured_talk", locals: { featured: featured } %>
<%= render partial: "users/featured_talk", locals: { featured: featured, speaker: speaker } %>
🚫 Bad
<%= render partial: "users/featured_talk", locals: { featured: } %>
<%= render partial: "users/featured_talk", locals: { featured:, speaker: } %>
Notes
Depends on #1204
References
Rule:
erb-hash-shorthand-syntaxDescription
Enforce a consistent style for Ruby's hash value omission (shorthand hash syntax, Ruby >= 3.1) inside ERB tags, most visibly in
rendercalls with alocals:hash.The rule should be configurable through an
enforcedStyleoption:always(proposed default)neverExamples
With
enforcedStyle: "always":✅ Good
🚫 Bad
With
enforcedStyle: "never":✅ Good
🚫 Bad
Notes
Depends on #1204
References
Style/HashSyntax(EnforcedShorthandSyntax)