Skip to content

Commit

Permalink
add eslint-plugin-vue-i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Oct 26, 2021
1 parent 8fc0f4f commit e1ee532
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 13 deletions.
28 changes: 26 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ module.exports = {
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@intlify/vue-i18n/recommended',
'plugin:prettier/recommended',
'prettier'
],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module'
},
overrides: [
{
files: ['*.json', '*.json5'],
extends: ['plugin:@intlify/vue-i18n/base']
},
{
files: ['*.yaml', '*.yml'],
extends: ['plugin:@intlify/vue-i18n/base']
}
],
rules: {
'object-curly-spacing': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
Expand All @@ -26,6 +37,19 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/triple-slash-reference': 'off'
'@typescript-eslint/triple-slash-reference': 'off',
'@intlify/vue-i18n/no-dynamic-keys': 'error',
'@intlify/vue-i18n/no-unused-keys': [
'error',
{
extensions: ['.ts']
}
]
},
settings: {
'vue-i18n': {
localeDir: './locales/*.json',
messageSyntaxVersion: '^9.0.0'
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"yargs": "^17.2.0"
},
"devDependencies": {
"@intlify/eslint-plugin-vue-i18n": "^0.15.0",
"@kazupon/lerna-changelog": "^4.3.0",
"@microsoft/api-extractor": "^7.18.2",
"@secretlint/secretlint-rule-preset-recommend": "^3.3.0",
Expand Down
119 changes: 111 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { compile, annotate, format } from './commands'
await initI18n()
yargs(hideBin(process.argv))
.scriptName('intlify')
.usage(t('Usage: $0 <command> [options]'))
.usage(t('Usage: $0 <command> [options]')) // eslint-disable-line @intlify/vue-i18n/no-missing-keys
.command(compile())
.command(annotate())
.command(format())
Expand Down
2 changes: 1 addition & 1 deletion src/commands/annotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default function defineCommand() {
e.erorrs.forEach(err => console.error(chalk.red(` ${err.message}`)))
} else if (e instanceof SFCAnnotateError) {
console.error(
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any, @intlify/vue-i18n/no-dynamic-keys
)
} else {
console.error(chalk.red((e as Error).message))
Expand Down
2 changes: 1 addition & 1 deletion src/commands/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function defineCommand() {
errorCounter++
if (e instanceof FormatLangNotFoundError) {
console.error(
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any
chalk.red(`${e.filepath}: ${t(e.message as any)}`) // eslint-disable-line @typescript-eslint/no-explicit-any, @intlify/vue-i18n/no-dynamic-keys
)
} else if (isSFCParserError(e)) {
console.error(chalk.red(`${e.message} at ${e.filepath}`))
Expand Down

0 comments on commit e1ee532

Please sign in to comment.