|
| 1 | +Ensures magic comments are written consistently throughout your code base. |
| 2 | +Looks for discrepancies in separators (`-` vs `_`) and capitalization for |
| 3 | +both magic comment directives and values. |
| 4 | + |
| 5 | +Required capitalization can be set with the `DirectiveCapitalization` and |
| 6 | +`ValueCapitalization` configuration keys. |
| 7 | + |
| 8 | +NOTE: If one of these configuration is set to nil, any capitalization is allowed. |
| 9 | + |
| 10 | +### Example: EnforcedStyle: snake_case (default) |
| 11 | + # The `snake_case` style will enforce that the frozen string literal |
| 12 | + # comment is written in snake case. (Words separated by underscores) |
| 13 | + # bad |
| 14 | + # frozen-string-literal: true |
| 15 | + |
| 16 | + module Bar |
| 17 | + # ... |
| 18 | + end |
| 19 | + |
| 20 | + # good |
| 21 | + # frozen_string_literal: false |
| 22 | + |
| 23 | + module Bar |
| 24 | + # ... |
| 25 | + end |
| 26 | + |
| 27 | +### Example: EnforcedStyle: kebab_case |
| 28 | + # The `kebab_case` style will enforce that the frozen string literal |
| 29 | + # comment is written in kebab case. (Words separated by hyphens) |
| 30 | + # bad |
| 31 | + # frozen_string_literal: true |
| 32 | + |
| 33 | + module Baz |
| 34 | + # ... |
| 35 | + end |
| 36 | + |
| 37 | + # good |
| 38 | + # frozen-string-literal: true |
| 39 | + |
| 40 | + module Baz |
| 41 | + # ... |
| 42 | + end |
| 43 | + |
| 44 | +### Example: DirectiveCapitalization: lowercase (default) |
| 45 | + # bad |
| 46 | + # FROZEN-STRING-LITERAL: true |
| 47 | + |
| 48 | + # good |
| 49 | + # frozen-string-literal: true |
| 50 | + |
| 51 | +### Example: DirectiveCapitalization: uppercase |
| 52 | + # bad |
| 53 | + # frozen-string-literal: true |
| 54 | + |
| 55 | + # good |
| 56 | + # FROZEN-STRING-LITERAL: true |
| 57 | + |
| 58 | +### Example: DirectiveCapitalization: nil |
| 59 | + # any capitalization is accepted |
| 60 | + |
| 61 | + # good |
| 62 | + # frozen-string-literal: true |
| 63 | + |
| 64 | + # good |
| 65 | + # FROZEN-STRING-LITERAL: true |
| 66 | + |
| 67 | +### Example: ValueCapitalization: nil (default) |
| 68 | + # any capitalization is accepted |
| 69 | + |
| 70 | + # good |
| 71 | + # frozen-string-literal: true |
| 72 | + |
| 73 | + # good |
| 74 | + # frozen-string-literal: TRUE |
| 75 | + |
| 76 | +### Example: ValueCapitalization: lowercase |
| 77 | + # when a value is not given, any capitalization is accepted |
| 78 | + |
| 79 | + # bad |
| 80 | + # frozen-string-literal: TRUE |
| 81 | + |
| 82 | + # good |
| 83 | + # frozen-string-literal: TRUE |
| 84 | + |
| 85 | +### Example: ValueCapitalization: uppercase |
| 86 | + # bad |
| 87 | + # frozen-string-literal: true |
| 88 | + |
| 89 | + # good |
| 90 | + # frozen-string-literal: TRUE |
0 commit comments