mirror of
https://github.com/grafana/grafana.git
synced 2025-01-13 09:32:12 -06:00
I18n: Add lint rule to enforce correct i18n imports (#56487)
* I18n: Add lint rule to enforce correct i18n imports * ignore in gui wrapper
This commit is contained in:
parent
74c809f544
commit
891f9c00a1
@ -20,13 +20,18 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"no-restricted-imports": [
|
"no-restricted-imports": [
|
||||||
"warn",
|
"error",
|
||||||
{
|
{
|
||||||
"paths": [
|
"paths": [
|
||||||
{
|
{
|
||||||
"name": "react-redux",
|
"name": "react-redux",
|
||||||
"importNames": ["useDispatch", "useSelector"],
|
"importNames": ["useDispatch", "useSelector"],
|
||||||
"message": "Please import from app/types instead."
|
"message": "Please import from app/types instead."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "react-i18next",
|
||||||
|
"importNames": ["Trans", "t"],
|
||||||
|
"message": "Please import from app/core/internationalization instead"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
{
|
{
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-restricted-imports": ["error", { "patterns": ["@grafana/runtime", "@grafana/data/*", "@grafana/ui", "@grafana/e2e"] }]
|
"no-restricted-imports": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"patterns": ["@grafana/runtime", "@grafana/data/*", "@grafana/ui", "@grafana/e2e"],
|
||||||
|
"paths": [
|
||||||
|
{
|
||||||
|
"name": "react-i18next",
|
||||||
|
"importNames": ["Trans", "t"],
|
||||||
|
"message": "Please import from grafana-ui/src/utils/i18n instead"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Trans as I18NextTrans, initReactI18next } from 'react-i18next';
|
import { Trans as I18NextTrans, initReactI18next } from 'react-i18next'; // eslint-disable-line no-restricted-imports
|
||||||
|
|
||||||
// We want to translate grafana-ui without introducing any breaking changes for consumers
|
// We want to translate grafana-ui without introducing any breaking changes for consumers
|
||||||
// who use grafana-ui outside of grafana (such as grafana.com self serve). The other struggle
|
// who use grafana-ui outside of grafana (such as grafana.com self serve). The other struggle
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import i18n, { BackendModule, ResourceKey } from 'i18next';
|
import i18n, { BackendModule, ResourceKey } from 'i18next';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Trans as I18NextTrans, initReactI18next } from 'react-i18next';
|
import { Trans as I18NextTrans, initReactI18next } from 'react-i18next'; // eslint-disable-line no-restricted-imports
|
||||||
|
|
||||||
import { DEFAULT_LOCALE, ENGLISH_US, FRENCH_FRANCE, SPANISH_SPAIN, PSEUDO_LOCALE, VALID_LOCALES } from './constants';
|
import { DEFAULT_LOCALE, ENGLISH_US, FRENCH_FRANCE, SPANISH_SPAIN, PSEUDO_LOCALE, VALID_LOCALES } from './constants';
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ const loadTranslations: BackendModule = {
|
|||||||
return callback(new Error('No message loader available for ' + language), null);
|
return callback(new Error('No message loader available for ' + language), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: namespace??
|
|
||||||
const messages = await loader();
|
const messages = await loader();
|
||||||
callback(null, messages);
|
callback(null, messages);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user