Shopify / rubocop-sorbet

A collection of RuboCop rules for Sorbet
MIT License
178 stars 26 forks source link

Cop suggestion: Sorbet/StructPropName for T::Struct properties #237

Open marknuzz opened 2 months ago

marknuzz commented 2 months ago

It would be great to have a cop that works like Naming/MethodName, but for T::Struct props

Personally I only plan to use snake_case for this right now, but for completeness the cop could support the same options as Naming/MethodName.

Naming/MethodName source: https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cop/naming/method_name.rb

Example:

class Foo < T::Struct
  const :fooConst, String # bad
  const :foo_const, String # good

  prop :fooProp, T::Boolean # bad
  prop :foo_prop, T::Boolean # good
end
KaanOzkan commented 2 months ago

This isn't a priority for us because internally we utilize ForbidTStruct cop and have moved away from T::Struct usages however, contributions are welcome and we will merge it if it's implemented 🙂