mirror of
https://github.com/grafana/grafana.git
synced 2024-12-25 08:21:46 -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": [
|
||||
"warn",
|
||||
"error",
|
||||
{
|
||||
"paths": [
|
||||
{
|
||||
"name": "react-redux",
|
||||
"importNames": ["useDispatch", "useSelector"],
|
||||
"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": {
|
||||
"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": [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
import i18next from 'i18next';
|
||||
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
|
||||
// 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 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';
|
||||
|
||||
@ -21,7 +21,6 @@ const loadTranslations: BackendModule = {
|
||||
return callback(new Error('No message loader available for ' + language), null);
|
||||
}
|
||||
|
||||
// TODO: namespace??
|
||||
const messages = await loader();
|
||||
callback(null, messages);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user