mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Reduce frontend eslint warnings to 0
This commit is contained in:
parent
9b9e276491
commit
6e0f3475b4
2
.github/workflows/lint-frontend.yml
vendored
2
.github/workflows/lint-frontend.yml
vendored
@ -21,4 +21,4 @@ jobs:
|
|||||||
- run: 'yarn install'
|
- run: 'yarn install'
|
||||||
- run: 'yarn tsc'
|
- run: 'yarn tsc'
|
||||||
- run: 'yarn run madge'
|
- run: 'yarn run madge'
|
||||||
- run: 'yarn run lint --max-warnings=22'
|
- run: 'yarn run lint --max-warnings=0'
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:react-hooks/recommended',
|
||||||
|
],
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
plugins: ['@typescript-eslint', 'eslint-plugin-react-hooks'],
|
plugins: ['@typescript-eslint', 'eslint-plugin-react-hooks'],
|
||||||
root: true,
|
root: true,
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: '_+' }],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@ import type { RootState } from 'app/store';
|
|||||||
* i.e. those which make server requests.
|
* i.e. those which make server requests.
|
||||||
*/
|
*/
|
||||||
const makeSocketIOEmitters = (
|
const makeSocketIOEmitters = (
|
||||||
store: MiddlewareAPI<Dispatch<AnyAction>, any>,
|
store: MiddlewareAPI<Dispatch<AnyAction>, RootState>,
|
||||||
socketio: Socket
|
socketio: Socket
|
||||||
) => {
|
) => {
|
||||||
// We need to dispatch actions to redux and get pieces of state from the store.
|
// We need to dispatch actions to redux and get pieces of state from the store.
|
||||||
@ -114,7 +114,7 @@ const makeSocketIOEmitters = (
|
|||||||
const options: OptionsState = getState().options;
|
const options: OptionsState = getState().options;
|
||||||
const { facetoolType, facetoolStrength, codeformerFidelity } = options;
|
const { facetoolType, facetoolStrength, codeformerFidelity } = options;
|
||||||
|
|
||||||
const facetoolParameters: Record<string, any> = {
|
const facetoolParameters: Record<string, unknown> = {
|
||||||
facetool_strength: facetoolStrength,
|
facetool_strength: facetoolStrength,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,13 +40,14 @@ import {
|
|||||||
} from './actions';
|
} from './actions';
|
||||||
import { addImageToStagingArea } from 'features/canvas/store/canvasSlice';
|
import { addImageToStagingArea } from 'features/canvas/store/canvasSlice';
|
||||||
import { tabMap } from 'features/tabs/tabMap';
|
import { tabMap } from 'features/tabs/tabMap';
|
||||||
|
import type { RootState } from 'app/store';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object containing listener callbacks for socketio events.
|
* Returns an object containing listener callbacks for socketio events.
|
||||||
* TODO: This file is large, but simple. Should it be split up further?
|
* TODO: This file is large, but simple. Should it be split up further?
|
||||||
*/
|
*/
|
||||||
const makeSocketIOListeners = (
|
const makeSocketIOListeners = (
|
||||||
store: MiddlewareAPI<Dispatch<AnyAction>, any>
|
store: MiddlewareAPI<Dispatch<AnyAction>, RootState>
|
||||||
) => {
|
) => {
|
||||||
const { dispatch, getState } = store;
|
const { dispatch, getState } = store;
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ const makeSocketIOListeners = (
|
|||||||
*/
|
*/
|
||||||
onGenerationResult: (data: InvokeAI.ImageResultResponse) => {
|
onGenerationResult: (data: InvokeAI.ImageResultResponse) => {
|
||||||
try {
|
try {
|
||||||
const state = getState();
|
const state: RootState = getState();
|
||||||
const { shouldLoopback, activeTab } = state.options;
|
const { shouldLoopback, activeTab } = state.options;
|
||||||
const { boundingBox: _, generationMode, ...rest } = data;
|
const { boundingBox: _, generationMode, ...rest } = data;
|
||||||
|
|
||||||
@ -325,7 +326,10 @@ const makeSocketIOListeners = (
|
|||||||
// remove references to image in options
|
// remove references to image in options
|
||||||
const { initialImage, maskPath } = getState().options;
|
const { initialImage, maskPath } = getState().options;
|
||||||
|
|
||||||
if (initialImage?.url === url || initialImage === url) {
|
if (
|
||||||
|
initialImage === url ||
|
||||||
|
(initialImage as InvokeAI.Image)?.url === url
|
||||||
|
) {
|
||||||
dispatch(clearInitialImage());
|
dispatch(clearInitialImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ export default function IAISlider(props: IAIFullSliderProps) {
|
|||||||
onChange(clamped);
|
onChange(clamped);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInputChange = (v: any) => {
|
const handleInputChange = (v: number | string) => {
|
||||||
setLocalInputValue(v);
|
setLocalInputValue(String(v));
|
||||||
onChange(Number(v));
|
onChange(Number(v));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Tooltip } from '@chakra-ui/react';
|
import { Tooltip } from '@chakra-ui/react';
|
||||||
import * as Slider from '@radix-ui/react-slider';
|
import * as Slider from '@radix-ui/react-slider';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import IAITooltip from './IAITooltip';
|
|
||||||
|
|
||||||
type IAISliderProps = Slider.SliderProps & {
|
type IAISliderProps = Slider.SliderProps & {
|
||||||
value: number[];
|
value: number[];
|
||||||
|
@ -20,7 +20,7 @@ const IAITooltip = (props: IAITooltipProps) => {
|
|||||||
<Tooltip.Portal>
|
<Tooltip.Portal>
|
||||||
<Tooltip.Content
|
<Tooltip.Content
|
||||||
{...contentProps}
|
{...contentProps}
|
||||||
onPointerDownOutside={(e: any) => {e.preventDefault()}}
|
onPointerDownOutside={(e) => {e.preventDefault()}}
|
||||||
className="invokeai__tooltip-content"
|
className="invokeai__tooltip-content"
|
||||||
>
|
>
|
||||||
<Tooltip.Arrow {...arrowProps} className="invokeai__tooltip-arrow" />
|
<Tooltip.Arrow {...arrowProps} className="invokeai__tooltip-arrow" />
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { RefObject, useEffect, useRef } from 'react';
|
import { RefObject, useEffect} from 'react';
|
||||||
import { Rect } from 'react-konva';
|
|
||||||
|
|
||||||
const watchers: {
|
const watchers: {
|
||||||
ref: RefObject<HTMLElement>;
|
ref: RefObject<HTMLElement>;
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants';
|
import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants';
|
||||||
import { OptionsState } from 'features/options/store/optionsSlice';
|
import { OptionsState } from 'features/options/store/optionsSlice';
|
||||||
import { SystemState } from 'features/system/store/systemSlice';
|
import { SystemState } from 'features/system/store/systemSlice';
|
||||||
|
import { Vector2d } from 'konva/lib/types';
|
||||||
|
import { Dimensions } from 'features/canvas/store/canvasTypes';
|
||||||
|
|
||||||
import { stringToSeedWeightsArray } from './seedWeightPairs';
|
import { stringToSeedWeightsArray } from './seedWeightPairs';
|
||||||
import randomInt from './randomInt';
|
import randomInt from './randomInt';
|
||||||
import { InvokeTabName } from 'features/tabs/tabMap';
|
import { InvokeTabName } from 'features/tabs/tabMap';
|
||||||
import { CanvasState, isCanvasMaskLine } from 'features/canvas/store/canvasTypes';
|
import {
|
||||||
|
CanvasState,
|
||||||
|
isCanvasMaskLine,
|
||||||
|
} from 'features/canvas/store/canvasTypes';
|
||||||
import generateMask from 'features/canvas/util/generateMask';
|
import generateMask from 'features/canvas/util/generateMask';
|
||||||
import openBase64ImageInTab from './openBase64ImageInTab';
|
import openBase64ImageInTab from './openBase64ImageInTab';
|
||||||
import { getCanvasBaseLayer } from 'features/canvas/util/konvaInstanceProvider';
|
import { getCanvasBaseLayer } from 'features/canvas/util/konvaInstanceProvider';
|
||||||
|
import type {
|
||||||
|
UpscalingLevel,
|
||||||
|
FacetoolType,
|
||||||
|
} from 'features/options/store/optionsSlice';
|
||||||
|
|
||||||
export type FrontendToBackendParametersConfig = {
|
export type FrontendToBackendParametersConfig = {
|
||||||
generationMode: InvokeTabName;
|
generationMode: InvokeTabName;
|
||||||
@ -18,13 +27,68 @@ export type FrontendToBackendParametersConfig = {
|
|||||||
imageToProcessUrl?: string;
|
imageToProcessUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type BackendGenerationParameters = {
|
||||||
|
prompt: string;
|
||||||
|
iterations: number;
|
||||||
|
steps: number;
|
||||||
|
cfg_scale: number;
|
||||||
|
threshold: number;
|
||||||
|
perlin: number;
|
||||||
|
height: number;
|
||||||
|
width: number;
|
||||||
|
sampler_name: string;
|
||||||
|
seed: number;
|
||||||
|
progress_images: boolean;
|
||||||
|
progress_latents: boolean;
|
||||||
|
save_intermediates: number;
|
||||||
|
generation_mode: InvokeTabName;
|
||||||
|
init_mask: string;
|
||||||
|
init_img?: string;
|
||||||
|
fit?: boolean;
|
||||||
|
seam_size?: number;
|
||||||
|
seam_blur?: number;
|
||||||
|
seam_strength?: number;
|
||||||
|
seam_steps?: number;
|
||||||
|
tile_size?: number;
|
||||||
|
infill_method?: string;
|
||||||
|
force_outpaint?: boolean;
|
||||||
|
seamless?: boolean;
|
||||||
|
hires_fix?: boolean;
|
||||||
|
strength?: number;
|
||||||
|
invert_mask?: boolean;
|
||||||
|
inpaint_replace?: number;
|
||||||
|
bounding_box?: Vector2d & Dimensions;
|
||||||
|
inpaint_width?: number;
|
||||||
|
inpaint_height?: number;
|
||||||
|
with_variations?: Array<Array<number>>;
|
||||||
|
variation_amount?: number;
|
||||||
|
enable_image_debugging?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BackendEsrGanParameters = {
|
||||||
|
level: UpscalingLevel;
|
||||||
|
strength: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BackendFacetoolParameters = {
|
||||||
|
type: FacetoolType;
|
||||||
|
strength: number;
|
||||||
|
codeformer_fidelity?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BackendParameters = {
|
||||||
|
generationParameters: BackendGenerationParameters;
|
||||||
|
esrganParameters: false | BackendEsrGanParameters;
|
||||||
|
facetoolParameters: false | BackendFacetoolParameters;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates/formats frontend state into parameters suitable
|
* Translates/formats frontend state into parameters suitable
|
||||||
* for consumption by the API.
|
* for consumption by the API.
|
||||||
*/
|
*/
|
||||||
export const frontendToBackendParameters = (
|
export const frontendToBackendParameters = (
|
||||||
config: FrontendToBackendParametersConfig
|
config: FrontendToBackendParametersConfig
|
||||||
): { [key: string]: any } => {
|
): BackendParameters => {
|
||||||
const canvasBaseLayer = getCanvasBaseLayer();
|
const canvasBaseLayer = getCanvasBaseLayer();
|
||||||
|
|
||||||
const { generationMode, optionsState, canvasState, systemState } = config;
|
const { generationMode, optionsState, canvasState, systemState } = config;
|
||||||
@ -70,7 +134,7 @@ export const frontendToBackendParameters = (
|
|||||||
enableImageDebugging,
|
enableImageDebugging,
|
||||||
} = systemState;
|
} = systemState;
|
||||||
|
|
||||||
const generationParameters: { [k: string]: any } = {
|
const generationParameters: BackendGenerationParameters = {
|
||||||
prompt,
|
prompt,
|
||||||
iterations,
|
iterations,
|
||||||
steps,
|
steps,
|
||||||
@ -88,8 +152,8 @@ export const frontendToBackendParameters = (
|
|||||||
init_mask: '',
|
init_mask: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
let esrganParameters: false | { [k: string]: any } = false;
|
let esrganParameters: false | BackendEsrGanParameters = false;
|
||||||
let facetoolParameters: false | { [k: string]: any } = false;
|
let facetoolParameters: false | BackendFacetoolParameters = false;
|
||||||
|
|
||||||
generationParameters.seed = shouldRandomizeSeed
|
generationParameters.seed = shouldRandomizeSeed
|
||||||
? randomInt(NUMPY_RAND_MIN, NUMPY_RAND_MAX)
|
? randomInt(NUMPY_RAND_MIN, NUMPY_RAND_MAX)
|
||||||
|
@ -14,7 +14,7 @@ type ReactPanZoomProps = {
|
|||||||
image: string;
|
image: string;
|
||||||
styleClass?: string;
|
styleClass?: string;
|
||||||
alt?: string;
|
alt?: string;
|
||||||
ref?: any;
|
ref?: React.Ref<HTMLImageElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ReactPanZoom({
|
export default function ReactPanZoom({
|
||||||
|
@ -6,7 +6,6 @@ import { useLayoutEffect } from 'react';
|
|||||||
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
||||||
import { setDoesCanvasNeedScaling } from 'features/canvas/store/canvasSlice';
|
import { setDoesCanvasNeedScaling } from 'features/canvas/store/canvasSlice';
|
||||||
import IAICanvas from 'features/canvas/components/IAICanvas';
|
import IAICanvas from 'features/canvas/components/IAICanvas';
|
||||||
import IAICanvasOutpaintingControls from 'features/canvas/components/IAICanvasToolbar/IAICanvasToolbar';
|
|
||||||
import { canvasSelector } from 'features/canvas/store/canvasSelectors';
|
import { canvasSelector } from 'features/canvas/store/canvasSelectors';
|
||||||
import { Flex } from '@chakra-ui/react';
|
import { Flex } from '@chakra-ui/react';
|
||||||
import UnifiedCanvasToolbarBeta from './UnifiedCanvasToolbarBeta';
|
import UnifiedCanvasToolbarBeta from './UnifiedCanvasToolbarBeta';
|
||||||
|
@ -3,7 +3,6 @@ import { createSelector } from '@reduxjs/toolkit';
|
|||||||
import {
|
import {
|
||||||
addEraseRect,
|
addEraseRect,
|
||||||
addFillRect,
|
addFillRect,
|
||||||
setBrushColor,
|
|
||||||
setTool,
|
setTool,
|
||||||
} from 'features/canvas/store/canvasSlice';
|
} from 'features/canvas/store/canvasSlice';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
||||||
|
6
frontend/src/global.d.ts
vendored
6
frontend/src/global.d.ts
vendored
@ -15,11 +15,11 @@ declare global {
|
|||||||
*/
|
*/
|
||||||
findLast<S extends T>(
|
findLast<S extends T>(
|
||||||
predicate: (this: void, value: T, index: number, obj: T[]) => value is S,
|
predicate: (this: void, value: T, index: number, obj: T[]) => value is S,
|
||||||
thisArg?: any
|
thisArg?: unknown
|
||||||
): S | undefined;
|
): S | undefined;
|
||||||
findLast(
|
findLast(
|
||||||
predicate: (value: T, index: number, obj: T[]) => unknown,
|
predicate: (value: T, index: number, obj: T[]) => unknown,
|
||||||
thisArg?: any
|
thisArg?: unknown
|
||||||
): T | undefined;
|
): T | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +33,7 @@ declare global {
|
|||||||
*/
|
*/
|
||||||
findLastIndex(
|
findLastIndex(
|
||||||
predicate: (value: T, index: number, obj: T[]) => unknown,
|
predicate: (value: T, index: number, obj: T[]) => unknown,
|
||||||
thisArg?: any
|
thisArg?: unknown
|
||||||
): number;
|
): number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user