|
| 1 | +# @intlify/vue-i18n/key-format-style |
| 2 | + |
| 3 | +> enforce specific casing for localization keys |
| 4 | +
|
| 5 | +This rule aims to enforces specific casing for localization key names. |
| 6 | + |
| 7 | +```yaml |
| 8 | +camelCaseKey: The key for this value is camel case. |
| 9 | +kebab-case-key: The key for this value is kebab case. |
| 10 | +snake_case_key: The key for this value is snake case. |
| 11 | +mixed_Case-key: Perhaps you don't want to use this casing. |
| 12 | +``` |
| 13 | +
|
| 14 | +## :book: Rule Details |
| 15 | +
|
| 16 | +This rule reports localization keys other than the specific casing. |
| 17 | +Also, the following localization key definitions are reported as errors, because the casing cannot determine. |
| 18 | +
|
| 19 | +:-1: Examples of **incorrect** code for this rule: |
| 20 | +
|
| 21 | +```yaml |
| 22 | +# ✗ BAD: Use array elements. |
| 23 | +- message1 |
| 24 | +- message2 |
| 25 | +- message3 |
| 26 | +... |
| 27 | +# ✗ BAD: Use object for key. |
| 28 | +{foo: bar}: message |
| 29 | +[1,2,3]: message |
| 30 | +``` |
| 31 | +
|
| 32 | +## Options |
| 33 | +
|
| 34 | +```json |
| 35 | +{ |
| 36 | + "@intlify/vue-i18n/key-format-style": ["error", |
| 37 | + "camelCase" | "kebab-case" | "snake_case", |
| 38 | + { |
| 39 | + "allowArray": false |
| 40 | + } |
| 41 | + ] |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +- Primary Option: Select the casing you want to apply. It set to `"camelCase"` as default |
| 46 | +- `allowArray`: If `true`, allow the use of arrays. If `false`, disallow the use of arrays. It set to `false` as default. |
| 47 | + |
| 48 | +:+1: Examples of **correct** code for this rule with `"camelCase"`: |
| 49 | + |
| 50 | +```yaml |
| 51 | +# ✓ GOOD |
| 52 | +appTitle: I18N Management System |
| 53 | +``` |
| 54 | +
|
| 55 | +:-1: Examples of **incorrect** code for this rule with `"camelCase"`: |
| 56 | +
|
| 57 | +```yaml |
| 58 | +# ✗ BAD |
| 59 | +app-title: I18N Management System |
| 60 | +app_title: I18N Management System |
| 61 | +``` |
| 62 | +
|
| 63 | +:+1: Examples of **correct** code for this rule with `"kebab-case"`: |
| 64 | +
|
| 65 | +```yaml |
| 66 | +# ✓ GOOD |
| 67 | +app-title: I18N Management System |
| 68 | +``` |
| 69 | +
|
| 70 | +:-1: Examples of **incorrect** code for this rule with `"kebab-case"`: |
| 71 | +
|
| 72 | +```yaml |
| 73 | +# ✗ BAD |
| 74 | +appTitle: I18N Management System |
| 75 | +app_title: I18N Management System |
| 76 | +``` |
| 77 | +
|
| 78 | +:+1: Examples of **correct** code for this rule with `"snake_case"`: |
| 79 | +
|
| 80 | +```yaml |
| 81 | +# ✓ GOOD |
| 82 | +app_title: I18N Management System |
| 83 | +``` |
| 84 | +
|
| 85 | +:-1: Examples of **incorrect** code for this rule with `"snake_case"`: |
| 86 | +
|
| 87 | +```yaml |
| 88 | +# ✗ BAD |
| 89 | +appTitle: I18N Management System |
| 90 | +app-title: I18N Management System |
| 91 | +``` |
| 92 | +
|
| 93 | +:+1: Examples of **correct** code for this rule with `{"allowArray": true}`: |
| 94 | + |
| 95 | +```yaml |
| 96 | +# ✓ GOOD |
| 97 | +- message1 |
| 98 | +- message2 |
| 99 | +- message3 |
| 100 | +``` |
0 commit comments