Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type checking to husky pre commit #543

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged

yarn typecheck
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"start:renderer": "cross-env NODE_ENV=development webpack serve --config ./.erb/configs/webpack.config.renderer.dev.babel.js",
"test": "jest --passWithNoTests",
"gql-codegen": "graphql-codegen --config codegen.yml && yarn lint:fix",
"prepare": "husky install"
"prepare": "husky install",
"typecheck": "tsc --project tsconfig.json --noEmit --skipLibCheck"
},
"author": {
"name": "ExpressLRS Configurator Contributors",
Expand Down
1 change: 1 addition & 0 deletions src/@types/bluejay-rtttl-parse.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'bluejay-rtttl-parse';
5 changes: 5 additions & 0 deletions src/@types/svg.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.svg' {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const content: any;
export default content;
}
2 changes: 1 addition & 1 deletion src/ui/components/BuildResponse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface BuildResponseProps {
}

const BuildResponse: FunctionComponent<BuildResponseProps> = memo(
({ response, firmwareVersionData }) => {
({ response }) => {
const { t } = useTranslation();

const toTitle = (errorType: BuildFirmwareErrorType | undefined): string => {
Expand Down
3 changes: 2 additions & 1 deletion src/ui/components/Loader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ interface LoaderProps {
}

const Loader: FunctionComponent<LoaderProps> = ({ loading, sx = {} }) => {
const sxStyle = { ...styles.root, ...sx };
return loading ? (
<Box sx={{ ...styles.root, ...sx }}>
<Box sx={sxStyle}>
<CircularProgress />
</Box>
) : null;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/SerialConnectionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const styles: Record<string, SxProps<Theme>> = {
interface SerialConnectionFormProps {
serialDevice: string | null;
baudRate: number;
onConnect: (serialDevice: string | null, baudRate: number) => void;
onConnect: (serialDevice: string, baudRate: number) => void;
}

const SerialConnectionForm: FunctionComponent<SerialConnectionFormProps> = (
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/ShowAfterTimeout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { FunctionComponent, useEffect, useRef, useState } from 'react';
interface ShowAfterTimeoutProps {
timeout: number;
active: boolean;
children?: React.ReactNode;
children?: React.ReactElement;
}

const ShowAfterTimeout: FunctionComponent<ShowAfterTimeoutProps> = ({
Expand Down Expand Up @@ -32,7 +32,7 @@ const ShowAfterTimeout: FunctionComponent<ShowAfterTimeoutProps> = ({
}
};
}, [active, timeout]);
return visible ? props.children : null;
return visible && props.children ? props.children : null;
};

export default ShowAfterTimeout;
62 changes: 33 additions & 29 deletions src/ui/components/WifiDeviceNotification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,40 @@ const WifiDeviceNotification: FunctionComponent<WifiDeviceNotificationProps> = (
const { appStatus } = useAppState();
const { t } = useTranslation();

return appStatus === AppStatus.Interactive
? newNetworkDevices.map((dnsDevice) => {
const handleClose = () => {
removeDeviceFromNewList(dnsDevice.name);
};
const result =
appStatus === AppStatus.Interactive
? newNetworkDevices.map((dnsDevice) => {
const handleClose = () => {
removeDeviceFromNewList(dnsDevice.name);
};

return (
<Snackbar
key={dnsDevice.name}
open
autoHideDuration={6000}
onClose={handleClose}
>
<Alert onClose={handleClose} severity="info">
{t('WifiDeviceNotification.NewDevice')} {dnsDevice.name} (
{dnsDevice.ip})
<Button
size="small"
onClick={() => {
onDeviceChange(dnsDevice);
removeDeviceFromNewList(dnsDevice.name);
}}
>
{t('WifiDeviceNotification.Select')}
</Button>
</Alert>
</Snackbar>
);
})
: null;
return (
<Snackbar
key={dnsDevice.name}
open
autoHideDuration={6000}
onClose={handleClose}
>
<Alert onClose={handleClose} severity="info">
{t('WifiDeviceNotification.NewDevice')} {dnsDevice.name} (
{dnsDevice.ip})
<Button
size="small"
onClick={() => {
onDeviceChange(dnsDevice);
removeDeviceFromNewList(dnsDevice.name);
}}
>
{t('WifiDeviceNotification.Select')}
</Button>
</Alert>
</Snackbar>
);
})
: null;

// eslint-disable-next-line react/jsx-no-useless-fragment
return <>{result}</>;
};

export default WifiDeviceNotification;
30 changes: 16 additions & 14 deletions src/ui/views/ConfiguratorView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,20 +1160,22 @@ const ConfiguratorView: FunctionComponent<ConfiguratorViewProps> = (props) => {
}
active={!buildInProgress}
>
<Box sx={styles.buildNotification}>
<BuildResponse
response={response?.buildFlashFirmware}
firmwareVersionData={firmwareVersionData}
/>
</Box>
{response?.buildFlashFirmware?.success && hasLuaScript && (
<Alert sx={styles.buildNotification} severity="info">
<AlertTitle>
{t('ConfiguratorView.UpdateLuaScript')}
</AlertTitle>
{t('ConfiguratorView.UpdateLuaScriptOnRadio')}
</Alert>
)}
<>
<Box sx={styles.buildNotification}>
<BuildResponse
response={response?.buildFlashFirmware}
firmwareVersionData={firmwareVersionData}
/>
</Box>
{response?.buildFlashFirmware?.success && hasLuaScript && (
<Alert sx={styles.buildNotification} severity="info">
<AlertTitle>
{t('ConfiguratorView.UpdateLuaScript')}
</AlertTitle>
{t('ConfiguratorView.UpdateLuaScriptOnRadio')}
</Alert>
)}
</>
</ShowAfterTimeout>
{response?.buildFlashFirmware?.success &&
currentJobType === BuildJobType.Build && (
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/SerialMonitorView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const SerialMonitorView: FunctionComponent = () => {
connectToSerialDeviceMutation,
{ loading: connectInProgress, data: response, error: connectError },
] = useConnectToSerialDeviceMutation();
const onConnect = (newSerialDevice: string | null, newBaudRate: number) => {
const onConnect = (newSerialDevice: string, newBaudRate: number) => {
setSerialDevice(newSerialDevice);
setBaudRate(newBaudRate);
setLogs('');
Expand Down
11 changes: 3 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"emitDecoratorMetadata": true,
"target": "ES2018",
"module": "CommonJS",
"lib": [
"dom",
"esnext"
],
"lib": ["dom", "esnext"],
"declaration": true,
"declarationMap": true,
"noEmit": true,
Expand All @@ -27,10 +24,8 @@
"resolveJsonModule": true,
"allowJs": true
},
"typeRoots": [
"node_modules/@types",
"src/@types"
],
"typeRoots": ["node_modules/@types", "src/@types"],
"include": ["src/**/*"],
"exclude": [
"test",
"release",
Expand Down