Skip to content

Commit

Permalink
Fix additional linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maksis committed Dec 31, 2024
1 parent b0b764f commit 14f0d31
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 48 deletions.
19 changes: 16 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/components/download/layout/DownloadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { usingMobileLayout } from 'utils/BrowserUtils';
import { toI18nKey } from 'utils/TranslationUtils';

import ShareConstants from 'constants/ShareConstants';
import {
default as HistoryConstants,
HistoryStringEnum,
} from 'constants/HistoryConstants';
import FavoriteDirectoryConstants from 'constants/FavoriteDirectoryConstants';

import MenuItemLink from 'components/semantic/MenuItemLink';
Expand Down
4 changes: 1 addition & 3 deletions src/components/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const fieldOptionReducer = (
}

if (fieldDefinitions.type === API.SettingTypeEnum.STRUCT) {
// reducedOptions[fieldDefinitions.key].fields = {};
reducedOptions[fieldDefinitions.key].fields = fieldDefinitions.definitions!.reduce(
(reduced, cur) => {
return fieldOptionReducer(
Expand Down Expand Up @@ -192,7 +191,7 @@ class Form<ValueType extends UI.FormValueMap = UI.FormValueMap> extends Componen
super(props);

this.sourceValue = normalizeSettingValueMap(
props.sourceValue || undefined,
props.sourceValue ?? undefined,
this.props.fieldDefinitions,
) as Partial<ValueType>;

Expand Down Expand Up @@ -334,7 +333,6 @@ class Form<ValueType extends UI.FormValueMap = UI.FormValueMap> extends Componen
return (
<Translation>
{(t) => {
//const { location } = useRouter(); // TODO
const {
title,
fieldDefinitions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ const HashStatistics: React.FC<HashStatisticsProps & HashStatisticsDataProps> =
// className,
hashStats,
}) => {
const { formatSpeed, t } = useFormatter();
const { formatSpeed } = useFormatter();
return (
<>
<StatisticsRow
icon={IconConstants.HASH}
bytes={hashStats.hash_speed}
formatter={formatSpeed}
t={t}
/>
</>
<StatisticsRow
icon={IconConstants.HASH}
bytes={hashStats.hash_speed}
formatter={formatSpeed}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@ import * as React from 'react';

import Icon, { IconType, CornerIconType } from 'components/semantic/Icon';

import * as UI from 'types/ui';

interface StatisticsRowProps {
icon: IconType;
cornerIcon?: CornerIconType;
bytes: number;
formatter: (bytes: number) => React.ReactNode;
t: UI.TranslateF;
}

export const StatisticsRow: React.FC<StatisticsRowProps> = ({
icon,
cornerIcon,
bytes,
formatter,
t,
}) => {
if (bytes === 0) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import * as API from 'types/api';
import DataProviderDecorator from 'decorators/DataProviderDecorator';
import { StatisticsRow } from './StatisticsRow';

interface TransferStatisticsProps {
// className?: string;
}
interface TransferStatisticsProps {}

interface TransferStatisticsDataProps {
transferStats: Pick<API.TransferStats, 'speed_down' | 'speed_up' | 'queued_bytes'>;
Expand All @@ -21,26 +19,23 @@ interface TransferStatisticsDataProps {
const TransferStatistics: React.FC<
TransferStatisticsProps & TransferStatisticsDataProps
> = ({ transferStats }) => {
const { formatSize, formatSpeed, t } = useFormatter();
const { formatSize, formatSpeed } = useFormatter();
return (
<>
<StatisticsRow
icon={IconConstants.DOWNLOAD}
bytes={transferStats.speed_down}
formatter={formatSpeed}
t={t}
/>
<StatisticsRow
icon={IconConstants.UPLOAD}
bytes={transferStats.speed_up}
formatter={formatSpeed}
t={t}
/>
<StatisticsRow
icon={IconConstants.QUEUE_COLORED}
bytes={transferStats.queued_bytes}
formatter={formatSize}
t={t}
/>
</>
);
Expand Down
12 changes: 9 additions & 3 deletions src/decorators/ActionHandlerDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const handleAction = async <

try {
const result = await action.handler(handlerData, confirmData);
if (action.notifications && action.notifications.onSuccess) {
if (action.notifications?.onSuccess) {
const item = action.notifications.itemConverter
? action.notifications.itemConverter(itemData)
: itemData;
Expand All @@ -105,13 +105,19 @@ const handleAction = async <

resolve(result);
} catch (e) {
const reason = !e ? undefined : typeof e === 'string' ? e : e.message;
let reason;
if (typeof e === 'string') {
reason = e;
} else if (e) {
reason = e.message;
}

NotificationActions.error({
title: translate('Action failed', t, UI.Modules.COMMON),
message: reason,
});

reject(reason);
reject(Error(reason));
}
});
});
Expand Down
14 changes: 8 additions & 6 deletions src/decorators/TableFilterDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ export default function <PropsT>(
React.useLayoutEffect(() => {
return () => {
const { store, filter, socket } = props;
if (store.active) {
socket
.delete(`${store.viewUrl}/filter/${filter.id}`)
.catch((error: ErrorResponse) =>
console.error('Failed to delete table filter', error),
);
if (!store.active) {
return;
}

socket
.delete(`${store.viewUrl}/filter/${filter.id}`)
.catch((error: ErrorResponse) =>
console.error('Failed to delete table filter', error),
);
};
}, []);

Expand Down
8 changes: 2 additions & 6 deletions src/decorators/components/ActionDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// import * as React from 'react';

// import { Location } from 'react-router';

import * as UI from 'types/ui';

import { InputDialog } from 'components/semantic/InputDialog';
Expand Down Expand Up @@ -96,13 +92,13 @@ const getCommonConfirmDialogProps = <
const { action, moduleData } = actionData;
const { icon } = action;
const { approveCaption, rejectCaption, content, checkboxCaption } = translateInput(
confirmation!,
confirmation,
actionData,
t,
);
return {
approveCaption,
rejectCaption: rejectCaption || translate(defaultRejectCaption, t, UI.Modules.COMMON),
rejectCaption: rejectCaption ?? translate(defaultRejectCaption, t, UI.Modules.COMMON),
content,
icon,
title: translateActionName(action, moduleData, t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ profiles.';
);
};

export default ShareProfileDecorator(ShareProfilesPage, false, undefined);
export default ShareProfileDecorator(ShareProfilesPage, false);
4 changes: 2 additions & 2 deletions src/widgets/Transfers/components/SpeedChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const SpeedChart: React.FC<SpeedChartProps> = ({
options={options}
series={series}
type="area"
width={bounds && bounds.width ? bounds.width : undefined}
height={bounds && bounds.height ? bounds.height : undefined}
width={bounds?.width}
height={bounds?.height}
/>
</div>
)}
Expand Down

0 comments on commit 14f0d31

Please sign in to comment.