|
| 1 | +--- |
| 2 | +title: '@intlify/vue-i18n/no-deprecated-i18n-places-prop' |
| 3 | +description: disallow using deprecated `places` prop (Removed in Vue I18n 9.0.0+) |
| 4 | +--- |
| 5 | + |
| 6 | +# @intlify/vue-i18n/no-deprecated-i18n-places-prop |
| 7 | + |
| 8 | +> disallow using deprecated `places` prop (Removed in Vue I18n 9.0.0+) |
| 9 | +
|
| 10 | +If you are migrating from Vue I18n v8 to v9, the `places` prop should be replaced with the `v-slot`. |
| 11 | + |
| 12 | +## :book: Rule Details |
| 13 | + |
| 14 | +This rule reports use of deprecated `places` prop (Removed in Vue I18n 9.0.0+). |
| 15 | + |
| 16 | +:-1: Examples of **incorrect** code for this rule: |
| 17 | + |
| 18 | +<eslint-code-block> |
| 19 | + |
| 20 | +<!-- eslint-skip --> |
| 21 | + |
| 22 | +```vue |
| 23 | +<script> |
| 24 | +/* eslint @intlify/vue-i18n/no-deprecated-i18n-places-prop: 'error' */ |
| 25 | +</script> |
| 26 | +<template> |
| 27 | + <div class="app"> |
| 28 | + <!-- ✗ BAD --> |
| 29 | + <i18n path="info" tag="p" :places="{ limit: changeLimit }"> |
| 30 | + <a place="action" :href="changeUrl">{{ $t('change') }}</a> |
| 31 | + </i18n> |
| 32 | +
|
| 33 | + <!-- Also check the <i18n-t> component to prevent mistakes. --> |
| 34 | + <!-- ✗ BAD --> |
| 35 | + <i18n-t path="info" tag="p" :places="{ limit: changeLimit }"> |
| 36 | + <a place="action" :href="changeUrl">{{ $t('change') }}</a> |
| 37 | + </i18n-t> |
| 38 | + </div> |
| 39 | +</template> |
| 40 | +``` |
| 41 | + |
| 42 | +</eslint-code-block> |
| 43 | + |
| 44 | +:+1: Examples of **correct** code for this rule: |
| 45 | + |
| 46 | +<eslint-code-block> |
| 47 | + |
| 48 | +<!-- eslint-skip --> |
| 49 | + |
| 50 | +```vue |
| 51 | +<script> |
| 52 | +/* eslint @intlify/vue-i18n/no-deprecated-i18n-places-prop: 'error' */ |
| 53 | +</script> |
| 54 | +<template> |
| 55 | + <div class="app"> |
| 56 | + <!-- ✓ GOOD --> |
| 57 | + <i18n path="info" tag="p"> |
| 58 | + <template v-slot:limit> |
| 59 | + <span>{{ changeLimit }}</span> |
| 60 | + </template> |
| 61 | + <template v-slot:action> |
| 62 | + <a :href="changeUrl">{{ $t('change') }}</a> |
| 63 | + </template> |
| 64 | + </i18n> |
| 65 | +
|
| 66 | + <!-- ✓ GOOD --> |
| 67 | + <i18n-t keypath="info" tag="p"> |
| 68 | + <template #limit> |
| 69 | + <span>{{ changeLimit }}</span> |
| 70 | + </template> |
| 71 | + <template #action> |
| 72 | + <a :href="changeUrl">{{ $t('change') }}</a> |
| 73 | + </template> |
| 74 | + </i18n-t> |
| 75 | + </div> |
| 76 | +</template> |
| 77 | +``` |
| 78 | + |
| 79 | +</eslint-code-block> |
| 80 | + |
| 81 | +## :books: Further reading |
| 82 | + |
| 83 | +- [Vue I18n > Breaking Changes - Remove place syntax with `place` attr and `places` prop](https://vue-i18n.intlify.dev/guide/migration/breaking.html#remove-place-syntax-with-place-attr-and-places-prop) |
| 84 | +- [Vue I18n (v8) > Component interpolation - Places syntax usage](https://kazupon.github.io/vue-i18n/guide/interpolation.html#places-syntax-usage) |
| 85 | + |
| 86 | +## :mag: Implementation |
| 87 | + |
| 88 | +- [Rule source](https://github.com/intlify/eslint-plugin-vue-i18n/blob/master/lib/rules/no-deprecated-i18n-places-prop.ts) |
| 89 | +- [Test source](https://github.com/intlify/eslint-plugin-vue-i18n/tree/master/tests/lib/rules/no-deprecated-i18n-places-prop.ts) |
0 commit comments