Skip to content

Commit eb9b528

Browse files
committed
🆙 update: tweak line error messages
1 parent b2b9dac commit eb9b528

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

lib/rules/no-html-messages.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function create (context) {
7474
const foundNode = findHTMLNode(htmlNode)
7575
if (!foundNode) { return }
7676
context.report({
77-
message: `used HTML localization message in '${targetLocaleMessage.path}'`,
77+
message: `used HTML localization message`,
7878
loc: {
7979
line: messageNode.loc.start.line,
8080
column: messageNode.loc.start.column + foundNode.sourceCodeLocation.startOffset

lib/rules/no-unused-keys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function create (context) {
117117
traverseJsonAstWithUnusedKeys(unusedKeys, ast, (fullpath, node) => {
118118
const { line, column } = node.loc.start
119119
context.report({
120-
message: `unused '${fullpath}' key in '${targetLocaleMessage.path}'`,
120+
message: `unused '${fullpath}' key'`,
121121
loc: { line, column }
122122
})
123123
})

lib/utils/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function findMissingsFromLocaleMessages (localeMessages, key) {
6464
const value = last[paths[i]]
6565
if (value === undefined) {
6666
missings.push({
67-
message: `'${key}' does not exist in '${localeMessage.path}'`
67+
message: `'${key}' does not exist`
6868
})
6969
}
7070
last = value

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const RuleTester = require('eslint').RuleTester
77
const rule = require('../../../lib/rules/no-missing-keys')
88

99
const baseDir = './tests/fixtures/no-missing-keys/locales'
10-
const resolve = file => `${baseDir}/${file}`
1110

1211
const settings = {
1312
'vue-i18n': {
@@ -68,8 +67,8 @@ tester.run('no-missing-keys', rule, {
6867
settings,
6968
code: `$t('missing')`,
7069
errors: [
71-
`'missing' does not exist in '${resolve('en.json')}'`,
72-
`'missing' does not exist in '${resolve('ja.json')}'`
70+
`'missing' does not exist`,
71+
`'missing' does not exist`
7372
]
7473
}, {
7574
// using mustaches in template block
@@ -78,8 +77,8 @@ tester.run('no-missing-keys', rule, {
7877
<p>{{ $t('missing') }}</p>
7978
</template>`,
8079
errors: [
81-
`'missing' does not exist in '${resolve('en.json')}'`,
82-
`'missing' does not exist in '${resolve('ja.json')}'`
80+
`'missing' does not exist`,
81+
`'missing' does not exist`
8382
]
8483
}, {
8584
// using custom directive in template block
@@ -88,8 +87,8 @@ tester.run('no-missing-keys', rule, {
8887
<p v-t="'missing'"></p>
8988
</template>`,
9089
errors: [
91-
`'missing' does not exist in '${resolve('en.json')}'`,
92-
`'missing' does not exist in '${resolve('ja.json')}'`
90+
`'missing' does not exist`,
91+
`'missing' does not exist`
9392
]
9493
}, {
9594
// using <i18n> functional component in template block
@@ -100,8 +99,8 @@ tester.run('no-missing-keys', rule, {
10099
</div>
101100
</template>`,
102101
errors: [
103-
`'missing' does not exist in '${resolve('en.json')}'`,
104-
`'missing' does not exist in '${resolve('ja.json')}'`
102+
`'missing' does not exist`,
103+
`'missing' does not exist`
105104
]
106105
}, {
107106
// settings.vue-i18n.localeDir' error

0 commit comments

Comments
 (0)