Skip to content

Commit ed02d94

Browse files
williamchongkazupon
authored andcommitted
🐛 bug(no-missing-keys): fix plugin crashes on missing nested path (#7) by @williamchong007
1 parent 4ee8ff2 commit ed02d94

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/utils/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function findMissingsFromLocaleMessages (localeMessages, key) {
6161
let last = localeMessage.messages
6262
let i = 0
6363
while (i < length) {
64-
const value = last[paths[i]]
64+
const value = last && last[paths[i]]
6565
if (value === undefined) {
6666
missings.push({
6767
message: `'${key}' does not exist`

tests/lib/rules/no-missing-keys.js

+10
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,15 @@ tester.run('no-missing-keys', rule, {
108108
errors: [
109109
`You need to 'localeDir' at 'settings. See the 'eslint-plugin-vue-i18n documentation`
110110
]
111+
}, {
112+
// nested basic
113+
settings,
114+
code: `$t('missing.path')`,
115+
errors: [
116+
`'missing.path' does not exist`,
117+
`'missing.path' does not exist`,
118+
`'missing.path' does not exist`,
119+
`'missing.path' does not exist`
120+
]
111121
}]
112122
})

0 commit comments

Comments
 (0)