mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-01-15 00:58:02 -05:00
chore(ui): finish eslint v9 migration
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
import { PropsWithChildren, memo, useEffect } from 'react';
|
||||
import { modelChanged } from '../src/features/controlLayers/store/paramsSlice';
|
||||
import { useAppDispatch } from '../src/app/store/storeHooks';
|
||||
import { useGlobalModifiersInit } from '@invoke-ai/ui-library';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { memo, useEffect } from 'react';
|
||||
|
||||
import { useAppDispatch } from '../src/app/store/storeHooks';
|
||||
import { modelChanged } from '../src/features/controlLayers/store/paramsSlice';
|
||||
/**
|
||||
* Initializes some state for storybook. Must be in a different component
|
||||
* so that it is run inside the redux context.
|
||||
*/
|
||||
export const ReduxInit = memo((props: PropsWithChildren) => {
|
||||
export const ReduxInit = memo(({ children }: PropsWithChildren) => {
|
||||
const dispatch = useAppDispatch();
|
||||
useGlobalModifiersInit();
|
||||
useEffect(() => {
|
||||
dispatch(
|
||||
modelChanged({ model: { key: 'test_model', hash: 'some_hash', name: 'some name', base: 'sd-1', type: 'main' } })
|
||||
);
|
||||
}, []);
|
||||
}, [dispatch]);
|
||||
|
||||
return props.children;
|
||||
return children;
|
||||
});
|
||||
|
||||
ReduxInit.displayName = 'ReduxInit';
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import { Preview } from '@storybook/react';
|
||||
import type { Preview } from '@storybook/react';
|
||||
import { themes } from '@storybook/theming';
|
||||
import { $store } from 'app/store/nanostores/store';
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import { Provider } from 'react-redux';
|
||||
import ThemeLocaleProvider from '../src/app/components/ThemeLocaleProvider';
|
||||
import { $baseUrl } from '../src/app/store/nanostores/baseUrl';
|
||||
import { createStore } from '../src/app/store/store';
|
||||
|
||||
// TODO: Disabled for IDE performance issues with our translation JSON
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import translationEN from '../public/locales/en.json';
|
||||
import ThemeLocaleProvider from '../src/app/components/ThemeLocaleProvider';
|
||||
import { $baseUrl } from '../src/app/store/nanostores/baseUrl';
|
||||
import { createStore } from '../src/app/store/store';
|
||||
import { ReduxInit } from './ReduxInit';
|
||||
import { $store } from 'app/store/nanostores/store';
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
lng: 'en',
|
||||
|
||||
@@ -17,8 +17,6 @@ export default [
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
parser: typescriptParser,
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
@@ -27,8 +25,9 @@ export default [
|
||||
},
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2021,
|
||||
...globals.node,
|
||||
GlobalCompositeOperation: 'readonly',
|
||||
RequestInit: 'readonly',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -41,7 +40,7 @@ export default [
|
||||
import: pluginImport,
|
||||
'unused-imports': pluginUnusedImports,
|
||||
'simple-import-sort': pluginSimpleImportSort,
|
||||
'react-refresh': pluginReactRefresh,
|
||||
'react-refresh': pluginReactRefresh.configs.vite,
|
||||
path: pluginPath,
|
||||
i18next: pluginI18Next,
|
||||
storybook: pluginStorybook,
|
||||
@@ -71,13 +70,6 @@ export default [
|
||||
|
||||
'react-hooks/exhaustive-deps': 'error',
|
||||
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{
|
||||
allowConstantExport: true,
|
||||
},
|
||||
],
|
||||
|
||||
curly: 'error',
|
||||
'no-var': 'error',
|
||||
'brace-style': 'error',
|
||||
@@ -143,9 +135,9 @@ export default [
|
||||
'@typescript-eslint/no-import-type-side-effects': 'error',
|
||||
|
||||
'@typescript-eslint/consistent-type-assertions': [
|
||||
'warn',
|
||||
'error',
|
||||
{
|
||||
assertionStyle: 'never',
|
||||
assertionStyle: 'as',
|
||||
},
|
||||
],
|
||||
|
||||
@@ -184,6 +176,9 @@ export default [
|
||||
},
|
||||
],
|
||||
|
||||
// Typescript handles this for us: https://eslint.org/docs/latest/rules/no-redeclare#handled_by_typescript
|
||||
'no-redeclare': 'off',
|
||||
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
@@ -241,13 +236,7 @@ export default [
|
||||
'**/*.scss',
|
||||
'src/services/api/schema.ts',
|
||||
'.prettierrc.js',
|
||||
'.storybook',
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
files: ['**/*.test.ts', '**/*.test.tsx'],
|
||||
rules: {
|
||||
'@typescript-eslint/consistent-type-assertions': 'off',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -317,7 +317,7 @@ const InvokeAIUI = ({
|
||||
if (import.meta.env.MODE === 'development') {
|
||||
window.$store = $store;
|
||||
}
|
||||
() => {
|
||||
return () => {
|
||||
$store.set(undefined);
|
||||
if (import.meta.env.MODE === 'development') {
|
||||
window.$store = undefined;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const preventDefault = (e: React.MouseEvent) => {
|
||||
import type { MouseEvent } from 'react';
|
||||
|
||||
export const preventDefault = (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import type React from 'react';
|
||||
import { memo } from 'react';
|
||||
|
||||
/**
|
||||
* A typed version of React.memo, useful for components that take generics.
|
||||
*/
|
||||
export const typedMemo: <T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>>(
|
||||
export const typedMemo: <T extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>>(
|
||||
component: T,
|
||||
propsAreEqual?: (prevProps: React.ComponentProps<T>, nextProps: React.ComponentProps<T>) => boolean
|
||||
) => T & { displayName?: string } = memo;
|
||||
|
||||
@@ -126,6 +126,7 @@ const AddRefImageDropTargetAndButton = memo(() => {
|
||||
</Flex>
|
||||
);
|
||||
});
|
||||
AddRefImageDropTargetAndButton.displayName = 'AddRefImageDropTargetAndButton';
|
||||
|
||||
const BboxButton = memo(() => {
|
||||
const { t } = useTranslation();
|
||||
@@ -145,4 +146,4 @@ const BboxButton = memo(() => {
|
||||
/>
|
||||
);
|
||||
});
|
||||
AddRefImageDropTargetAndButton.displayName = 'AddRefImageDropTargetAndButton';
|
||||
BboxButton.displayName = 'BboxButton';
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ToolBrushButton } from 'features/controlLayers/components/Tool/ToolBrus
|
||||
import { ToolColorPickerButton } from 'features/controlLayers/components/Tool/ToolColorPickerButton';
|
||||
import { ToolMoveButton } from 'features/controlLayers/components/Tool/ToolMoveButton';
|
||||
import { ToolRectButton } from 'features/controlLayers/components/Tool/ToolRectButton';
|
||||
import React from 'react';
|
||||
|
||||
import { ToolEraserButton } from './ToolEraserButton';
|
||||
import { ToolViewButton } from './ToolViewButton';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useEntityAdapter } from 'features/controlLayers/contexts/EntityAdapterC
|
||||
import { useEntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext';
|
||||
import { TRANSPARENCY_CHECKERBOARD_PATTERN_DARK_DATAURL } from 'features/controlLayers/konva/patterns/transparency-checkerboard-pattern';
|
||||
import { selectCanvasSlice, selectEntity } from 'features/controlLayers/store/selectors';
|
||||
import { memo, useEffect, useMemo, useRef } from 'react';
|
||||
import React, { memo, useEffect, useMemo, useRef } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
const ChakraCanvas = chakra.canvas;
|
||||
|
||||
@@ -339,7 +339,9 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
|
||||
onStageMouseWheel = (e: KonvaEventObject<WheelEvent>) => {
|
||||
e.evt.preventDefault();
|
||||
this._snapTimeout && window.clearTimeout(this._snapTimeout);
|
||||
if (this._snapTimeout !== null) {
|
||||
window.clearTimeout(this._snapTimeout);
|
||||
}
|
||||
|
||||
if (e.evt.ctrlKey || e.evt.metaKey) {
|
||||
return;
|
||||
|
||||
@@ -146,7 +146,7 @@ const zNoiseFilterConfig = z.object({
|
||||
});
|
||||
export type NoiseFilterConfig = z.infer<typeof zNoiseFilterConfig>;
|
||||
|
||||
const zFilterConfig = z.discriminatedUnion('type', [
|
||||
const _zFilterConfig = z.discriminatedUnion('type', [
|
||||
zAdjustImageFilterConfig,
|
||||
zCannyEdgeDetectionFilterConfig,
|
||||
zColorMapFilterConfig,
|
||||
@@ -164,7 +164,7 @@ const zFilterConfig = z.discriminatedUnion('type', [
|
||||
zBlurFilterConfig,
|
||||
zNoiseFilterConfig,
|
||||
]);
|
||||
export type FilterConfig = z.infer<typeof zFilterConfig>;
|
||||
export type FilterConfig = z.infer<typeof _zFilterConfig>;
|
||||
|
||||
const zFilterType = z.enum([
|
||||
'adjust_image',
|
||||
|
||||
@@ -82,8 +82,8 @@ const zIPMethodV2 = z.enum(['full', 'style', 'composition', 'style_strong', 'sty
|
||||
export type IPMethodV2 = z.infer<typeof zIPMethodV2>;
|
||||
export const isIPMethodV2 = (v: unknown): v is IPMethodV2 => zIPMethodV2.safeParse(v).success;
|
||||
|
||||
const zTool = z.enum(['brush', 'eraser', 'move', 'rect', 'view', 'bbox', 'colorPicker']);
|
||||
export type Tool = z.infer<typeof zTool>;
|
||||
const _zTool = z.enum(['brush', 'eraser', 'move', 'rect', 'view', 'bbox', 'colorPicker']);
|
||||
export type Tool = z.infer<typeof _zTool>;
|
||||
|
||||
const zPoints = z.array(z.number()).refine((points) => points.length % 2 === 0, {
|
||||
message: 'Must have an even number of coordinate components',
|
||||
@@ -106,23 +106,23 @@ export const RGBA_BLACK: RgbaColor = { r: 0, g: 0, b: 0, a: 1 };
|
||||
|
||||
const zOpacity = z.number().gte(0).lte(1);
|
||||
|
||||
const zDimensions = z.object({
|
||||
const _zDimensions = z.object({
|
||||
width: z.number().int().positive(),
|
||||
height: z.number().int().positive(),
|
||||
});
|
||||
export type Dimensions = z.infer<typeof zDimensions>;
|
||||
export type Dimensions = z.infer<typeof _zDimensions>;
|
||||
|
||||
const zCoordinate = z.object({
|
||||
x: z.number(),
|
||||
y: z.number(),
|
||||
});
|
||||
export type Coordinate = z.infer<typeof zCoordinate>;
|
||||
const zCoordinateWithPressure = z.object({
|
||||
const _zCoordinateWithPressure = z.object({
|
||||
x: z.number(),
|
||||
y: z.number(),
|
||||
pressure: z.number(),
|
||||
});
|
||||
export type CoordinateWithPressure = z.infer<typeof zCoordinateWithPressure>;
|
||||
export type CoordinateWithPressure = z.infer<typeof _zCoordinateWithPressure>;
|
||||
|
||||
const SAM_POINT_LABELS = {
|
||||
background: -1,
|
||||
@@ -154,12 +154,12 @@ export const SAM_POINT_LABEL_STRING_TO_NUMBER: Record<SAMPointLabelString, SAMPo
|
||||
foreground: 1,
|
||||
};
|
||||
|
||||
const zSAMPoint = z.object({
|
||||
const _zSAMPoint = z.object({
|
||||
x: z.number().int().gte(0),
|
||||
y: z.number().int().gte(0),
|
||||
label: zSAMPointLabel,
|
||||
});
|
||||
type SAMPoint = z.infer<typeof zSAMPoint>;
|
||||
type SAMPoint = z.infer<typeof _zSAMPoint>;
|
||||
export type SAMPointWithId = SAMPoint & { id: string };
|
||||
|
||||
const zRect = z.object({
|
||||
@@ -170,10 +170,10 @@ const zRect = z.object({
|
||||
});
|
||||
export type Rect = z.infer<typeof zRect>;
|
||||
|
||||
const zRectWithRotation = zRect.extend({
|
||||
const _zRectWithRotation = zRect.extend({
|
||||
rotation: z.number(),
|
||||
});
|
||||
export type RectWithRotation = z.infer<typeof zRectWithRotation>;
|
||||
export type RectWithRotation = z.infer<typeof _zRectWithRotation>;
|
||||
|
||||
const zCanvasBrushLineState = z.object({
|
||||
id: zId,
|
||||
@@ -402,13 +402,13 @@ export type BoundingBoxScaleMethod = z.infer<typeof zBoundingBoxScaleMethod>;
|
||||
export const isBoundingBoxScaleMethod = (v: unknown): v is BoundingBoxScaleMethod =>
|
||||
zBoundingBoxScaleMethod.safeParse(v).success;
|
||||
|
||||
const zCanvasEntityState = z.discriminatedUnion('type', [
|
||||
const _zCanvasEntityState = z.discriminatedUnion('type', [
|
||||
zCanvasRasterLayerState,
|
||||
zCanvasControlLayerState,
|
||||
zCanvasRegionalGuidanceState,
|
||||
zCanvasInpaintMaskState,
|
||||
]);
|
||||
export type CanvasEntityState = z.infer<typeof zCanvasEntityState>;
|
||||
export type CanvasEntityState = z.infer<typeof _zCanvasEntityState>;
|
||||
|
||||
const zCanvasEntityType = z.union([
|
||||
zCanvasRasterLayerState.shape.type,
|
||||
|
||||
@@ -51,7 +51,7 @@ const BoardContextMenu = ({ board, children }: Props) => {
|
||||
board_id: board.board_id,
|
||||
changes: { archived: true },
|
||||
}).unwrap();
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({
|
||||
status: 'error',
|
||||
title: 'Unable to archive board',
|
||||
|
||||
@@ -5,7 +5,7 @@ import { TRANSPARENCY_CHECKERBOARD_PATTERN_DARK_DATAURL } from 'features/control
|
||||
import type { Dimensions } from 'features/controlLayers/store/types';
|
||||
import { ImageComparisonLabel } from 'features/gallery/components/ImageViewer/ImageComparisonLabel';
|
||||
import { selectComparisonFit } from 'features/gallery/store/gallerySelectors';
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { PiCaretLeftBold, PiCaretRightBold } from 'react-icons/pi';
|
||||
|
||||
import type { ComparisonProps } from './common';
|
||||
|
||||
@@ -14,7 +14,7 @@ import { imageToCompareChanged, selectionChanged } from 'features/gallery/store/
|
||||
import { useRegisteredHotkeys } from 'features/system/components/HotkeysModal/useHotkeyData';
|
||||
import { useOverlayScrollbars } from 'overlayscrollbars-react';
|
||||
import type { MutableRefObject, RefObject } from 'react';
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import type {
|
||||
GridComponents,
|
||||
GridComputeItemKey,
|
||||
|
||||
@@ -52,12 +52,12 @@ export const useCreateStylePresetFromMetadata = (imageDTO?: ImageDTO | null) =>
|
||||
|
||||
try {
|
||||
positivePrompt = await MetadataHandlers.PositivePrompt.parse(metadata, store);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
positivePrompt = '';
|
||||
}
|
||||
try {
|
||||
negativePrompt = (await MetadataHandlers.NegativePrompt.parse(metadata, store)) ?? '';
|
||||
} catch (error) {
|
||||
} catch {
|
||||
negativePrompt = '';
|
||||
}
|
||||
|
||||
|
||||
@@ -990,7 +990,7 @@ const recallByHandlers = async (arg: {
|
||||
const value = await handler.parse(metadata, store);
|
||||
handler.recall(value, store);
|
||||
recalled.set(handler, value);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1146,7 +1146,6 @@ export function useSingleMetadataDatum<T>(metadata: unknown, handler: SingleMeta
|
||||
return { data, recall };
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||
export function useCollectionMetadataDatum<T extends any[]>(metadata: unknown, handler: CollectionMetadataHandler<T>) {
|
||||
const store = useAppStore();
|
||||
const [data, setData] = useState<Data<T>>(buildUnparsedData);
|
||||
|
||||
@@ -22,7 +22,11 @@ const PredictionTypeSelect = ({ control }: Props) => {
|
||||
const value = useMemo(() => options.find((o) => o.value === field.value), [field.value]);
|
||||
const onChange = useCallback<ComboboxOnChange>(
|
||||
(v) => {
|
||||
v?.value === 'none' ? field.onChange(undefined) : field.onChange(v?.value);
|
||||
if (v?.value === 'none') {
|
||||
field.onChange(undefined);
|
||||
} else {
|
||||
field.onChange(v?.value);
|
||||
}
|
||||
},
|
||||
[field]
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
TagLabel,
|
||||
} from '@invoke-ai/ui-library';
|
||||
import type { ChangeEvent } from 'react';
|
||||
import { memo, useCallback, useMemo, useState } from 'react';
|
||||
import React, { memo, useCallback, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PiPlusBold } from 'react-icons/pi';
|
||||
import { useUpdateModelMutation } from 'services/api/endpoints/models';
|
||||
|
||||
@@ -220,6 +220,7 @@ export const InvocationNodeContextProvider = memo(({ nodeId, children }: PropsWi
|
||||
|
||||
return <InvocationNodeContext.Provider value={value}>{children}</InvocationNodeContext.Provider>;
|
||||
});
|
||||
InvocationNodeContextProvider.displayName = 'InvocationNodeContextProvider';
|
||||
|
||||
export const useInvocationNodeContext = () => {
|
||||
const context = useContext(InvocationNodeContext);
|
||||
|
||||
@@ -14,7 +14,7 @@ type Props<T extends AnyModelConfig> = {
|
||||
groupByType?: boolean;
|
||||
};
|
||||
|
||||
const _ModelFieldCombobox = <T extends AnyModelConfig>({
|
||||
const ModelFieldComboboxInternal = <T extends AnyModelConfig>({
|
||||
value: _value,
|
||||
modelConfigs,
|
||||
isLoadingConfigs,
|
||||
@@ -48,4 +48,4 @@ const _ModelFieldCombobox = <T extends AnyModelConfig>({
|
||||
);
|
||||
};
|
||||
|
||||
export const ModelFieldCombobox = typedMemo(_ModelFieldCombobox);
|
||||
export const ModelFieldCombobox = typedMemo(ModelFieldComboboxInternal);
|
||||
|
||||
@@ -22,7 +22,7 @@ export const PublishedWorkflowPanelContent = memo(() => {
|
||||
title: t('toast.workflowUnpublished'),
|
||||
status: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({
|
||||
title: t('toast.problemUnpublishingWorkflow'),
|
||||
description: t('toast.problemUnpublishingWorkflowDescription'),
|
||||
|
||||
@@ -34,7 +34,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import type { Equals } from 'tsafe';
|
||||
import { assert } from 'tsafe';
|
||||
|
||||
const ContainerElement = memo(({ id }: { id: string }) => {
|
||||
const ContainerElementComponent = memo(({ id }: { id: string }) => {
|
||||
const el = useElement(id);
|
||||
const mode = useAppSelector(selectWorkflowMode);
|
||||
|
||||
@@ -49,7 +49,7 @@ const ContainerElement = memo(({ id }: { id: string }) => {
|
||||
// mode === 'edit'
|
||||
return <ContainerElementComponentEditMode el={el} />;
|
||||
});
|
||||
ContainerElement.displayName = 'ContainerElementComponent';
|
||||
ContainerElementComponent.displayName = 'ContainerElementComponent';
|
||||
|
||||
const containerViewModeSx: SystemStyleObject = {
|
||||
gap: 2,
|
||||
@@ -301,7 +301,7 @@ const FormElementComponent = memo(({ id }: { id: string }) => {
|
||||
}
|
||||
|
||||
if (isContainerElement(el)) {
|
||||
return <ContainerElement key={id} id={id} />;
|
||||
return <ContainerElementComponent key={id} id={id} />;
|
||||
}
|
||||
|
||||
if (isNodeFieldElement(el)) {
|
||||
|
||||
@@ -63,8 +63,8 @@ describe('workflow builder form manipulation', () => {
|
||||
});
|
||||
|
||||
it('should narrow the type of the element if a type guard is provided and the element matches', () => {
|
||||
const element = getElement(form, form.rootElementId, isContainerElement);
|
||||
assert<Equals<typeof element, ContainerElement>>();
|
||||
const _element = getElement(form, form.rootElementId, isContainerElement);
|
||||
assert<Equals<typeof _element, ContainerElement>>();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export const WorkflowThumbnailEditor = ({
|
||||
|
||||
setCanSaveChanges(false);
|
||||
toast({ status: 'success', title: 'Workflow thumbnail updated' });
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({ status: 'error', title: 'Failed to update thumbnail' });
|
||||
}
|
||||
}, [deleteThumbnail, setThumbnail, workflowId, localThumbnailUrl]);
|
||||
|
||||
@@ -26,7 +26,7 @@ export const WorkflowThumbnailField = ({
|
||||
const file = new File([blob], 'workflow.png', { type: 'image/png' });
|
||||
setThumbnail(file);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setThumbnail(null);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -22,7 +22,7 @@ export const useInputFieldErrors = (fieldName: string): FieldError[] => {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
const errors = thisNodeErrors.filter((error) => {
|
||||
error.type === 'field-error' && error.fieldName === fieldName;
|
||||
return error.type === 'field-error' && error.fieldName === fieldName;
|
||||
});
|
||||
if (errors.length === 0) {
|
||||
return EMPTY_ARRAY;
|
||||
|
||||
@@ -22,7 +22,7 @@ export const useInputFieldIsInvalid = (fieldName: string) => {
|
||||
return false;
|
||||
}
|
||||
const isFieldInvalid = thisNodeErrors.some((error) => {
|
||||
error.type === 'field-error' && error.fieldName === fieldName;
|
||||
return error.type === 'field-error' && error.fieldName === fieldName;
|
||||
});
|
||||
return isFieldInvalid;
|
||||
}),
|
||||
|
||||
@@ -138,7 +138,7 @@ export type ModelIdentifierField = z.infer<typeof zModelIdentifierField>;
|
||||
// #endregion
|
||||
|
||||
// #region Control Adapters
|
||||
const zControlField = z.object({
|
||||
const _zControlField = z.object({
|
||||
image: zImageField,
|
||||
control_model: zModelIdentifierField,
|
||||
control_weight: z.union([z.number(), z.array(z.number())]).optional(),
|
||||
@@ -147,9 +147,9 @@ const zControlField = z.object({
|
||||
control_mode: z.enum(['balanced', 'more_prompt', 'more_control', 'unbalanced']).optional(),
|
||||
resize_mode: z.enum(['just_resize', 'crop_resize', 'fill_resize', 'just_resize_simple']).optional(),
|
||||
});
|
||||
export type ControlField = z.infer<typeof zControlField>;
|
||||
export type ControlField = z.infer<typeof _zControlField>;
|
||||
|
||||
const zIPAdapterField = z.object({
|
||||
const _zIPAdapterField = z.object({
|
||||
image: zImageField,
|
||||
ip_adapter_model: zModelIdentifierField,
|
||||
weight: z.number(),
|
||||
@@ -157,9 +157,9 @@ const zIPAdapterField = z.object({
|
||||
begin_step_percent: z.number().optional(),
|
||||
end_step_percent: z.number().optional(),
|
||||
});
|
||||
export type IPAdapterField = z.infer<typeof zIPAdapterField>;
|
||||
export type IPAdapterField = z.infer<typeof _zIPAdapterField>;
|
||||
|
||||
const zT2IAdapterField = z.object({
|
||||
const _zT2IAdapterField = z.object({
|
||||
image: zImageField,
|
||||
t2i_adapter_model: zModelIdentifierField,
|
||||
weight: z.union([z.number(), z.array(z.number())]).optional(),
|
||||
@@ -167,7 +167,7 @@ const zT2IAdapterField = z.object({
|
||||
end_step_percent: z.number().optional(),
|
||||
resize_mode: z.enum(['just_resize', 'crop_resize', 'fill_resize', 'just_resize_simple']).optional(),
|
||||
});
|
||||
export type T2IAdapterField = z.infer<typeof zT2IAdapterField>;
|
||||
export type T2IAdapterField = z.infer<typeof _zT2IAdapterField>;
|
||||
// #endregion
|
||||
|
||||
// #region ProgressImage
|
||||
|
||||
@@ -1918,8 +1918,8 @@ export const zStatefulFieldValue = z.union([
|
||||
]);
|
||||
export type StatefulFieldValue = z.infer<typeof zStatefulFieldValue>;
|
||||
|
||||
const zFieldValue = z.union([zStatefulFieldValue, zStatelessFieldValue]);
|
||||
export type FieldValue = z.infer<typeof zFieldValue>;
|
||||
const _zFieldValue = z.union([zStatefulFieldValue, zStatelessFieldValue]);
|
||||
export type FieldValue = z.infer<typeof _zFieldValue>;
|
||||
// #endregion
|
||||
|
||||
// #region StatefulFieldInputInstance & FieldInputInstance
|
||||
|
||||
@@ -6,7 +6,7 @@ import { zFieldInputInstance, zFieldInputTemplate, zFieldOutputTemplate } from '
|
||||
import { zSemVer } from './semver';
|
||||
|
||||
// #region InvocationTemplate
|
||||
const zInvocationTemplate = z.object({
|
||||
const _zInvocationTemplate = z.object({
|
||||
type: z.string(),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
@@ -19,7 +19,7 @@ const zInvocationTemplate = z.object({
|
||||
nodePack: z.string().min(1).default('invokeai'),
|
||||
classification: zClassification,
|
||||
});
|
||||
export type InvocationTemplate = z.infer<typeof zInvocationTemplate>;
|
||||
export type InvocationTemplate = z.infer<typeof _zInvocationTemplate>;
|
||||
// #endregion
|
||||
|
||||
// #region NodeData
|
||||
@@ -43,7 +43,7 @@ export const zNotesNodeData = z.object({
|
||||
isOpen: z.boolean(),
|
||||
notes: z.string(),
|
||||
});
|
||||
const zCurrentImageNodeData = z.object({
|
||||
const _zCurrentImageNodeData = z.object({
|
||||
id: z.string().trim().min(1),
|
||||
type: z.literal('current_image'),
|
||||
label: z.string(),
|
||||
@@ -52,7 +52,7 @@ const zCurrentImageNodeData = z.object({
|
||||
|
||||
export type NotesNodeData = z.infer<typeof zNotesNodeData>;
|
||||
export type InvocationNodeData = z.infer<typeof zInvocationNodeData>;
|
||||
type CurrentImageNodeData = z.infer<typeof zCurrentImageNodeData>;
|
||||
type CurrentImageNodeData = z.infer<typeof _zCurrentImageNodeData>;
|
||||
|
||||
export type InvocationNode = Node<InvocationNodeData, 'invocation'>;
|
||||
export type NotesNode = Node<NotesNodeData, 'notes'>;
|
||||
@@ -71,7 +71,7 @@ const zNodeError = z.object({
|
||||
error_message: z.string(),
|
||||
error_traceback: z.string(),
|
||||
});
|
||||
const zNodeExecutionState = z.object({
|
||||
const _zNodeExecutionState = z.object({
|
||||
nodeId: z.string().trim().min(1),
|
||||
status: zNodeStatus,
|
||||
progress: z.number().nullable(),
|
||||
@@ -79,14 +79,14 @@ const zNodeExecutionState = z.object({
|
||||
outputs: z.array(z.any()),
|
||||
error: zNodeError.nullable(),
|
||||
});
|
||||
export type NodeExecutionState = z.infer<typeof zNodeExecutionState>;
|
||||
export type NodeExecutionState = z.infer<typeof _zNodeExecutionState>;
|
||||
// #endregion
|
||||
|
||||
// #region Edges
|
||||
const zInvocationNodeEdgeCollapsedData = z.object({
|
||||
const _zInvocationNodeEdgeCollapsedData = z.object({
|
||||
count: z.number().int().min(1),
|
||||
});
|
||||
type InvocationNodeEdgeCollapsedData = z.infer<typeof zInvocationNodeEdgeCollapsedData>;
|
||||
type InvocationNodeEdgeCollapsedData = z.infer<typeof _zInvocationNodeEdgeCollapsedData>;
|
||||
export type DefaultInvocationNodeEdge = Edge<Record<string, never>, 'default'>;
|
||||
export type CollapsedInvocationNodeEdge = Edge<InvocationNodeEdgeCollapsedData, 'collapsed'>;
|
||||
export type AnyEdge = DefaultInvocationNodeEdge | CollapsedInvocationNodeEdge;
|
||||
|
||||
@@ -328,7 +328,7 @@ const zStatelessFieldOutputInstance = zFieldOutputInstanceBase.extend({
|
||||
|
||||
// #endregion
|
||||
|
||||
const zStatefulFieldType = z.union([
|
||||
const _zStatefulFieldType = z.union([
|
||||
zIntegerFieldType,
|
||||
zFloatFieldType,
|
||||
zStringFieldType,
|
||||
@@ -347,7 +347,7 @@ const zStatefulFieldType = z.union([
|
||||
zColorFieldType,
|
||||
zSchedulerFieldType,
|
||||
]);
|
||||
export type StatefulFieldType = z.infer<typeof zStatefulFieldType>;
|
||||
export type StatefulFieldType = z.infer<typeof _zStatefulFieldType>;
|
||||
|
||||
/**
|
||||
* Here we define the main field unions:
|
||||
|
||||
@@ -82,7 +82,7 @@ export const validateWorkflow = async (args: ValidateWorkflowArgs): Promise<Vali
|
||||
try {
|
||||
const updatedNode = updateNode(node, template);
|
||||
node.data = updatedNode.data;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
const message = t('nodes.unableToUpdateNode', {
|
||||
node: node.id,
|
||||
type: node.data.type,
|
||||
|
||||
@@ -131,8 +131,8 @@ export type ParameterCLIPGEmbedModel = z.infer<typeof zParameterCLIPGEmbedModel>
|
||||
// #endregion
|
||||
|
||||
// #region LoRA Model
|
||||
const zParameterLoRAModel = zModelIdentifierField;
|
||||
export type ParameterLoRAModel = z.infer<typeof zParameterLoRAModel>;
|
||||
const _zParameterLoRAModel = zModelIdentifierField;
|
||||
export type ParameterLoRAModel = z.infer<typeof _zParameterLoRAModel>;
|
||||
// #endregion
|
||||
|
||||
// #region VAE Model
|
||||
|
||||
@@ -31,7 +31,7 @@ export const expandPrompt = async (arg: { dispatch: AppDispatch; getState: AppGe
|
||||
});
|
||||
assert(output.type === 'string_output');
|
||||
promptExpansionApi.setSuccess(output.value);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
promptExpansionApi.reset();
|
||||
toast({
|
||||
id: 'PROMPT_EXPANSION_FAILED',
|
||||
|
||||
@@ -17,7 +17,7 @@ const ClearModelCacheButton = () => {
|
||||
status: 'success',
|
||||
title: t('modelCache.clearSucceeded'),
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({
|
||||
status: 'error',
|
||||
title: t('modelCache.clearFailed'),
|
||||
|
||||
@@ -39,7 +39,7 @@ const selectBadges = createMemoizedSelector([selectCanvasSlice, selectParamsSlic
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
badges;
|
||||
return badges;
|
||||
});
|
||||
|
||||
const scalingLabelProps: FormLabelProps = {
|
||||
|
||||
@@ -36,7 +36,7 @@ const selectBadges = createMemoizedSelector(
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
badges;
|
||||
return badges;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import ParamSDXLRefinerScheduler from 'features/sdxl/components/SDXLRefiner/Para
|
||||
import ParamSDXLRefinerStart from 'features/sdxl/components/SDXLRefiner/ParamSDXLRefinerStart';
|
||||
import ParamSDXLRefinerSteps from 'features/sdxl/components/SDXLRefiner/ParamSDXLRefinerSteps';
|
||||
import { useStandaloneAccordionToggle } from 'features/settingsAccordions/hooks/useStandaloneAccordionToggle';
|
||||
import { memo } from 'react';
|
||||
import React, { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsRefinerAvailable } from 'services/api/hooks/useIsRefinerAvailable';
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export const DeleteStylePresetDialog = memo(() => {
|
||||
status: 'success',
|
||||
title: t('stylePresets.templateDeleted'),
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({
|
||||
status: 'error',
|
||||
title: t('stylePresets.unableToDeleteTemplate'),
|
||||
|
||||
@@ -27,7 +27,7 @@ export const StylePresetExportButton = () => {
|
||||
try {
|
||||
const response = await exportStylePresets().unwrap();
|
||||
blob = new Blob([response], { type: 'text/csv' });
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({
|
||||
status: 'error',
|
||||
title: t('stylePresets.exportFailed'),
|
||||
|
||||
@@ -68,7 +68,7 @@ export const StylePresetForm = ({
|
||||
} else {
|
||||
await createStylePreset(payload).unwrap();
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast({
|
||||
status: 'error',
|
||||
title: 'Failed to save style preset',
|
||||
|
||||
@@ -55,7 +55,7 @@ export const StylePresetModal = () => {
|
||||
if (blob) {
|
||||
file = new File([blob], 'style_preset.png', { type: 'image/png' });
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export type RootLayoutGridviewComponents = Record<string, FunctionComponent<IGri
|
||||
type PanelProps = IDockviewPanelProps<PanelParameters> | IGridviewPanelProps<PanelParameters>;
|
||||
|
||||
export const withPanelContainer = (Component: FunctionComponent) =>
|
||||
/* eslint-disable-next-line react/display-name */
|
||||
memo((props: PanelProps) => {
|
||||
return (
|
||||
<AutoLayoutPanelContainer {...props}>
|
||||
|
||||
@@ -340,7 +340,7 @@ export class NavigationApi {
|
||||
log.trace(`Focused panel ${key}`);
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
log.error(`Failed to focus panel ${panelId} in tab ${tab}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,15 +70,15 @@ export const useCreateLibraryWorkflow = (): CreateLibraryWorkflowReturn => {
|
||||
// When a workflow is saved, the form field initial values are updated to the current form field values
|
||||
dispatch(formFieldInitialValuesChanged({ formFieldInitialValues: getFormFieldInitialValues() }));
|
||||
updateOpenedAt({ workflow_id: id });
|
||||
onSuccess && onSuccess();
|
||||
onSuccess?.();
|
||||
toast.update(toastRef.current, {
|
||||
title: t('workflows.workflowSaved'),
|
||||
status: 'success',
|
||||
duration: 1000,
|
||||
isClosable: true,
|
||||
});
|
||||
} catch (e) {
|
||||
onError && onError();
|
||||
} catch {
|
||||
onError?.();
|
||||
if (!toast.isActive(`auth-error-toast-${workflowsApi.endpoints.createWorkflow.name}`)) {
|
||||
toast.update(toastRef.current, {
|
||||
title: t('workflows.problemSavingWorkflow'),
|
||||
|
||||
@@ -55,7 +55,7 @@ export const useSaveLibraryWorkflow = (): UseSaveLibraryWorkflowReturn => {
|
||||
duration: 1000,
|
||||
isClosable: true,
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
if (!toast.isActive(`auth-error-toast-${workflowsApi.endpoints.updateWorkflow.name}`)) {
|
||||
toast.update(toastRef.current, {
|
||||
title: t('workflows.problemSavingWorkflow'),
|
||||
|
||||
@@ -72,7 +72,7 @@ export const authToastMiddleware: Middleware = () => (next) => (action) => {
|
||||
description: customMessage,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,6 @@ export const buildOnModelInstallError = (getState: AppGetState, dispatch: AppDis
|
||||
if (!install) {
|
||||
dispatch(api.util.invalidateTags([{ type: 'ModelInstalls' }]));
|
||||
} else {
|
||||
install.source;
|
||||
dispatch(
|
||||
modelsApi.util.updateQueryData('listModelInstalls', undefined, (draft) => {
|
||||
const modelImport = draft.find((m) => m.id === data.id);
|
||||
|
||||
Reference in New Issue
Block a user