aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-09-03 09:57:50 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-09-03 09:57:50 -0700
commitc75dbd5410dd0eed2576afdedcfeb6082b4f7225 (patch)
tree69611e16a4823d5cf78b17c9199a7a3ea72dc7ee /modern
parenta15843964ef7c2a51bf861dcb395c78062996c87 (diff)
downloadtrackermap-web-c75dbd5410dd0eed2576afdedcfeb6082b4f7225.tar.gz
trackermap-web-c75dbd5410dd0eed2576afdedcfeb6082b4f7225.tar.bz2
trackermap-web-c75dbd5410dd0eed2576afdedcfeb6082b4f7225.zip
Fix lint issues
Diffstat (limited to 'modern')
-rw-r--r--modern/src/DevicePage.js2
-rw-r--r--modern/src/GeofencePage.js2
-rw-r--r--modern/src/LocalizationProvider.js24
-rw-r--r--modern/src/UserPage.js2
-rw-r--r--modern/src/admin/ServerPage.js4
-rw-r--r--modern/src/attributes/useDeviceAttributes.js (renamed from modern/src/attributes/deviceAttributes.js)2
-rw-r--r--modern/src/attributes/useGeofenceAttributes.js (renamed from modern/src/attributes/geofenceAttributes.js)2
-rw-r--r--modern/src/attributes/usePositionAttributes.js (renamed from modern/src/attributes/positionAttributes.js)2
-rw-r--r--modern/src/attributes/useUserAttributes.js (renamed from modern/src/attributes/userAttributes.js)2
-rw-r--r--modern/src/common/formatter.js5
-rw-r--r--modern/src/common/usePersistedState.js3
-rw-r--r--modern/src/map/Map.js1
-rw-r--r--modern/src/reports/ChartReportPage.js2
-rw-r--r--modern/src/settings/ComputedAttributePage.js2
-rw-r--r--modern/src/settings/GroupPage.js2
-rw-r--r--modern/src/settings/MaintenancePage.js2
-rw-r--r--modern/src/settings/MaintenancesPage.js2
-rw-r--r--modern/src/settings/NotificationPage.js2
18 files changed, 29 insertions, 34 deletions
diff --git a/modern/src/DevicePage.js b/modern/src/DevicePage.js
index c3a49a58..def48d9c 100644
--- a/modern/src/DevicePage.js
+++ b/modern/src/DevicePage.js
@@ -12,7 +12,7 @@ import deviceCategories from './common/deviceCategories';
import LinkField from './form/LinkField';
import { prefixString } from './common/stringUtils';
import { useTranslation } from './LocalizationProvider';
-import { useDeviceAttributes } from './attributes/deviceAttributes';
+import useDeviceAttributes from './attributes/useDeviceAttributes';
const useStyles = makeStyles(() => ({
details: {
diff --git a/modern/src/GeofencePage.js b/modern/src/GeofencePage.js
index db752467..d421a8e1 100644
--- a/modern/src/GeofencePage.js
+++ b/modern/src/GeofencePage.js
@@ -8,7 +8,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import EditItemView from './EditItemView';
import EditAttributesView from './attributes/EditAttributesView';
import { useTranslation } from './LocalizationProvider';
-import { useGeofenceAttributes } from './attributes/geofenceAttributes';
+import useGeofenceAttributes from './attributes/useGeofenceAttributes';
const useStyles = makeStyles(() => ({
details: {
diff --git a/modern/src/LocalizationProvider.js b/modern/src/LocalizationProvider.js
index ae08a569..cc23d724 100644
--- a/modern/src/LocalizationProvider.js
+++ b/modern/src/LocalizationProvider.js
@@ -1,5 +1,5 @@
import React, { createContext, useContext } from 'react';
-import { usePersistedState } from './common/usePersistedState';
+import usePersistedState from './common/usePersistedState';
import af from '../../web/l10n/af.json';
import ar from '../../web/l10n/ar.json';
@@ -38,7 +38,7 @@ import nl from '../../web/l10n/nl.json';
import nn from '../../web/l10n/nn.json';
import pl from '../../web/l10n/pl.json';
import pt from '../../web/l10n/pt.json';
-import pt_BR from '../../web/l10n/pt_BR.json';
+import ptBR from '../../web/l10n/pt_BR.json';
import ro from '../../web/l10n/ro.json';
import ru from '../../web/l10n/ru.json';
import si from '../../web/l10n/si.json';
@@ -54,7 +54,7 @@ import uk from '../../web/l10n/uk.json';
import uz from '../../web/l10n/uz.json';
import vi from '../../web/l10n/vi.json';
import zh from '../../web/l10n/zh.json';
-import zh_TW from '../../web/l10n/zh_TW.json';
+import zhTW from '../../web/l10n/zh_TW.json';
const languages = {
af: { data: af, name: 'Afrikaans' },
@@ -94,7 +94,7 @@ const languages = {
nn: { data: nn, name: 'Norsk nynorsk' },
pl: { data: pl, name: 'Polski' },
pt: { data: pt, name: 'Português' },
- pt_BR: { data: pt_BR, name: 'Português (Brasil)' },
+ ptBR: { data: ptBR, name: 'Português (Brasil)' },
ro: { data: ro, name: 'Română' },
ru: { data: ru, name: 'Русский' },
si: { data: si, name: 'සිංහල' },
@@ -110,7 +110,7 @@ const languages = {
uz: { data: uz, name: 'Oʻzbekcha' },
vi: { data: vi, name: 'Tiếng Việt' },
zh: { data: zh, name: '中文' },
- zh_TW: { data: zh_TW, name: '中文 (Taiwan)' },
+ zhTW: { data: zhTW, name: '中文 (Taiwan)' },
};
const getDefaultLanguage = () => {
@@ -118,10 +118,9 @@ const getDefaultLanguage = () => {
const browserLanguage = window.navigator.userLanguage || window.navigator.language;
browserLanguages.push(browserLanguage);
browserLanguages.push(browserLanguage.substring(0, 2));
- browserLanguages.push('en');
- for (let i = 0; i < browserLanguages.length; i++) {
- let language = browserLanguages[i].replace('-', '_');
+ for (let i = 0; i < browserLanguages.length; i += 1) {
+ let language = browserLanguages[i].replace('-', '');
if (language in languages) {
return language;
}
@@ -132,6 +131,7 @@ const getDefaultLanguage = () => {
}
}
}
+ return 'en';
};
const LocalizationContext = createContext({
@@ -150,18 +150,16 @@ export const LocalizationProvider = ({ children }) => {
);
};
-export const useLocalization = () => {
- return useContext(LocalizationContext);
-};
+export const useLocalization = () => useContext(LocalizationContext);
export const useTranslation = () => {
const context = useContext(LocalizationContext);
- const data = context.languages[context.language].data;
+ const { data } = context.languages[context.language];
return (key) => data[key];
};
export const useTranslationKeys = (predicate) => {
const context = useContext(LocalizationContext);
- const data = context.languages[context.language].data;
+ const { data } = context.languages[context.language];
return Object.keys(data).filter(predicate);
};
diff --git a/modern/src/UserPage.js b/modern/src/UserPage.js
index 977d3302..ec19dd63 100644
--- a/modern/src/UserPage.js
+++ b/modern/src/UserPage.js
@@ -9,7 +9,7 @@ import EditItemView from './EditItemView';
import EditAttributesView from './attributes/EditAttributesView';
import LinkField from './form/LinkField';
import { useTranslation } from './LocalizationProvider';
-import { useUserAttributes } from './attributes/userAttributes';
+import useUserAttributes from './attributes/useUserAttributes';
const useStyles = makeStyles(() => ({
details: {
diff --git a/modern/src/admin/ServerPage.js b/modern/src/admin/ServerPage.js
index b424aac4..6f0d0734 100644
--- a/modern/src/admin/ServerPage.js
+++ b/modern/src/admin/ServerPage.js
@@ -9,8 +9,8 @@ import { useHistory } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { sessionActions } from '../store';
import EditAttributesView from '../attributes/EditAttributesView';
-import { useDeviceAttributes } from '../attributes/deviceAttributes';
-import { useUserAttributes } from '../attributes/userAttributes';
+import useDeviceAttributes from '../attributes/useDeviceAttributes';
+import useUserAttributes from '../attributes/useUserAttributes';
import OptionsLayout from '../settings/OptionsLayout';
import { useTranslation } from '../LocalizationProvider';
diff --git a/modern/src/attributes/deviceAttributes.js b/modern/src/attributes/useDeviceAttributes.js
index 20bb1e09..33213212 100644
--- a/modern/src/attributes/deviceAttributes.js
+++ b/modern/src/attributes/useDeviceAttributes.js
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
-export const useDeviceAttributes = (t) => useMemo({
+export default (t) => useMemo({
speedLimit: {
name: t('attributeSpeedLimit'),
type: 'string',
diff --git a/modern/src/attributes/geofenceAttributes.js b/modern/src/attributes/useGeofenceAttributes.js
index d9f512f1..3c17755e 100644
--- a/modern/src/attributes/geofenceAttributes.js
+++ b/modern/src/attributes/useGeofenceAttributes.js
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
-export const useGeofenceAttributes = (t) => useMemo({
+export default (t) => useMemo({
speedLimit: {
name: t('attributeSpeedLimit'),
type: 'string',
diff --git a/modern/src/attributes/positionAttributes.js b/modern/src/attributes/usePositionAttributes.js
index 49a64f71..825ec363 100644
--- a/modern/src/attributes/positionAttributes.js
+++ b/modern/src/attributes/usePositionAttributes.js
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
-export const usePositionAttributes = (t) => useMemo({
+export default (t) => useMemo({
raw: {
name: t('positionRaw'),
type: 'string',
diff --git a/modern/src/attributes/userAttributes.js b/modern/src/attributes/useUserAttributes.js
index d9a5814d..bf8c95af 100644
--- a/modern/src/attributes/userAttributes.js
+++ b/modern/src/attributes/useUserAttributes.js
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
-export const useUserAttributes = (t) => useMemo({
+export default (t) => useMemo({
notificationTokens: {
name: t('attributeNotificationTokens'),
type: 'string',
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 7a18d1af..0ff4e741 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -1,9 +1,6 @@
import moment from 'moment';
-import { useTranslation } from '../LocalizationProvider';
-export const formatBoolean = (value, t) => {
- return value ? t('sharedYes') : t('sharedNo');
-}
+export const formatBoolean = (value, t) => (value ? t('sharedYes') : t('sharedNo'));
export const formatNumber = (value, precision = 1) => Number(value.toFixed(precision));
diff --git a/modern/src/common/usePersistedState.js b/modern/src/common/usePersistedState.js
index a3a60d75..0a7a990e 100644
--- a/modern/src/common/usePersistedState.js
+++ b/modern/src/common/usePersistedState.js
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react';
-export const usePersistedState = (key, defaultValue) => {
-
+export default (key, defaultValue) => {
const [value, setValue] = useState(() => {
const stickyValue = window.localStorage.getItem(key);
return stickyValue ? JSON.parse(stickyValue) : defaultValue;
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js
index 1fa4db5d..2b95087a 100644
--- a/modern/src/map/Map.js
+++ b/modern/src/map/Map.js
@@ -15,6 +15,7 @@ import palette from '../theme/palette';
// TODO fix localization
import en from '../../../web/l10n/en.json';
+
const t = (key) => en[key];
const element = document.createElement('div');
diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js
index 6679fe4f..3639b98a 100644
--- a/modern/src/reports/ChartReportPage.js
+++ b/modern/src/reports/ChartReportPage.js
@@ -39,7 +39,7 @@ const Filter = ({ children, setItems }) => {
const ChartType = ({ type, setType }) => {
const t = useTranslation();
-
+
return (
<Grid container spacing={3}>
<Grid item xs={12} sm={6}>
diff --git a/modern/src/settings/ComputedAttributePage.js b/modern/src/settings/ComputedAttributePage.js
index 6733e980..e8efd096 100644
--- a/modern/src/settings/ComputedAttributePage.js
+++ b/modern/src/settings/ComputedAttributePage.js
@@ -5,7 +5,7 @@ import {
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import EditItemView from '../EditItemView';
import { useTranslation } from '../LocalizationProvider';
-import { usePositionAttributes } from '../attributes/positionAttributes';
+import usePositionAttributes from '../attributes/usePositionAttributes';
const useStyles = makeStyles(() => ({
details: {
diff --git a/modern/src/settings/GroupPage.js b/modern/src/settings/GroupPage.js
index 88b9504d..be14e96e 100644
--- a/modern/src/settings/GroupPage.js
+++ b/modern/src/settings/GroupPage.js
@@ -7,7 +7,7 @@ import {
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import EditItemView from '../EditItemView';
import EditAttributesView from '../attributes/EditAttributesView';
-import { useDeviceAttributes } from '../attributes/deviceAttributes';
+import useDeviceAttributes from '../attributes/useDeviceAttributes';
import SelectField from '../form/SelectField';
import { useTranslation } from '../LocalizationProvider';
diff --git a/modern/src/settings/MaintenancePage.js b/modern/src/settings/MaintenancePage.js
index d9500bed..c157ff48 100644
--- a/modern/src/settings/MaintenancePage.js
+++ b/modern/src/settings/MaintenancePage.js
@@ -12,7 +12,7 @@ import {
speedFromKnots, speedToKnots, distanceFromMeters, distanceToMeters,
} from '../common/converter';
import { useTranslation } from '../LocalizationProvider';
-import { usePositionAttributes } from '../attributes/positionAttributes';
+import usePositionAttributes from '../attributes/usePositionAttributes';
const useStyles = makeStyles(() => ({
details: {
diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js
index 89b0279e..2246b090 100644
--- a/modern/src/settings/MaintenancesPage.js
+++ b/modern/src/settings/MaintenancesPage.js
@@ -6,7 +6,7 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';
import { useEffectAsync } from '../reactHelper';
import EditCollectionView from '../EditCollectionView';
-import { usePositionAttributes } from '../attributes/positionAttributes';
+import usePositionAttributes from '../attributes/usePositionAttributes';
import { formatDistance, formatSpeed } from '../common/formatter';
import { useAttributePreference } from '../common/preferences';
import OptionsLayout from './OptionsLayout';
diff --git a/modern/src/settings/NotificationPage.js b/modern/src/settings/NotificationPage.js
index 6d895d0f..67c4ee05 100644
--- a/modern/src/settings/NotificationPage.js
+++ b/modern/src/settings/NotificationPage.js
@@ -4,7 +4,7 @@ import {
Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControlLabel, Checkbox,
} from '@material-ui/core';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
-import t, { findStringKeys, useTranslation, useTranslationKeys } from '../LocalizationProvider';
+import { useTranslation, useTranslationKeys } from '../LocalizationProvider';
import EditItemView from '../EditItemView';
import { prefixString, unprefixString } from '../common/stringUtils';
import SelectField from '../form/SelectField';