Fix all lint errors

This commit is contained in:
Gregory Schier
2024-09-16 08:36:02 -07:00
parent 974ecd511d
commit 2951023ee8
19 changed files with 43 additions and 34 deletions
+1
View File
@@ -19,6 +19,7 @@ module.exports = {
'src-tauri/**/*', 'src-tauri/**/*',
'plugins/**/*', 'plugins/**/*',
'tailwind.config.cjs', 'tailwind.config.cjs',
'vite.config.ts',
], ],
settings: { settings: {
react: { react: {
+1 -1
View File
@@ -89,7 +89,7 @@
"react-devtools": "^5.3.1", "react-devtools": "^5.3.1",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"tailwindcss": "^3.4.10", "tailwindcss": "^3.4.10",
"typescript": "^5.6.2", "typescript": "^5.6.0",
"vite": "^5.4.4", "vite": "^5.4.4",
"vite-plugin-static-copy": "^1.0.6", "vite-plugin-static-copy": "^1.0.6",
"vite-plugin-svgr": "^4.2.0", "vite-plugin-svgr": "^4.2.0",
+1 -1
View File
@@ -108,7 +108,7 @@
"react-devtools": "^5.3.1", "react-devtools": "^5.3.1",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"tailwindcss": "^3.4.10", "tailwindcss": "^3.4.10",
"typescript": "^5.6.2", "typescript": "^5.6.0",
"vite": "^5.4.4", "vite": "^5.4.4",
"vite-plugin-static-copy": "^1.0.6", "vite-plugin-static-copy": "^1.0.6",
"vite-plugin-svgr": "^4.2.0", "vite-plugin-svgr": "^4.2.0",
+1 -1
View File
@@ -20,6 +20,6 @@
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"ts-proto": "^2.2.0", "ts-proto": "^2.2.0",
"typescript": "^5.6.2" "typescript": "^5.6.0"
} }
} }
+1
View File
@@ -89,6 +89,7 @@ export function ExportDataDialog({
} }
/> />
</td> </td>
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions,jsx-a11y/click-events-have-key-events */}
<td <td
className="py-1 pl-4 text whitespace-nowrap overflow-x-auto hide-scrollbars" className="py-1 pl-4 text whitespace-nowrap overflow-x-auto hide-scrollbars"
onClick={() => setSelectedWorkspaces((prev) => ({ ...prev, [w.id]: !prev[w.id] }))} onClick={() => setSelectedWorkspaces((prev) => ({ ...prev, [w.id]: !prev[w.id] }))}
+3
View File
@@ -37,6 +37,7 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
const variables = p.variables; const variables = p.variables;
const operationName = p.operationName; const operationName = p.operationName;
return { query, variables, operationName }; return { query, variables, operationName };
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) { } catch (err) {
return { query: '' }; return { query: '' };
} }
@@ -46,6 +47,7 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
(b: GraphQLBody) => { (b: GraphQLBody) => {
try { try {
onChange?.(JSON.stringify(b, null, 2)); onChange?.(JSON.stringify(b, null, 2));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) { } catch (err) {
// Meh, not much we can do here // Meh, not much we can do here
} }
@@ -62,6 +64,7 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
(variables: string) => { (variables: string) => {
try { try {
handleChange({ query, variables: JSON.parse(variables || '{}') }); handleChange({ query, variables: JSON.parse(variables || '{}') });
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) { } catch (err) {
// Don't do anything if invalid JSON. The user probably hasn't finished // Don't do anything if invalid JSON. The user probably hasn't finished
// typing yet. // typing yet.
+15 -13
View File
@@ -6,8 +6,10 @@ import {
handleRefresh, handleRefresh,
jsonCompletion, jsonCompletion,
jsonSchemaLinter, jsonSchemaLinter,
updateSchema, // eslint-disable-next-line import/named
stateExtensions, stateExtensions,
// eslint-disable-next-line import/named
updateSchema,
} from 'codemirror-json-schema'; } from 'codemirror-json-schema';
import { useEffect, useMemo, useRef } from 'react'; import { useEffect, useMemo, useRef } from 'react';
import { useAlert } from '../hooks/useAlert'; import { useAlert } from '../hooks/useAlert';
@@ -136,10 +138,10 @@ export function GrpcEditor({
reflectionLoading reflectionLoading
? 'secondary' ? 'secondary'
: reflectionUnavailable : reflectionUnavailable
? 'info' ? 'info'
: reflectionError : reflectionError
? 'danger' ? 'danger'
: 'secondary' : 'secondary'
} }
isLoading={reflectionLoading} isLoading={reflectionLoading}
onClick={() => { onClick={() => {
@@ -160,14 +162,14 @@ export function GrpcEditor({
{reflectionLoading {reflectionLoading
? 'Inspecting Schema' ? 'Inspecting Schema'
: reflectionUnavailable : reflectionUnavailable
? 'Select Proto Files' ? 'Select Proto Files'
: reflectionError : reflectionError
? 'Server Error' ? 'Server Error'
: protoFiles.length > 0 : protoFiles.length > 0
? count('File', protoFiles.length) ? count('File', protoFiles.length)
: services != null && protoFiles.length === 0 : services != null && protoFiles.length === 0
? 'Schema Detected' ? 'Schema Detected'
: 'Select Schema'} : 'Select Schema'}
</Button> </Button>
</div>, </div>,
], ],
+1 -1
View File
@@ -40,7 +40,7 @@ export function ImportCurlButton() {
await clear(); // Clear the clipboard so the button goes away await clear(); // Clear the clipboard so the button goes away
setClipboardText(''); setClipboardText('');
} catch (e) { } catch (e) {
// Nothing console.log('Failed to import curl', e);
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
@@ -88,7 +88,6 @@ export function SettingsPlugins() {
function PluginInfo({ plugin }: { plugin: Plugin }) { function PluginInfo({ plugin }: { plugin: Plugin }) {
const pluginInfo = usePluginInfo(plugin.id); const pluginInfo = usePluginInfo(plugin.id);
if (pluginInfo.data == null) return null;
return ( return (
<tr className="group"> <tr className="group">
<td className="pr-2"> <td className="pr-2">
+4 -5
View File
@@ -243,7 +243,7 @@ export function Sidebar({ className }: Props) {
await setHidden(false); await setHidden(false);
} }
// Select 0 index on focus if none selected // Select 0th index on focus if none selected
focusActiveRequest( focusActiveRequest(
selectedTree != null && selectedId != null selectedTree != null && selectedId != null
? { forced: { id: selectedId, tree: selectedTree } } ? { forced: { id: selectedId, tree: selectedTree } }
@@ -310,7 +310,7 @@ export function Sidebar({ className }: Props) {
let hoveredIndex = dragIndex + (side === 'above' ? 0 : 1); let hoveredIndex = dragIndex + (side === 'above' ? 0 : 1);
if (hoveredItem?.model === 'folder' && side === 'below' && !isCollapsed(hoveredItem.id)) { if (hoveredItem?.model === 'folder' && side === 'below' && !isCollapsed(hoveredItem.id)) {
// Move into folder if it's open and we're moving below it // Move into the folder if it's open and we're moving below it
hoveredTree = hoveredTree?.children.find((n) => n.item.id === id) ?? null; hoveredTree = hoveredTree?.children.find((n) => n.item.id === id) ?? null;
hoveredIndex = 0; hoveredIndex = 0;
} }
@@ -814,11 +814,10 @@ function SidebarItem({
hotKeyAction: 'http_request.duplicate', hotKeyAction: 'http_request.duplicate',
hotKeyLabelOnly: true, // Would trigger for every request (bad) hotKeyLabelOnly: true, // Would trigger for every request (bad)
leftSlot: <Icon icon="copy" />, leftSlot: <Icon icon="copy" />,
onSelect: () => { onSelect: () =>
itemModel === 'http_request' itemModel === 'http_request'
? duplicateHttpRequest.mutate() ? duplicateHttpRequest.mutate()
: duplicateGrpcRequest.mutate(); : duplicateGrpcRequest.mutate(),
},
}, },
{ {
key: 'moveWorkspace', key: 'moveWorkspace',
+2 -1
View File
@@ -55,7 +55,8 @@ export const UrlBar = memo(function UrlBar({
const handleSubmit = (e: FormEvent<HTMLFormElement>) => { const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault(); e.preventDefault();
isLoading ? onCancel() : onSend(); if (isLoading) onCancel();
else onSend();
}; };
return ( return (
@@ -16,7 +16,8 @@ export function JsonViewer({ response, className }: Props) {
let parsed = {}; let parsed = {};
try { try {
parsed = JSON.parse(rawBody.data); parsed = JSON.parse(rawBody.data);
} catch (e) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// Nothing yet // Nothing yet
} }
+1 -2
View File
@@ -47,11 +47,10 @@ export function useGrpc(
}); });
const debouncedUrl = useDebouncedValue<string>(req?.url ?? '', 1000); const debouncedUrl = useDebouncedValue<string>(req?.url ?? '', 1000);
const debouncedMessage = useDebouncedValue<string>(req?.message ?? '', 1000);
const reflect = useQuery<ReflectResponseService[], string>({ const reflect = useQuery<ReflectResponseService[], string>({
enabled: req != null, enabled: req != null,
queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl, debouncedMessage, protoFiles], queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl, protoFiles],
queryFn: async () => queryFn: async () =>
(await minPromiseMillis( (await minPromiseMillis(
invokeCmd('cmd_grpc_reflect', { requestId, protoFiles }), invokeCmd('cmd_grpc_reflect', { requestId, protoFiles }),
+1 -2
View File
@@ -14,8 +14,7 @@ export function keyValueQueryKey({
return ['key_value', { namespace, key: buildKeyValueKey(key) }]; return ['key_value', { namespace, key: buildKeyValueKey(key) }];
} }
// eslint-disable-next-line @typescript-eslint/ban-types export function useKeyValue<T extends object | boolean | number | string | null>({
export function useKeyValue<T extends Object | null>({
namespace = DEFAULT_NAMESPACE, namespace = DEFAULT_NAMESPACE,
key, key,
fallback, fallback,
+2 -1
View File
@@ -19,7 +19,8 @@ export function isJSON(text: string): boolean {
try { try {
JSON.parse(text); JSON.parse(text);
return true; return true;
} catch (_) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
return false; return false;
} }
} }
+4 -2
View File
@@ -8,7 +8,8 @@ export function tryFormatJson(text: string, pretty = true): string {
try { try {
if (pretty) return JSON.stringify(JSON.parse(text), null, INDENT); if (pretty) return JSON.stringify(JSON.parse(text), null, INDENT);
else return JSON.stringify(JSON.parse(text)); else return JSON.stringify(JSON.parse(text));
} catch (_) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
return text; return text;
} }
} }
@@ -18,7 +19,8 @@ export function tryFormatXml(text: string): string {
try { try {
return xmlFormat(text, { throwOnFailure: true, strictMode: false, indentation: INDENT }); return xmlFormat(text, { throwOnFailure: true, strictMode: false, indentation: INDENT });
} catch (_) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
return text; return text;
} }
} }
+1
View File
@@ -49,6 +49,7 @@ export function extractKeyValue<T>(kv: KeyValue | null): T | undefined {
try { try {
return JSON.parse(kv.value) as T; return JSON.parse(kv.value) as T;
} catch (err) { } catch (err) {
console.log('Failed to parse kv value', kv.value, err);
return undefined; return undefined;
} }
} }
+2 -1
View File
@@ -9,7 +9,8 @@ export async function getResponseBodyText(response: HttpResponse): Promise<strin
try { try {
return new TextDecoder(charset ?? 'utf-8', { fatal: true }).decode(bytes); return new TextDecoder(charset ?? 'utf-8', { fatal: true }).decode(bytes);
} catch (_) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
// Failed to decode as text, so return null // Failed to decode as text, so return null
return null; return null;
} }
-1
View File
@@ -20,7 +20,6 @@
"include": [ "include": [
"src-web", "src-web",
"src-web/modules.d.ts", "src-web/modules.d.ts",
"vite.config.ts"
], ],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }