Skip to content

Commit e1ee532

Browse files
committed
add eslint-plugin-vue-i18n
1 parent 8fc0f4f commit e1ee532

File tree

6 files changed

+141
-13
lines changed

6 files changed

+141
-13
lines changed

.eslintrc.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ module.exports = {
1010
extends: [
1111
'plugin:@typescript-eslint/recommended',
1212
'plugin:@typescript-eslint/eslint-recommended',
13+
'plugin:@intlify/vue-i18n/recommended',
1314
'plugin:prettier/recommended',
1415
'prettier'
1516
],
1617
plugins: ['@typescript-eslint'],
17-
parser: '@typescript-eslint/parser',
1818
parserOptions: {
19+
parser: '@typescript-eslint/parser',
1920
sourceType: 'module'
2021
},
22+
overrides: [
23+
{
24+
files: ['*.json', '*.json5'],
25+
extends: ['plugin:@intlify/vue-i18n/base']
26+
},
27+
{
28+
files: ['*.yaml', '*.yml'],
29+
extends: ['plugin:@intlify/vue-i18n/base']
30+
}
31+
],
2132
rules: {
2233
'object-curly-spacing': 'off',
2334
'@typescript-eslint/explicit-function-return-type': 'off',
@@ -26,6 +37,19 @@ module.exports = {
2637
'@typescript-eslint/explicit-module-boundary-types': 'off',
2738
'@typescript-eslint/ban-ts-comment': 'off',
2839
'@typescript-eslint/no-non-null-assertion': 'off',
29-
'@typescript-eslint/triple-slash-reference': 'off'
40+
'@typescript-eslint/triple-slash-reference': 'off',
41+
'@intlify/vue-i18n/no-dynamic-keys': 'error',
42+
'@intlify/vue-i18n/no-unused-keys': [
43+
'error',
44+
{
45+
extensions: ['.ts']
46+
}
47+
]
48+
},
49+
settings: {
50+
'vue-i18n': {
51+
localeDir: './locales/*.json',
52+
messageSyntaxVersion: '^9.0.0'
53+
}
3054
}
3155
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"yargs": "^17.2.0"
4545
},
4646
"devDependencies": {
47+
"@intlify/eslint-plugin-vue-i18n": "^0.15.0",
4748
"@kazupon/lerna-changelog": "^4.3.0",
4849
"@microsoft/api-extractor": "^7.18.2",
4950
"@secretlint/secretlint-rule-preset-recommend": "^3.3.0",

pnpm-lock.yaml

Lines changed: 111 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { compile, annotate, format } from './commands'
99
await initI18n()
1010
yargs(hideBin(process.argv))
1111
.scriptName('intlify')
12-
.usage(t('Usage: $0 <command> [options]'))
12+
.usage(t('Usage: $0 <command> [options]')) // eslint-disable-line @intlify/vue-i18n/no-missing-keys
1313
.command(compile())
1414
.command(annotate())
1515
.command(format())

src/commands/annotate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export default function defineCommand() {
173173
e.erorrs.forEach(err => console.error(chalk.red(` ${err.message}`)))
174174
} else if (e instanceof SFCAnnotateError) {
175175
console.error(
176-
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any
176+
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any, @intlify/vue-i18n/no-dynamic-keys
177177
)
178178
} else {
179179
console.error(chalk.red((e as Error).message))

src/commands/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default function defineCommand() {
9595
errorCounter++
9696
if (e instanceof FormatLangNotFoundError) {
9797
console.error(
98-
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any
98+
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any, @intlify/vue-i18n/no-dynamic-keys
9999
)
100100
} else if (isSFCParserError(e)) {
101101
console.error(chalk.red(`${e.message} at ${e.filepath}`))

0 commit comments

Comments
 (0)