-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
no-duplicate-keys-in-locale
rule and change no-missing-keys
r…
…ule to not report if there is one matching key in each locale (#112) * Add no-duplicate-keys-in-locale rule and change no-missing-keys rule to not report if there is one matching key in each locale. * fixed testcase
- Loading branch information
Showing
33 changed files
with
1,580 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# @intlify/vue-i18n/no-duplicate-keys-in-locale | ||
|
||
> disallow duplicate localization keys within the same locale | ||
If you manage localization messages in multiple files, duplicate localization keys across multiple files can cause unexpected problems. | ||
|
||
## :book: Rule Details | ||
|
||
This rule reports duplicate localization keys within the same locale. | ||
|
||
:-1: Examples of **incorrect** code for this rule: | ||
|
||
locale messages: | ||
|
||
- `en.1.json` | ||
|
||
```json5 | ||
// ✗ BAD | ||
{ | ||
"hello": "Hello! DIO!", // duplicate. | ||
"hello": "Hello! DIO!", // duplicate. | ||
"good-bye": "Good bye! DIO!" | ||
} | ||
``` | ||
|
||
- `en.2.json` | ||
|
||
```json5 | ||
// ✗ BAD | ||
{ | ||
"good-bye": "Good bye! DIO!" // This same key exists in `en.1.json`. | ||
} | ||
``` | ||
|
||
:+1: Examples of **correct** code for this rule: | ||
|
||
locale messages: | ||
|
||
- `en.1.json` | ||
|
||
```json5 | ||
// ✓ GOOD | ||
{ | ||
"hello": "Hello! DIO!", | ||
"hi": "Hi! DIO!" | ||
} | ||
``` | ||
|
||
- `en.2.json` | ||
|
||
```json5 | ||
// ✓ GOOD | ||
{ | ||
"good-bye": "Good bye! DIO!" // This same key exists in `en.1.json`. | ||
} | ||
``` | ||
|
||
## :gear: Options | ||
|
||
```json | ||
{ | ||
"@intlify/vue-i18n/no-duplicate-keys-in-locale": ["error", { | ||
"ignoreI18nBlock": false | ||
}] | ||
} | ||
``` | ||
|
||
- `ignoreI18nBlock`: If `true`, do not report key duplication between `<i18n>` blocks and other files, it set to `false` as default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.