Skip to content

Commit 284c8c9

Browse files
authored
chore: comply more to default TS config (#3743)
1 parent af4676c commit 284c8c9

25 files changed

Lines changed: 70 additions & 83 deletions

File tree

src/component/1d-2d/FieldEdition.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ function stopPropagation(e: any) {
3838
e.stopPropagation();
3939
}
4040

41-
function keyDownCheck(event: React.KeyboardEvent<HTMLInputElement>) {
42-
if (event.key === 'Enter') {
43-
return true;
44-
} else if (event.key === 'Escape') {
45-
return false;
46-
}
47-
}
48-
4941
export function FieldEdition(props: FieldEditionsProps) {
5042
const { value, inputType = 'text', onChange, children, PopoverProps } = props;
5143
const [isOpen, setIsOpen] = useState(false);
@@ -84,7 +76,7 @@ function Field(props: FieldProps) {
8476
});
8577

8678
function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
87-
if (keyDownCheck(event)) {
79+
if (event.key === 'Enter') {
8880
void handleSubmit(onChange)();
8981
}
9082
}

src/component/1d/peaks/PeakEditionManager.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ function PeakEditionField({ value, onClose }: PeakFieldProps) {
167167
} else if (event.key === 'Escape') {
168168
onClose();
169169
return false;
170+
} else {
171+
return false;
170172
}
171173
}
172174
function handleOnSubmit({ value: newValue }: FieldValues) {

src/component/2d/SignalDeltaLine.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styled from '@emotion/styled';
2+
import { assert } from 'react-science/ui';
23

34
import { useChartData } from '../context/ChartContext.js';
45

@@ -16,7 +17,8 @@ interface SignalDeltaLineProps {
1617
show: boolean;
1718
}
1819

19-
function SignalDeltaLine({ delta, axis, show }: SignalDeltaLineProps) {
20+
function SignalDeltaLine(props: SignalDeltaLineProps) {
21+
const { delta, axis, show } = props;
2022
const { xDomain, yDomain } = useChartData();
2123
const scaleX = useScale2DX();
2224
const scaleY = useScale2DY();
@@ -33,9 +35,8 @@ function SignalDeltaLine({ delta, axis, show }: SignalDeltaLineProps) {
3335
y2={scaleY(yDomain[1])}
3436
/>
3537
);
36-
}
37-
38-
if (axis === 'Y') {
38+
} else {
39+
assert(axis === 'Y');
3940
return (
4041
<SignalLine
4142
key={`signalLine_${delta}_Y`}

src/component/context/SortSpectraContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ interface SortItem {
163163
sortValue: string | number | boolean | null | undefined;
164164
}
165165

166-
function sortArray(data: SortItem[], sortDirection?: SortDirection) {
166+
function sortArray(data: SortItem[], sortDirection?: SortDirection): void {
167167
const direction = sortDirection === 'asc' ? 1 : -1;
168168

169169
if (!sortDirection) {
170-
return data;
170+
return;
171171
}
172172

173173
data.sort((a, b) => {

src/component/elements/NextPrev.tsx

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -83,52 +83,28 @@ const transition = 0.45;
8383

8484
interface NextPrevProps {
8585
children: ReactElement | ReactElement[];
86-
loop?: boolean;
8786
index: number;
8887
onChange: (element: number) => void;
8988
style?: { arrowContainer?: CSSProperties };
9089
}
9190

9291
export function NextPrev(props: NextPrevProps) {
93-
const {
94-
children,
95-
loop = false,
96-
index = 0,
97-
onChange = () => null,
98-
style = {},
99-
} = props;
92+
const { children, index = 0, onChange = () => null, style = {} } = props;
10093
const [ref, { width } = { width: 0 }] = useResizeObserver();
10194
const slidersCount = Children.count(children);
10295
const lastIndex = slidersCount > 0 ? slidersCount - 1 : 0;
10396
const activeIndex = Math.min(index, lastIndex);
10497

10598
function nextHandler() {
106-
if (index === lastIndex) {
107-
onChange(index);
108-
109-
if (loop) {
110-
return 0;
111-
} else {
112-
return index;
113-
}
99+
if (index < lastIndex) {
100+
onChange(index + 1);
114101
}
115-
116-
const nextIndex = index + 1;
117-
onChange(nextIndex);
118102
}
119103

120104
function prevHandler() {
121-
if (index === 0) {
122-
onChange(index);
123-
if (loop) {
124-
return 0;
125-
} else {
126-
return index;
127-
}
105+
if (index > 0) {
106+
onChange(index - 1);
128107
}
129-
const prevIndex = index - 1;
130-
131-
onChange(prevIndex);
132108
}
133109

134110
if (!width && slidersCount === 0) return null;

src/component/elements/export/ExportManager.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ export function ExportManagerController(props: ExportManagerControllerProps) {
9595
triggerExport(null);
9696
}
9797

98-
function handleExport(targetElement: HTMLElement, options: ExportSettings) {
98+
function handleExport(
99+
targetElement: HTMLElement,
100+
options: ExportSettings,
101+
): void {
99102
if (!exportOptions) {
100-
return null;
103+
return;
101104
}
102105

103106
if (!hasDataToExport) {
@@ -106,7 +109,7 @@ export function ExportManagerController(props: ExportManagerControllerProps) {
106109
intent: 'danger',
107110
message: 'No spectra available for export',
108111
});
109-
return null;
112+
return;
110113
}
111114

112115
const { format, destination = 'file' } = exportOptions;

src/component/elements/pdnd.cts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// Given how `@atlaskit/pragmatic-drag-and-drop` publishes ESM in a non-native way,
33
// we have to trick TS into using the CJS build so that our build is compatible
44
// with native ESM.
5-
// We cannot use `verbatimModuleSyntax` ts config option with this pattern.
5+
// This file is not compatible with the `verbatimModuleSyntax` TS option.
6+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
7+
// @ts-nocheck
68
export {
79
draggable,
810
dropTargetForElements,

src/component/hooks/useSaveSettings.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
22
import styled from '@emotion/styled';
33
import { yupResolver } from '@hookform/resolvers/yup';
44
import type { Workspace } from '@zakodium/nmrium-core';
5-
import type { KeyboardEvent } from 'react';
65
import { useRef } from 'react';
76
import { useForm } from 'react-hook-form';
87
import { useOnOff } from 'react-science/ui';
@@ -19,14 +18,6 @@ const schema = Yup.object().shape({
1918
workspaceName: Yup.string().required(),
2019
});
2120

22-
function keyDownCheck(event: KeyboardEvent<HTMLInputElement>) {
23-
if (event.key === 'Enter') {
24-
return true;
25-
} else if (event.key === 'Escape') {
26-
return false;
27-
}
28-
}
29-
3021
function WorkspaceAddForm(props: any) {
3122
const { className, message, control, onEnter } = props;
3223

@@ -44,7 +35,7 @@ function WorkspaceAddForm(props: any) {
4435
autoFocus
4536
size="large"
4637
onKeyDown={(event) => {
47-
if (keyDownCheck(event)) {
38+
if (event.key === 'Enter') {
4839
onEnter();
4940
}
5041
}}

src/component/modal/metaImportation/MetaImportationModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ function InnerMetaImportationModal({
240240
} else if (record) {
241241
return rowColors.match;
242242
}
243+
return undefined;
243244
}
244245

245246
function handleImport() {

src/component/modal/setting/GeneralSettings.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ function WorkSpaceActionsButtons(props: any) {
351351
reset(workSpaceDisplayPreferences);
352352
}
353353

354-
function handlePastWorkspace(text: string | undefined) {
354+
function handlePasteWorkspace(text: string | undefined) {
355355
if (!text) return;
356356

357357
try {
@@ -365,7 +365,7 @@ function WorkSpaceActionsButtons(props: any) {
365365
}
366366

367367
function handlePastWorkspaceAction() {
368-
void readText().then(handlePastWorkspace);
368+
void readText().then(handlePasteWorkspace);
369369
}
370370

371371
function handleCopyWorkspace() {
@@ -428,7 +428,7 @@ function WorkSpaceActionsButtons(props: any) {
428428
<ClipboardFallbackModal
429429
mode={shouldFallback}
430430
onDismiss={cleanShouldFallback}
431-
onReadText={handlePastWorkspace}
431+
onReadText={handlePasteWorkspace}
432432
text={text}
433433
label="Workspace"
434434
/>
@@ -453,7 +453,8 @@ function DialogActionButtons(props: BasseGeneralModalProps) {
453453

454454
function applyPreferencesHandler() {
455455
if (!isValid) {
456-
return handleSubmit(submitHandler)();
456+
void handleSubmit(submitHandler)();
457+
return;
457458
}
458459

459460
dispatch({

0 commit comments

Comments
 (0)