Skip to content

Commit

Permalink
i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
nirtamir2 committed Jul 7, 2024
1 parent a4e0eaa commit 9411b63
Showing 1 changed file with 48 additions and 51 deletions.
99 changes: 48 additions & 51 deletions src/configs/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,57 @@ export async function i18n(): Promise<Array<TypedFlatConfigItem>> {
]);

return [
{
name: "nirtamir2/i18n",
...fixupConfigRules(
compat.config({
extends: [
"plugin:i18n-prefix/recommended",
"plugin:i18next/recommended",
...fixupConfigRules(
compat.config({
extends: [
"plugin:i18n-prefix/recommended",
"plugin:i18next/recommended",
],
plugins: ["@naturacosmeticos/i18n-checker"],
rules: {
/**
* This will error if `t` function called with a translation key
* that does not exist in translation files
*/
"@naturacosmeticos/i18n-checker/path-in-locales": [
"error",
{
localesPath: "locales/",
messagesBasePath: "translations",
translationFunctionName: "t",
},
],
plugins: ["@naturacosmeticos/i18n-checker"],
rules: {
/**
* This will error if `t` function called with a translation key
* that does not exist in translation files
*/
"@naturacosmeticos/i18n-checker/path-in-locales": [
"error",
{
localesPath: "locales/",
messagesBasePath: "translations",
translationFunctionName: "t",
},
],
/**
* i18n translation should be the same as component name
*/
"i18n-prefix/i18n-prefix": [
"error",
{
translationFunctionName: "t",
delimiter: ".",
ignorePrefixes: ["enum"],
},
],
},
overrides: [
/**
* i18n translation should be the same as component name
*/
"i18n-prefix/i18n-prefix": [
"error",
{
files: ["**/locales/**/*.json"],
extends: ["plugin:i18n-json/recommended"],
rules: {
"i18n-json/valid-message-syntax": [
"error",
{
/**
* This allows using the i18next format with {param} syntax
* @see https://github.com/godaddy/eslint-plugin-i18n-json/issues/40#issuecomment-842474651
*/
syntax: path.resolve("./i18next-syntax-validator.mjs"),
},
],
},
translationFunctionName: "t",
delimiter: ".",
ignorePrefixes: ["enum"],
},
],
}),
),
},
},
overrides: [
{
files: ["**/locales/**/*.json"],
extends: ["plugin:i18n-json/recommended"],
rules: {
"i18n-json/valid-message-syntax": [
"error",
{
/**
* This allows using the i18next format with {param} syntax
* @see https://github.com/godaddy/eslint-plugin-i18n-json/issues/40#issuecomment-842474651
*/
syntax: path.resolve("./i18next-syntax-validator.mjs"),
},
],
},
},
],
}),
),
];
}

0 comments on commit 9411b63

Please sign in to comment.