More eslint fixes

This commit is contained in:
Gregory Schier
2023-04-01 15:48:37 -07:00
parent 49856bb6f7
commit 03b35beae4
8 changed files with 34 additions and 20 deletions

View File

@@ -8,6 +8,10 @@ module.exports = {
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"eslint-config-prettier" "eslint-config-prettier"
], ],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.json'],
},
ignorePatterns: ["src-tauri/**/*"], ignorePatterns: ["src-tauri/**/*"],
settings: { settings: {
react: { react: {
@@ -16,13 +20,14 @@ module.exports = {
"import/resolver": { "import/resolver": {
node: { node: {
paths: ["src-web"], paths: ["src-web"],
extensions: [".js", ".jsx", ".ts", ".tsx"] extensions: [".ts", ".tsx"]
} }
} }
}, },
rules: { rules: {
"jsx-a11y/no-autofocus": "warn", "jsx-a11y/no-autofocus": "warn",
"react/react-in-jsx-scope": "off", "react/react-in-jsx-scope": "off",
"import/no-unresolved": "off",
"@typescript-eslint/consistent-type-imports": ["error", { "@typescript-eslint/consistent-type-imports": ["error", {
prefer: "type-imports", prefer: "type-imports",
disallowTypeAnnotations: true, disallowTypeAnnotations: true,

15
package-lock.json generated
View File

@@ -49,7 +49,8 @@
"@types/node": "^18.7.10", "@types/node": "^18.7.10",
"@types/parse-color": "^1.0.1", "@types/parse-color": "^1.0.1",
"@types/parse-json": "^4.0.0", "@types/parse-json": "^4.0.0",
"@types/react-dom": "^18.0.6", "@types/react": "^18.0.31",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1", "@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0", "@typescript-eslint/parser": "^5.57.0",
@@ -2135,9 +2136,9 @@
"devOptional": true "devOptional": true
}, },
"node_modules/@types/react": { "node_modules/@types/react": {
"version": "18.0.28", "version": "18.0.31",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.31.tgz",
"integrity": "sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==", "integrity": "sha512-EEG67of7DsvRDU6BLLI0p+k1GojDLz9+lZsnCpCRTa/lOokvyPBvp8S5x+A24hME3yyQuIipcP70KJ6H7Qupww==",
"devOptional": true, "devOptional": true,
"dependencies": { "dependencies": {
"@types/prop-types": "*", "@types/prop-types": "*",
@@ -8842,9 +8843,9 @@
"devOptional": true "devOptional": true
}, },
"@types/react": { "@types/react": {
"version": "18.0.28", "version": "18.0.31",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.31.tgz",
"integrity": "sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==", "integrity": "sha512-EEG67of7DsvRDU6BLLI0p+k1GojDLz9+lZsnCpCRTa/lOokvyPBvp8S5x+A24hME3yyQuIipcP70KJ6H7Qupww==",
"devOptional": true, "devOptional": true,
"requires": { "requires": {
"@types/prop-types": "*", "@types/prop-types": "*",

View File

@@ -56,7 +56,8 @@
"@types/node": "^18.7.10", "@types/node": "^18.7.10",
"@types/parse-color": "^1.0.1", "@types/parse-color": "^1.0.1",
"@types/parse-json": "^4.0.0", "@types/parse-json": "^4.0.0",
"@types/react-dom": "^18.0.6", "@types/react": "^18.0.31",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1", "@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0", "@typescript-eslint/parser": "^5.57.0",

View File

@@ -22,7 +22,7 @@ interface GraphQLBody {
export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEditorProps }: Props) { export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEditorProps }: Props) {
const { query, variables } = useMemo<GraphQLBody>(() => { const { query, variables } = useMemo<GraphQLBody>(() => {
if (!defaultValue) { if (defaultValue === undefined) {
return { query: '', variables: {} }; return { query: '', variables: {} };
} }
try { try {
@@ -61,6 +61,11 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
// Refetch the schema when the URL changes // Refetch the schema when the URL changes
useEffect(() => { useEffect(() => {
// First, clear the schema
if (editorViewRef.current) {
updateSchema(editorViewRef.current, undefined);
}
let unmounted = false; let unmounted = false;
const body = JSON.stringify({ const body = JSON.stringify({
query: getIntrospectionQuery(), query: getIntrospectionQuery(),
@@ -76,14 +81,15 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
updateSchema(editorViewRef.current, schema); updateSchema(editorViewRef.current, schema);
} catch (err) { } catch (err) {
console.log('Failed to parse introspection query', err); console.log('Failed to parse introspection query', err);
updateSchema(editorViewRef.current, undefined);
return;
} }
}); });
return () => { return () => {
unmounted = true; unmounted = true;
}; };
}, [baseRequest, baseRequest.url]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [baseRequest.url]);
return ( return (
<div className="pb-2 h-full grid grid-rows-[minmax(0,100%)_auto_auto_minmax(0,auto)]"> <div className="pb-2 h-full grid grid-rows-[minmax(0,100%)_auto_auto_minmax(0,auto)]">

View File

@@ -25,7 +25,7 @@ export const HStack = forwardRef(function HStack(
return ( return (
<BaseStack <BaseStack
ref={ref} ref={ref}
className={classnames(className, 'flex-row', space && gapClasses[space])} className={classnames(className, 'flex-row', space != null && gapClasses[space])}
{...props} {...props}
> >
{children} {children}
@@ -45,7 +45,7 @@ export const VStack = forwardRef(function VStack(
return ( return (
<BaseStack <BaseStack
ref={ref} ref={ref}
className={classnames(className, 'flex-col', space && gapClasses[space])} className={classnames(className, 'flex-col', space != null && gapClasses[space])}
{...props} {...props}
> >
{children} {children}

View File

@@ -6,11 +6,11 @@ export function useDeleteResponses(requestId?: string) {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation({ return useMutation({
mutationFn: async () => { mutationFn: async () => {
if (!requestId) return; if (requestId === undefined) return;
await invoke('delete_all_responses', { requestId }); await invoke('delete_all_responses', { requestId });
}, },
onSuccess: async () => { onSuccess: async () => {
if (!requestId) return; if (requestId === undefined) return;
queryClient.setQueryData(responsesQueryKey({ requestId }), []); queryClient.setQueryData(responsesQueryKey({ requestId }), []);
}, },
}); });

View File

@@ -1,5 +1,5 @@
import { StrictMode } from 'react'; import { StrictMode } from 'react';
import ReactDOM from 'react-dom/client'; import { createRoot } from 'react-dom/client';
import { App } from './components/App'; import { App } from './components/App';
import { getKeyValue } from './lib/keyValueStore'; import { getKeyValue } from './lib/keyValueStore';
import { syncLastLocation } from './lib/lastLocation'; import { syncLastLocation } from './lib/lastLocation';
@@ -10,7 +10,7 @@ setAppearance(await getKeyValue({ key: 'appearance', fallback: getPreferredAppea
await syncLastLocation(); await syncLastLocation();
// root holds our app's root DOM Element: // root holds our app's root DOM Element:
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( createRoot(document.getElementById('root') as HTMLElement).render(
<StrictMode> <StrictMode>
<App /> <App />
</StrictMode>, </StrictMode>,

View File

@@ -18,7 +18,8 @@
"jsx": "react-jsx" "jsx": "react-jsx"
}, },
"include": [ "include": [
"src-web" "src-web",
"vite.config.ts"
], ],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }