Change prettier rules

This commit is contained in:
ErickSkrauch
2020-05-24 02:08:24 +03:00
parent 73f0c37a6a
commit f85b9d8d35
382 changed files with 24137 additions and 26046 deletions

View File

@@ -5,23 +5,21 @@ import i18n from 'app/services/i18n';
import { RootState } from 'app/reducers';
const IntlProvider: ComponentType = ({ children }) => {
const [intl, setIntl] = useState<IntlShape>(i18n.getIntl());
const locale = useSelector(
({ i18n: i18nState }: RootState) => i18nState.locale,
);
const [intl, setIntl] = useState<IntlShape>(i18n.getIntl());
const locale = useSelector(({ i18n: i18nState }: RootState) => i18nState.locale);
useEffect(() => {
if (process.env.NODE_ENV === 'test') {
// disable async modules loading in tests
return;
}
useEffect(() => {
if (process.env.NODE_ENV === 'test') {
// disable async modules loading in tests
return;
}
(async () => {
setIntl(await i18n.changeLocale(locale));
})();
}, [locale]);
(async () => {
setIntl(await i18n.changeLocale(locale));
})();
}, [locale]);
return <RawIntlProvider value={intl}>{children}</RawIntlProvider>;
return <RawIntlProvider value={intl}>{children}</RawIntlProvider>;
};
export default IntlProvider;

View File

@@ -3,29 +3,29 @@ import i18n from 'app/services/i18n';
import { ThunkAction } from 'app/reducers';
export function setLocale(desiredLocale: string): ThunkAction<Promise<string>> {
return async (dispatch) => {
const locale = i18n.detectLanguage(desiredLocale);
return async (dispatch) => {
const locale = i18n.detectLanguage(desiredLocale);
dispatch(_setLocale(locale));
dispatch(_setLocale(locale));
return locale;
};
return locale;
};
}
interface SetAction extends ReduxAction {
type: 'i18n:setLocale';
payload: {
locale: string;
};
type: 'i18n:setLocale';
payload: {
locale: string;
};
}
function _setLocale(locale: string): SetAction {
return {
type: 'i18n:setLocale',
payload: {
locale,
},
};
return {
type: 'i18n:setLocale',
payload: {
locale,
},
};
}
export type Action = SetAction;

View File

@@ -1,38 +1,34 @@
import supportedLocales from 'app/i18n';
const localeToCountryCode: Record<string, string> = {
en: 'gb',
be: 'by',
pt: 'br',
uk: 'ua',
vi: 'vn',
sl: 'si',
sr: 'rs',
zh: 'cn',
en: 'gb',
be: 'by',
pt: 'br',
uk: 'ua',
vi: 'vn',
sl: 'si',
sr: 'rs',
zh: 'cn',
};
const SUPPORTED_LANGUAGES: string[] = Object.keys(supportedLocales);
export default {
getCountryList(): string[] {
return SUPPORTED_LANGUAGES.map(
(locale) => localeToCountryCode[locale] || locale,
);
},
getCountryList(): string[] {
return SUPPORTED_LANGUAGES.map((locale) => localeToCountryCode[locale] || locale);
},
/**
* Возвращает для указанной локали её флаг с учётом всех нюансов загрузки флага
* и подбора соответствующего локали флага.
*
* @param {string} locale
*
* @returns {string}
*/
getIconUrl(locale: string): string {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const mod = require(`flag-icon-css/flags/4x3/${
localeToCountryCode[locale] || locale
}.svg`);
/**
* Возвращает для указанной локали её флаг с учётом всех нюансов загрузки флага
* и подбора соответствующего локали флага.
*
* @param {string} locale
*
* @returns {string}
*/
getIconUrl(locale: string): string {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const mod = require(`flag-icon-css/flags/4x3/${localeToCountryCode[locale] || locale}.svg`);
return mod.default || mod;
},
return mod.default || mod;
},
};

View File

@@ -3,20 +3,17 @@ import i18n from 'app/services/i18n';
import { Action } from './actions';
export interface State {
locale: string;
locale: string;
}
const defaultState: State = {
locale: i18n.detectLanguage(),
locale: i18n.detectLanguage(),
};
export default function (
state: State = defaultState,
{ type, payload }: Action,
): State {
if (type === 'i18n:setLocale') {
return payload;
}
export default function (state: State = defaultState, { type, payload }: Action): State {
if (type === 'i18n:setLocale') {
return payload;
}
return state;
return state;
}