mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
typing cleanup
This commit is contained in:
@@ -48,6 +48,8 @@
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-namespace": "off",
|
||||
"@typescript-eslint/no-empty-interface": [
|
||||
"error",
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { Button, chakra, Icon, Stack, Text, VStack } from '@chakra-ui/react';
|
||||
import { Button, chakra, Stack, Text, VStack } from '@chakra-ui/react';
|
||||
import { useConfig, useColorValue } from '~/context';
|
||||
import { useStrf, useLGState, useDNSQuery } from '~/hooks';
|
||||
|
||||
@@ -24,7 +24,7 @@ function findAnswer(data: DnsOverHttps.Response | undefined): string {
|
||||
return answer;
|
||||
}
|
||||
|
||||
export const ResolvedTarget = (props: TResolvedTarget) => {
|
||||
export const ResolvedTarget: React.FC<TResolvedTarget> = (props: TResolvedTarget) => {
|
||||
const { setTarget, errorClose } = props;
|
||||
const { web } = useConfig();
|
||||
const { displayTarget, isSubmitting, families, queryTarget } = useLGState();
|
||||
|
@@ -31,6 +31,7 @@ type MDProps = {
|
||||
node: Dict;
|
||||
};
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any: off */
|
||||
function hasNode<C>(p: any): p is C & MDProps {
|
||||
return 'node' in p;
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useConfig } from '~/context';
|
||||
import { flatten } from '~/util';
|
||||
|
||||
import type { TDevice } from '~/types';
|
||||
import type { TUseDevice } from './types';
|
||||
@@ -11,7 +10,7 @@ import type { TUseDevice } from './types';
|
||||
export function useDevice(): TUseDevice {
|
||||
const { networks } = useConfig();
|
||||
|
||||
const devices = useMemo(() => flatten<TDevice>(networks.map(n => n.locations)), []);
|
||||
const devices = useMemo(() => networks.map(n => n.locations).flat(), []);
|
||||
|
||||
function getDevice(id: string): TDevice {
|
||||
return devices.filter(dev => dev.name === id)[0];
|
||||
|
@@ -87,7 +87,7 @@ export function useTableToString(
|
||||
const [header, accessor, align] = field;
|
||||
if (align !== null) {
|
||||
let value = route[accessor];
|
||||
const fmtFunc = getFmtFunc(accessor);
|
||||
const fmtFunc = getFmtFunc(accessor) as (v: typeof value) => string;
|
||||
value = fmtFunc(value);
|
||||
if (accessor === 'prefix') {
|
||||
tableStringParts.push(` - ${header}: ${value}`);
|
||||
|
@@ -17,7 +17,6 @@ class MyDocument extends Document {
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="true" />
|
||||
</Head>
|
||||
<body>
|
||||
<script src="noflash.js" />
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import type { State, InferredStateKeysType } from '@hookstate/core';
|
||||
/* eslint @typescript-eslint/explicit-module-boundary-types: off */
|
||||
/* eslint @typescript-eslint/no-explicit-any: off */
|
||||
import type { State } from '@hookstate/core';
|
||||
import type { TValidQueryTypes, TStringTableData, TQueryResponseString } from './data';
|
||||
import type { TSelectOption } from './common';
|
||||
import type { TQueryContent } from './config';
|
||||
|
||||
export function isQueryType(q: any): q is TValidQueryTypes {
|
||||
export function isQueryType(q: unknown): q is TValidQueryTypes {
|
||||
let result = false;
|
||||
if (
|
||||
typeof q === 'string' &&
|
||||
@@ -14,7 +16,7 @@ export function isQueryType(q: any): q is TValidQueryTypes {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function isString(a: any): a is string {
|
||||
export function isString(a: unknown): a is string {
|
||||
return typeof a === 'string';
|
||||
}
|
||||
|
||||
|
2
hyperglass/ui/types/react-table-config.d.ts
vendored
2
hyperglass/ui/types/react-table-config.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
/* eslint-disable */
|
||||
|
||||
import type {
|
||||
TableInstance,
|
||||
UseSortByHooks,
|
||||
|
@@ -7,12 +7,6 @@ export function all<I extends unknown>(...iter: I[]): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function flatten<T extends unknown>(arr: any[][]): T[] {
|
||||
return arr.reduce(function (flat, toFlatten) {
|
||||
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
|
||||
}, []);
|
||||
}
|
||||
|
||||
export function chunkArray<A extends unknown>(array: A[], size: number): A[][] {
|
||||
const result = [] as A[][];
|
||||
for (let i = 0; i < array.length; i += size) {
|
||||
|
@@ -34,11 +34,11 @@ const defaultMonoFonts = [
|
||||
'monospace',
|
||||
];
|
||||
|
||||
export function isLight(color: string) {
|
||||
export function isLight(color: string): boolean {
|
||||
return readableColorIsBlack(color);
|
||||
}
|
||||
|
||||
export function isDark(color: string) {
|
||||
export function isDark(color: string): boolean {
|
||||
return !readableColorIsBlack(color);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user