Skip to content

Commit

Permalink
Fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peace317 committed Jun 16, 2024
1 parent 4692e76 commit c1f0bb8
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 71 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ See docs and guides for [electron-forge](https://js.electronforge.io/)

MIT © [Minterm](https://github.com/peace317/minterm)

[github-actions-status]: https://github.com/peace317/minterm/workflows/Test/badge.svg
[github-actions-status]: https://github.com/peace317/minterm/workflows/Build%20and%20Test/badge.svg
[github-actions-url]: https://github.com/peace317/minterm/actions
[github-tag-image]: https://img.shields.io/github/v/tag/peace317/minterm.svg?label=version
[github-tag-url]: https://github.com/peace317/minterm/releases/latest
2 changes: 2 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const createWindow = (): void => {
| "system"
| "light"
| "dark";

new AppUpdater();
};

// This method will be called when Electron has finished
Expand Down
22 changes: 11 additions & 11 deletions src/main/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import { format } from 'util';
export default class ElectronLogger {

init(): void {
ipcMain.on(IPCChannelType.DEBUG, (event, arg) => {
log.debug(this.buildLogString(arg));
ipcMain.on(IPCChannelType.DEBUG, (event, args) => {
log.debug(this.buildLogString(args));
});

ipcMain.on(IPCChannelType.INFO, async (event, arg) => {
log.info(this.buildLogString(arg));
ipcMain.on(IPCChannelType.INFO, async (event, args) => {
log.info(this.buildLogString(args));
});

ipcMain.on(IPCChannelType.LOG, async (event, arg) => {
log.log(this.buildLogString(arg));
ipcMain.on(IPCChannelType.LOG, async (event, args) => {
log.log(this.buildLogString(args));
});

ipcMain.on(IPCChannelType.WARN, async (event, arg) => {
log.warn(this.buildLogString(arg));
ipcMain.on(IPCChannelType.WARN, async (event, args) => {
log.warn(this.buildLogString(args));
});

ipcMain.on(IPCChannelType.ERROR, async (event, arg) => {
log.error(this.buildLogString(arg));
ipcMain.on(IPCChannelType.ERROR, async (event, args) => {
log.error(this.buildLogString(args));
});
}

public buildLogString(data: any): any {
public buildLogString(data: unknown[]): string {
let res = '';
const msgData = data[0] as LogMessage;
if (msgData !== undefined) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const electronHandler = {
},
removeListener(
channel: IPCChannelType,
listener: (...args: any[]) => void
listener: (...args: unknown[]) => void
) {
const cnt = ipcRenderer.listenerCount(channel);
ipcRenderer.removeListener(channel, listener);
Expand All @@ -41,24 +41,24 @@ const electronHandler = {
get(key: StoreKey) {
return ipcRenderer.sendSync(IPCChannelType.STORE_GET, key);
},
set(key: StoreKey, val: any) {
set(key: StoreKey, val: unknown) {
ipcRenderer.send(IPCChannelType.STORE_SET, key, val);
},
},
logger: {
log(...params: any[]) {
log(...params: unknown[]) {
ipcRenderer.send(IPCChannelType.LOG, params);
},
info(...params: any[]) {
info(...params: unknown[]) {
ipcRenderer.send(IPCChannelType.INFO, params);
},
debug(...params: any[]) {
debug(...params: unknown[]) {
ipcRenderer.send(IPCChannelType.DEBUG, params);
},
error(...params: any[]) {
error(...params: unknown[]) {
ipcRenderer.send(IPCChannelType.ERROR, params);
},
warn(...params: any[]) {
warn(...params: unknown[]) {
ipcRenderer.send(IPCChannelType.WARN, params);
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TransmitDataTable from "@/renderer//components/output/TransmitDataTable";
import MacroTree from "@/renderer/components/macros/MacroTree";
import MenuBar from "@/renderer/components/menu/MenuBar";
import clsx from "clsx";
import i18n from "i18next";
import { use } from "i18next";
import "primeflex/primeflex.scss";
import "primeicons/primeicons.css";
import "primereact/resources/primereact.min.css";
Expand All @@ -31,7 +31,7 @@ declare global {
}
}

i18n.use(initReactI18next).init({
use(initReactI18next).init({
resources: {
en: { translation: messageTextEn },
de: { translation: messageTextDe },
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/macros/MacroTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { MenuItem } from "primereact/menuitem";
import {
Tree,
TreeDragDropEvent,
TreeExpandedKeysType,
TreeNodeTemplateOptions,
TreeExpandedKeysType
} from "primereact/tree";
import { TreeNode } from "primereact/treenode";
import React, { useEffect, useRef, useState } from "react";
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/macros/MacroTreeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MacroTreeItem: React.FC<IMacroTreeItemProps> = ({
if (clickInTextField) setClickInTextField(false);
}, [clickForCommit]);

const onKeyPressed = (e: any) => {
const onKeyPressed = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'Enter') {
renameNode();
removeListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,45 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import BaudRateSelect from '@/renderer/components/tools/BaudRateSelect';
import PortSelect from '@/renderer/components/tools/PortSelect';
import { IDialogProps, ISelectValue, StoreKey } from '@minterm/types';
import { IDialogProps, SelectValue, StoreKey } from '@minterm/types';

const ConnectionSettingsDialog: React.FC<IDialogProps> = ({
id,
className,
display,
setDisplay,
}) => {
const dataBitsOptions: Array<ISelectValue> = [
const dataBitsOptions: Array<SelectValue> = [
{ name: '5', key: 5 },
{ name: '6', key: 6 },
{ name: '7', key: 7 },
{ name: '8', key: 8 },
];

const stopBitsOptions: Array<ISelectValue> = [
const stopBitsOptions: Array<SelectValue> = [
{ name: '1', key: 1 },
{ name: '1.5', key: 1.5 },
{ name: '2', key: 2 },
];

const parityOptions: Array<ISelectValue> = [
const parityOptions: Array<SelectValue> = [
{ name: 'None', key: 'None' },
{ name: 'Odd', key: 'Odd' },
{ name: 'Even', key: 'Even' },
{ name: 'Mark', key: 'Mark' },
{ name: 'Space', key: 'Space' },
];

const [dataBits, setDataBits] = useState<any>(
const [dataBits, setDataBits] = useState<number>(
window.electron.store.get(StoreKey.SERIALPORT_DATA_BITS)
);
const [stopBits, setStopBits] = useState<any>(
const [stopBits, setStopBits] = useState<number>(
window.electron.store.get(StoreKey.SERIALPORT_STOP_BITS)
);
const [lock, setLock] = useState<boolean>(
window.electron.store.get(StoreKey.SERIALPORT_LOCK)
);
const [parity, setParity] = useState<any>(
const [parity, setParity] = useState<string>(
window.electron.store.get(StoreKey.SERIALPORT_PARITY)
);
const [rtscts, setRtscts] = useState<boolean>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18n from 'i18next';
import i18n, { changeLanguage } from 'i18next';
import { Button } from 'primereact/button';
import { ConfirmDialog, confirmDialog } from 'primereact/confirmdialog';
import { Dialog } from 'primereact/dialog';
Expand All @@ -21,7 +21,7 @@ const GeneralSettingsDialog: React.FC<IDialogProps> = ({
const [isRestartNecessary, setIsRestartNecessary] = useState<boolean>(false);
const toast = useRef<Toast>(null);
const [selectedLanguage, setSelectedLanguage] = useState<string>(i18n.language);
const [selectedTheme, setSelectedTheme] = useState<any>(
const [selectedTheme, setSelectedTheme] = useState<string>(
window.electron.store.get(StoreKey.THEME)
);

Expand All @@ -42,7 +42,7 @@ const GeneralSettingsDialog: React.FC<IDialogProps> = ({

const onLanguageChange = (e: DropdownChangeEvent) => {
setSelectedLanguage(e.value);
i18n.changeLanguage(e.value);
changeLanguage(e.value);
};

const onHide = () => {
Expand All @@ -52,7 +52,7 @@ const GeneralSettingsDialog: React.FC<IDialogProps> = ({
const onCancel = () => {
onHide();
setSelectedTheme(window.electron.store.get(StoreKey.THEME));
i18n.changeLanguage(window.electron.store.get(StoreKey.LANGUAGE));
changeLanguage(window.electron.store.get(StoreKey.LANGUAGE));
setSelectedLanguage(window.electron.store.get(StoreKey.LANGUAGE));
setIsRestartNecessary(false);
};
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/menu/general/LanguageSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import i18n from 'i18next';
import { Dropdown, DropdownChangeEvent } from 'primereact/dropdown';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { IDefaultProps, ISelectValue } from '@minterm/types';
import { IDefaultProps, SelectValue } from '@minterm/types';

interface ILanguageSelectProps extends IDefaultProps {
selectedLanguage: string;
Expand All @@ -16,7 +16,7 @@ const LanguageSelect: React.FC<ILanguageSelectProps> = ({
onLanguageChange,
}) => {
const { t } = useTranslation();
const languages: Array<ISelectValue> = i18n.languages.map((e) => ({
const languages: Array<SelectValue> = i18n.languages.map((e) => ({
name: t(e.toUpperCase()),
key: e,
}));
Expand Down
20 changes: 10 additions & 10 deletions src/renderer/components/output/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { InputNumber } from 'primereact/inputnumber';
import { Tooltip } from 'primereact/tooltip';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { ConversionType, DataPointType, IDefaultProps } from '@minterm/types';
import { ConversionType, DataPointType } from '@minterm/types';
import ButtonClear from '../tools/ButtonClear';
import { typeToSelectList } from '@minterm/services';

export interface IActionBarProps extends IDefaultProps {
export interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
data?: Array<DataPointType>;
setData?: React.Dispatch<React.SetStateAction<any[]>>;
setData?: React.Dispatch<React.SetStateAction<unknown[]>>;
dataCounterHidden?: boolean;
dataCountLabel?: string;
selectedConversions?: ConversionType[];
Expand All @@ -30,11 +30,10 @@ export interface IActionBarProps extends IDefaultProps {
* outputting components. Therefore certain settings/actions will be displayed
* equally when reusing this component.
*
* @param IActionBarProps
* @param ActionBarProps
*/
const ActionBar: React.FC<IActionBarProps> = ({
const ActionBar: React.FC<ActionBarProps> = ({
id,
className,
data = [],
setData = () => {return;},
dataCounterHidden = true,
Expand All @@ -47,6 +46,7 @@ const ActionBar: React.FC<IActionBarProps> = ({
clearButtonToolTip = '',
saveButtonHidden = true,
onSave = () => {return;},
...props
}) => {
const { t } = useTranslation();

Expand All @@ -69,22 +69,22 @@ const ActionBar: React.FC<IActionBarProps> = ({
};

return (
<div id={`${id}:container`} className={className}>
<div id={`${id}:container`} {...props}>
<div className="p-checkbox h-2rem w-full" style={{ cursor: 'unset' }}>
<div className="p-checkbox h-2rem">
{!conversionsHidden &&
encodings.map((encoding) => {
return (
<div key={encoding.key} className="field-checkbox mr-2 mt-2">
<Checkbox
inputId={encoding.key}
inputId={encoding.key as string}
name="category"
value={encoding}
onChange={onEncodingChange}
disabled={conversionsDisabled}
checked={selectedConversions.includes(encoding.key)}
checked={selectedConversions.includes(encoding.key as ConversionType)}
/>
<label htmlFor={encoding.key}>{encoding.name}</label>
<label htmlFor={encoding.key as string}>{encoding.name}</label>
</div>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/output/ContextMenuOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import React, { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { DataPointType } from '@minterm/types';

interface IContextMenuOutputProps {
interface ContextMenuOutputProps {
selectedCells: Array<any>;
onContextMenu: React.MouseEvent<HTMLDivElement, MouseEvent>;
data: Array<DataPointType>;
}

const ContextMenuOutput: React.FC<IContextMenuOutputProps> = ({
const ContextMenuOutput: React.FC<ContextMenuOutputProps> = ({
data,
selectedCells,
onContextMenu,
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/components/output/OutputDataTableCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { DataTable, DataTableSelectionMultipleChangeEvent } from 'primereact/dat
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useResizeDetector } from 'react-resize-detector';
import { ConversionType, DataPointType } from '@minterm/types';
import ActionBar, { IActionBarProps } from './ActionBar';
import ActionBar, { ActionBarProps } from './ActionBar';

interface IOutputDataTableCoreProps extends IActionBarProps {
interface IOutputDataTableCoreProps extends ActionBarProps {
data: Array<DataPointType>;
setData?: React.Dispatch<React.SetStateAction<any[]>>;
setData?: React.Dispatch<React.SetStateAction<unknown[]>>;
width?: number;
selectedCells?: Array<any>;
setSelectedCells?: React.Dispatch<React.SetStateAction<any[]>>;
selectedCells?: Array<unknown>;
setSelectedCells?: React.Dispatch<React.SetStateAction<unknown[]>>;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/output/OutputTabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import OutputLineChart from './OutputLineChart';

const OutputTabView: React.FC<IDefaultProps> = ({ id, className }) => {
const { t } = useTranslation();
const [contextEvent, setContextEvent] = useState<any>();
const [contextEvent, setContextEvent] = useState<React.MouseEvent<HTMLDivElement, MouseEvent>>();
const { receivedData, setReceivedData } = useContext();
const [selectedCellsInTable, setSelectedCellsInTable] = useState<Array<any>>(
[]
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/output/OutputTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const OutputTextArea: React.FC<IOutputTextAreaProps> = ({
const { t } = useTranslation();
const [topScrollable, setTopScrollable] = useState<boolean>(false);
const [downScrollable, setDownScrollable] = useState<boolean>(false);
const { width, ref } = useResizeDetector({
const { ref } = useResizeDetector({
onResize: () => {
setScrollable();
},
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/output/TransmitDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import OutputDataTableCore from './OutputDataTableCore';
const TransmitDataTable: React.FC<IDefaultProps> = ({ id, className }) => {
const { t } = useTranslation();
const { transmittedData, setTransmittedData } = useContext();
const [contextEvent, setContextEvent] = useState<any>();
const [contextEvent, setContextEvent] = useState<React.MouseEvent<HTMLDivElement, MouseEvent>>();
const [selectedCells, setSelectedCells] = useState<Array<any>>([]);

const isContextEnabled = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/tools/BaudRateSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Dropdown } from 'primereact/dropdown';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useContext } from '@/renderer/context';
import { ISelectValue } from '@minterm/types';
import { SelectValue } from '@minterm/types';
import clsx from 'clsx';

const baudOptions: Array<ISelectValue> = [
const baudOptions: Array<SelectValue> = [
{ name: '110', key: '110' },
{ name: '300', key: '300' },
{ name: '1200', key: '1200' },
Expand Down
Loading

0 comments on commit c1f0bb8

Please sign in to comment.