Skip to content

Commit 090626f

Browse files
committed
typing cleanup
1 parent 4137286 commit 090626f

10 files changed

Lines changed: 16 additions & 17 deletions

File tree

hyperglass/ui/.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"@typescript-eslint/no-inferrable-types": "off",
4949
"@typescript-eslint/explicit-function-return-type": "off",
5050
"@typescript-eslint/no-var-requires": "off",
51+
"@typescript-eslint/no-non-null-assertion": "off",
52+
"@typescript-eslint/no-namespace": "off",
5153
"@typescript-eslint/no-empty-interface": [
5254
"error",
5355
{

hyperglass/ui/components/form/resolvedTarget.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useMemo } from 'react';
22
import dynamic from 'next/dynamic';
3-
import { Button, chakra, Icon, Stack, Text, VStack } from '@chakra-ui/react';
3+
import { Button, chakra, Stack, Text, VStack } from '@chakra-ui/react';
44
import { useConfig, useColorValue } from '~/context';
55
import { useStrf, useLGState, useDNSQuery } from '~/hooks';
66

@@ -24,7 +24,7 @@ function findAnswer(data: DnsOverHttps.Response | undefined): string {
2424
return answer;
2525
}
2626

27-
export const ResolvedTarget = (props: TResolvedTarget) => {
27+
export const ResolvedTarget: React.FC<TResolvedTarget> = (props: TResolvedTarget) => {
2828
const { setTarget, errorClose } = props;
2929
const { web } = useConfig();
3030
const { displayTarget, isSubmitting, families, queryTarget } = useLGState();

hyperglass/ui/components/markdown/elements.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type MDProps = {
3131
node: Dict;
3232
};
3333

34+
/* eslint @typescript-eslint/no-explicit-any: off */
3435
function hasNode<C>(p: any): p is C & MDProps {
3536
return 'node' in p;
3637
}

hyperglass/ui/hooks/useDevice.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useCallback, useMemo } from 'react';
22
import { useConfig } from '~/context';
3-
import { flatten } from '~/util';
43

54
import type { TDevice } from '~/types';
65
import type { TUseDevice } from './types';
@@ -11,7 +10,7 @@ import type { TUseDevice } from './types';
1110
export function useDevice(): TUseDevice {
1211
const { networks } = useConfig();
1312

14-
const devices = useMemo(() => flatten<TDevice>(networks.map(n => n.locations)), []);
13+
const devices = useMemo(() => networks.map(n => n.locations).flat(), []);
1514

1615
function getDevice(id: string): TDevice {
1716
return devices.filter(dev => dev.name === id)[0];

hyperglass/ui/hooks/useTableToString.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function useTableToString(
8787
const [header, accessor, align] = field;
8888
if (align !== null) {
8989
let value = route[accessor];
90-
const fmtFunc = getFmtFunc(accessor);
90+
const fmtFunc = getFmtFunc(accessor) as (v: typeof value) => string;
9191
value = fmtFunc(value);
9292
if (accessor === 'prefix') {
9393
tableStringParts.push(` - ${header}: ${value}`);

hyperglass/ui/pages/_document.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class MyDocument extends Document {
1717
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />
1818
</Head>
1919
<body>
20-
<script src="noflash.js" />
2120
<Main />
2221
<NextScript />
2322
</body>

hyperglass/ui/types/guards.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import type { State, InferredStateKeysType } from '@hookstate/core';
1+
/* eslint @typescript-eslint/explicit-module-boundary-types: off */
2+
/* eslint @typescript-eslint/no-explicit-any: off */
3+
import type { State } from '@hookstate/core';
24
import type { TValidQueryTypes, TStringTableData, TQueryResponseString } from './data';
35
import type { TSelectOption } from './common';
46
import type { TQueryContent } from './config';
57

6-
export function isQueryType(q: any): q is TValidQueryTypes {
8+
export function isQueryType(q: unknown): q is TValidQueryTypes {
79
let result = false;
810
if (
911
typeof q === 'string' &&
@@ -14,7 +16,7 @@ export function isQueryType(q: any): q is TValidQueryTypes {
1416
return result;
1517
}
1618

17-
export function isString(a: any): a is string {
19+
export function isString(a: unknown): a is string {
1820
return typeof a === 'string';
1921
}
2022

hyperglass/ui/types/react-table-config.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable */
2+
13
import type {
24
TableInstance,
35
UseSortByHooks,

hyperglass/ui/util/common.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ export function all<I extends unknown>(...iter: I[]): boolean {
77
return true;
88
}
99

10-
export function flatten<T extends unknown>(arr: any[][]): T[] {
11-
return arr.reduce(function (flat, toFlatten) {
12-
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
13-
}, []);
14-
}
15-
1610
export function chunkArray<A extends unknown>(array: A[], size: number): A[][] {
1711
const result = [] as A[][];
1812
for (let i = 0; i < array.length; i += size) {

hyperglass/ui/util/theme.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ const defaultMonoFonts = [
3434
'monospace',
3535
];
3636

37-
export function isLight(color: string) {
37+
export function isLight(color: string): boolean {
3838
return readableColorIsBlack(color);
3939
}
4040

41-
export function isDark(color: string) {
41+
export function isDark(color: string): boolean {
4242
return !readableColorIsBlack(color);
4343
}
4444

0 commit comments

Comments
 (0)