-
Notifications
You must be signed in to change notification settings - Fork 70
i18n: detect unused keys #1411
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
base: master
Are you sure you want to change the base?
i18n: detect unused keys #1411
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,9 @@ module.exports = { | |
| 'plugin:vue/vue3-recommended', | ||
| '@vue/airbnb' | ||
| ], | ||
| plugins: [ | ||
| '@intlify/eslint-plugin-vue-i18n', | ||
| ], | ||
| globals: { | ||
| $: 'readonly', | ||
| alert: 'readonly', | ||
|
|
@@ -15,6 +18,29 @@ module.exports = { | |
| defineModel: 'readonly' | ||
| }, | ||
| rules: { | ||
| '@intlify/vue-i18n/no-unused-keys': [ 'error', { | ||
| src: 'src/', | ||
| callExpression: '^(\\$t|t|\\$tc|tc|\\$tcn|tcn|\\$tn|tn)$', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: being blocked by intlify/eslint-plugin-vue-i18n#643, I have two thoughts:
|
||
| ignores: [ | ||
| // /^[\w-]+\./ should match all locale keys, e.g. "en", "zh-Hant" etc. | ||
| /^[\w-]+\.audit\.action\./, | ||
| /^[\w-]+\.audit\.category\./, | ||
| /^[\w-]+\.back\.back$/, | ||
| /^[\w-]+\.back\.title$/, | ||
| /^[\w-]+\.component\.WebFormRenderer\./, // dynamic modals | ||
| /^[\w-]+\.conflict\./, | ||
| /^[\w-]+\.fields\./, | ||
| /^[\w-]+\.oidc.error\./, | ||
| /^[\w-]+\.outdatedVersionHtml\./, // check that file's comments | ||
| /^[\w-]+\.reviewState\./, | ||
| /^[\w-]+\.steps\[0\]\.introduction\[1\]\[0\]$/, | ||
| /^[\w-]+\.tab\./, | ||
| /^[\w-]+\.title\.submissionBacklog\./, | ||
| /^[\w-]+\.title\.updateReviewState\./, | ||
| /^[\w-]+\.type\./, | ||
|
Comment on lines
+26
to
+40
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You wrote in the PR description:
The list of exceptions here is indeed longer than I'd expect. We probably wouldn't have to add to it super often though. I am a little concerned about false negatives though. It seems like the check will ignore a lot of messages. I guess checking most messages is much better than checking no messages though. It makes sense to me that messages that are accessed via dynamic/constructed keys need to be in this list, e.g., |
||
| /Modal\.(body|title)$/, | ||
| ].map(re => re.toString()), | ||
| }], | ||
| 'arrow-parens': 'off', | ||
| 'class-methods-use-this': 'off', | ||
| 'comma-dangle': ['error', 'only-multiline'], | ||
|
|
@@ -51,6 +77,7 @@ module.exports = { | |
| asyncArrow: 'always' | ||
| }], | ||
| 'spaced-comment': 'off', | ||
| 'vue/attribute-hyphenation': 'off', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You wrote in the PR description:
I wonder if we need to update our version of Just based on their names, One approach we could take is disable these rules for now, but file a follow-up issue to consider reenabling them. |
||
| 'vue/attributes-order': ['error', { | ||
| order: [ | ||
| 'LIST_RENDERING', | ||
|
|
@@ -76,6 +103,7 @@ module.exports = { | |
| selfClosingTag: 'never' | ||
| }], | ||
| 'vue/html-indent': 'off', | ||
| 'vue/require-prop-types': 'off', | ||
| 'vue/html-self-closing': ['error', { | ||
| html: { | ||
| void: 'never', | ||
|
|
@@ -87,6 +115,7 @@ module.exports = { | |
| }], | ||
| 'vue/max-attributes-per-line': 'off', | ||
| 'vue/multi-word-component-names': 'off', | ||
| 'vue/no-constant-condition': 'off', | ||
| 'vue/no-setup-props-destructure': 'off', | ||
| 'vue/no-template-target-blank': 'off', | ||
| 'vue/object-curly-newline': 'off', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #1026 is complete, there won't be a
$tc()ortc()anymore. At that time, we'll probably rename$tcn()to$tn().Currently, there is
$tcn(), and there istn(); there's no$tn()ortcn(). The asymmetry is because we've had$tcn()for a long time, whiletn()was added around the time that we moved to Vue 3 and started using the Composition API. In the context of Vue I18n within the Composition API,tc()is deprecated, becauset()now does what$t()and$tc()both used to do.