Skip to content

🐛 Fix plugin crashes on missing nested path #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function findMissingsFromLocaleMessages (localeMessages, key) {
let last = localeMessage.messages
let i = 0
while (i < length) {
const value = last[paths[i]]
const value = last && last[paths[i]]
if (value === undefined) {
missings.push({
message: `'${key}' does not exist`
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/rules/no-missing-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,15 @@ tester.run('no-missing-keys', rule, {
errors: [
`You need to 'localeDir' at 'settings. See the 'eslint-plugin-vue-i18n documentation`
]
}, {
// nested basic
settings,
code: `$t('missing.path')`,
errors: [
`'missing.path' does not exist`,
`'missing.path' does not exist`,
`'missing.path' does not exist`,
`'missing.path' does not exist`
]
}]
})