@intlify/vue-i18n/no-missing-keys
disallow missing locale message key at localization methods
- ⭐ The
"extends": "plugin:@intlify/vue-i18n/recommended"
or*.configs["flat/recommended"]
property in a configuration file enables this rule.
This rule warns locale message key missing if the key does not exist in locale messages.
📖 Rule Details
You can be detected with this rule the following:
$t
t
$tc
tc
v-t
<i18n>
👎 Examples of incorrect code for this rule:
locale messages:
json
{
"hello": "Hello! DIO!"
}
localization codes:
vue
<script>
/* eslint @intlify/vue-i18n/no-missing-keys: 'error' */
</script>
<template>
<div class="app">
<!-- ✗ BAD -->
<p>{{ $t('hi') }}</p>
<!-- ✗ BAD -->
<p v-t="'hi'"></p>
<!-- ✗ BAD -->
<i18n path="hi" tag="p"></i18n>
</div>
</template>
js
/* eslint @intlify/vue-i18n/no-missing-keys: 'error' */
import VueI18n from 'vue-i18n'
import en from './locales/en.json'
const i18n = new VueI18n({
locale: 'en',
messages: {
en
}
})
/* ✗ BAD */
i18n.t('hi')
👍 Examples of correct code for this rule:
locale messages:
json
{
"hello": "Hello! DIO!"
}
localization codes:
vue
<script>
/* eslint @intlify/vue-i18n/no-missing-keys: 'error' */
</script>
<template>
<div class="app">
<!-- ✓ GOOD -->
<p>{{ $t('hello') }}</p>
<!-- ✓ GOOD -->
<p v-t="'hello'"></p>
<!-- ✓ GOOD -->
<i18n path="hello" tag="p"></i18n>
</div>
</template>
js
/* eslint @intlify/vue-i18n/no-missing-keys: 'error' */
import VueI18n from 'vue-i18n'
import en from './locales/en.json'
const i18n = new VueI18n({
locale: 'en',
messages: {
en
}
})
/* ✓ GOOD */
i18n.t('hello')
For SFC.
vue
<script>
/* eslint @intlify/vue-i18n/no-missing-keys: 'error' */
</script>
<i18n>
{
"en": {
"hi": "Hi! DIO!"
}
}
</i18n>
<template>
<div class="app">
<!-- ✓ GOOD -->
<p>{{ $t('hi') }}</p>
</div>
</template>
👫 Related Rules
🚀 Version
This rule was introduced in @intlify/eslint-plugin-vue-i18n
v0.1.0