fix some linting issues

This commit is contained in:
caranicas 2022-09-19 15:37:21 -04:00
parent 9f2ae75fa2
commit 82f8c31b81
31 changed files with 112 additions and 101 deletions

View File

@ -9,40 +9,50 @@ module.exports = {
parserOptions: { parserOptions: {
ecmaVersion: "latest", ecmaVersion: "latest",
sourceType: "module", sourceType: "module",
ecmaFeatures: {
jsx: true,
},
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
}, },
plugins: ["react"], plugins: ["react"],
extends: [ extends: [
"plugin:react/recommended", "plugin:react/recommended",
"standard-with-typescript", "standard-with-typescript",
"plugin:i18next/recommended", "plugin:i18next/recommended",
"plugin:i18n-json/recommended", "plugin:i18n-json/recommended",
], ],
settings: {
react: {
version: "detect",
},
},
rules: { rules: {
// general things turned off for now // general things turned off for now
"prefer-const": "off",
"no-debugger": "warn", "no-debugger": "warn",
"eol-last": "off", "eol-last": "off",
"comma-dangle": ["off", "always-multiline"], "comma-dangle": ["off", "always-multiline"],
"no-void": ["off"], "no-void": ["off"],
"array-callback-return": ["off"], "array-callback-return": ["off"],
"react/display-name": "warn",
quotes: ["off", "double"],
semi: ["off", "always"],
"no-multiple-empty-lines": ["off", { max: 2, maxEOF: 1 }],
yoda: ["off"],
eqeqeq: ["off"],
"spaced-comment": ["off"], "spaced-comment": ["off"],
"padded-blocks": ["off"], "padded-blocks": ["off"],
"no-multiple-empty-lines": ["off", { max: 2, maxEOF: 1 }],
quotes: ["off", "double"],
semi: ["off", "always"],
yoda: ["off"],
eqeqeq: ["off"],
"react/display-name": "warn",
// TS THINGS WE DONT WANT
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/ban-ts-comment": "off",
// TS WARNINGS WE WANT
"@typescript-eslint/no-unused-vars": "warn",
// TS things turned off for now // TS things turned off for now
"@typescript-eslint/ban-ts-comment": "off", // "@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/restrict-template-expressions": "off", "@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-optional-chain": "off", "@typescript-eslint/prefer-optional-chain": "off",
"@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-non-null-assertion": "off",

View File

@ -4,7 +4,6 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"lint": "eslint --ext .tsx --fix src",
"pretty": "prettier --write .", "pretty": "prettier --write .",
"dev": "vite", "dev": "vite",
"build": "tsc && vite build --emptyOutDir", "build": "tsc && vite build --emptyOutDir",

View File

@ -11,7 +11,7 @@ export const API_URL = import.meta.env.DEV ? "http://localhost:9000" : "";
export const HEALTH_PING_INTERVAL = 5000; // 5 seconds export const HEALTH_PING_INTERVAL = 5000; // 5 seconds
export const healthPing = async () => { export const healthPing = async () => {
const pingUrl = `${API_URL}/ping`; const pingUrl = `${API_URL}/ping`;
let response = await fetch(pingUrl); const response = await fetch(pingUrl);
const data = await response.json(); const data = await response.json();
return data; return data;
}; };

View File

@ -34,9 +34,9 @@ export default function BetaMode() {
// TODO: make this a custom hook // TODO: make this a custom hook
useEffect(() => { useEffect(() => {
if (configStatus === "success") { if (configStatus === "success") {
const { update_branch } = configData; const { update_branch: updateBranch } = configData;
if (update_branch === "main") { if (updateBranch === "main") {
setBranchToGetNext("beta"); setBranchToGetNext("beta");
} else { } else {
// setIsBeta(true); // setIsBeta(true);

View File

@ -14,10 +14,10 @@ import {
export default function GpuSettings() { export default function GpuSettings() {
const turbo = useImageCreate((state) => state.getValueForRequestKey("turbo")); const turbo = useImageCreate((state) => state.getValueForRequestKey("turbo"));
const use_cpu = useImageCreate((state) => const useCpu = useImageCreate((state) =>
state.getValueForRequestKey("use_cpu") state.getValueForRequestKey("use_cpu")
); );
const use_full_precision = useImageCreate((state) => const useFullPrecision = useImageCreate((state) =>
state.getValueForRequestKey("use_full_precision") state.getValueForRequestKey("use_full_precision")
); );
@ -48,7 +48,7 @@ export default function GpuSettings() {
<label> <label>
<input <input
type="checkbox" type="checkbox"
checked={use_cpu} checked={useCpu}
onChange={(e) => setRequestOption("use_cpu", e.target.checked)} onChange={(e) => setRequestOption("use_cpu", e.target.checked)}
/> />
Use CPU instead of GPU (warning: this will be *very* slow) Use CPU instead of GPU (warning: this will be *very* slow)
@ -57,7 +57,7 @@ export default function GpuSettings() {
<div className={SettingItem}> <div className={SettingItem}>
<label> <label>
<input <input
checked={use_full_precision} checked={useFullPrecision}
onChange={(e) => onChange={(e) =>
setRequestOption("use_full_precision", e.target.checked) setRequestOption("use_full_precision", e.target.checked)
} }

View File

@ -18,11 +18,11 @@ export default function ImprovementSettings() {
const isUsingUpscaling = useImageCreate((state) => state.isUsingUpscaling()); const isUsingUpscaling = useImageCreate((state) => state.isUsingUpscaling());
const use_upscale = useImageCreate((state) => const useUpscale = useImageCreate((state) =>
state.getValueForRequestKey("use_upscale") state.getValueForRequestKey("use_upscale")
); );
const show_only_filtered_image = useImageCreate((state) => const filteredOnly = useImageCreate((state) =>
state.getValueForRequestKey("show_only_filtered_image") state.getValueForRequestKey("show_only_filtered_image")
); );
@ -45,7 +45,7 @@ export default function ImprovementSettings() {
useEffect(() => { useEffect(() => {
// if either are true we arent disabled // if either are true we arent disabled
if (isUsingFaceCorrection || use_upscale) { if (isUsingFaceCorrection || useUpscale) {
setIsFilteringDisabled(false); setIsFilteringDisabled(false);
} else { } else {
setIsFilteringDisabled(true); setIsFilteringDisabled(true);
@ -79,7 +79,7 @@ export default function ImprovementSettings() {
<select <select
id="upscale_model" id="upscale_model"
name="upscale_model" name="upscale_model"
value={use_upscale} value={useUpscale}
onChange={(e) => { onChange={(e) => {
setRequestOption("use_upscale", e.target.value); setRequestOption("use_upscale", e.target.value);
}} }}
@ -97,7 +97,7 @@ export default function ImprovementSettings() {
<input <input
disabled={isFilteringDisabled} disabled={isFilteringDisabled}
type="checkbox" type="checkbox"
checked={show_only_filtered_image} checked={filteredOnly}
onChange={(e) => onChange={(e) =>
setRequestOption("show_only_filtered_image", e.target.checked) setRequestOption("show_only_filtered_image", e.target.checked)
} }

View File

@ -39,15 +39,15 @@ export default function PropertySettings() {
const steps = useImageCreate((state) => const steps = useImageCreate((state) =>
state.getValueForRequestKey("num_inference_steps") state.getValueForRequestKey("num_inference_steps")
); );
const guidance_scale = useImageCreate((state) => const guidanceScale = useImageCreate((state) =>
state.getValueForRequestKey("guidance_scale") state.getValueForRequestKey("guidance_scale")
); );
const init_image = useImageCreate((state) => const initImage = useImageCreate((state) =>
state.getValueForRequestKey("init_image") state.getValueForRequestKey("init_image")
); );
const prompt_strength = useImageCreate((state) => const promptStrength = useImageCreate((state) =>
state.getValueForRequestKey("prompt_strength") state.getValueForRequestKey("prompt_strength")
); );
@ -106,7 +106,7 @@ export default function PropertySettings() {
<label> <label>
Guidance Scale: Guidance Scale:
<input <input
value={guidance_scale} value={guidanceScale}
onChange={(e) => onChange={(e) =>
setRequestOption("guidance_scale", e.target.value) setRequestOption("guidance_scale", e.target.value)
} }
@ -116,15 +116,15 @@ export default function PropertySettings() {
step=".1" step=".1"
/> />
</label> </label>
<span>{guidance_scale}</span> <span>{guidanceScale}</span>
</div> </div>
{init_image && ( {initImage && (
<div className={SettingItem}> <div className={SettingItem}>
<label> <label>
Prompt Strength:{" "} Prompt Strength:{" "}
<input <input
value={prompt_strength} value={promptStrength}
onChange={(e) => onChange={(e) =>
setRequestOption("prompt_strength", e.target.value) setRequestOption("prompt_strength", e.target.value)
} }
@ -134,7 +134,7 @@ export default function PropertySettings() {
step=".05" step=".05"
/> />
</label> </label>
<span>{prompt_strength}</span> <span>{promptStrength}</span>
</div> </div>
)} )}

View File

@ -12,12 +12,12 @@ import {
} from "../advancedsettings.css.ts"; } from "../advancedsettings.css.ts";
export default function WorkflowSettings() { export default function WorkflowSettings() {
const num_outputs = useImageCreate((state) => const numOutputs = useImageCreate((state) =>
state.getValueForRequestKey("num_outputs") state.getValueForRequestKey("num_outputs")
); );
const parallelCount = useImageCreate((state) => state.parallelCount); const parallelCount = useImageCreate((state) => state.parallelCount);
const isUseAutoSave = useImageCreate((state) => state.isUseAutoSave()); const isUseAutoSave = useImageCreate((state) => state.isUseAutoSave());
const save_to_disk_path = useImageCreate((state) => const diskPath = useImageCreate((state) =>
state.getValueForRequestKey("save_to_disk_path") state.getValueForRequestKey("save_to_disk_path")
); );
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled()); const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
@ -46,7 +46,7 @@ export default function WorkflowSettings() {
Number of images to make:{" "} Number of images to make:{" "}
<input <input
type="number" type="number"
value={num_outputs} value={numOutputs}
onChange={(e) => onChange={(e) =>
setRequestOption("num_outputs", parseInt(e.target.value, 10)) setRequestOption("num_outputs", parseInt(e.target.value, 10))
} }
@ -76,7 +76,7 @@ export default function WorkflowSettings() {
</label> </label>
<label> <label>
<input <input
value={save_to_disk_path} value={diskPath}
onChange={(e) => onChange={(e) =>
setRequestOption("save_to_disk_path", e.target.value) setRequestOption("save_to_disk_path", e.target.value)
} }

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useImageCreate } from "../../../../../stores/imageCreateStore"; import { useImageCreate } from "../../../../../stores/imageCreateStore";
@ -26,7 +27,7 @@ export default function MakeButton() {
// the request that we have built // the request that we have built
const req = builtRequest(); const req = builtRequest();
// the actual number of request we will make // the actual number of request we will make
let requests = []; const requests = [];
// the number of images we will make // the number of images we will make
let { num_outputs } = req; let { num_outputs } = req;

View File

@ -15,7 +15,7 @@ import { useImageCreate } from "../../../../../stores/imageCreateStore";
export default function SeedImage(_props: any) { export default function SeedImage(_props: any) {
const imageInputRef = useRef<HTMLInputElement>(null); const imageInputRef = useRef<HTMLInputElement>(null);
const init_image = useImageCreate((state) => const initImage = useImageCreate((state) =>
state.getValueForRequestKey("init_image") state.getValueForRequestKey("init_image")
); );
@ -70,10 +70,10 @@ export default function SeedImage(_props: any) {
</div> </div>
<div className={ImageFixer}> <div className={ImageFixer}>
{init_image && ( {initImage && (
<> <>
<div> <div>
<img src={init_image} width="100" height="100" /> <img src={initImage} width="100" height="100" />
<button className={XButton} onClick={_handleClearImage}> <button className={XButton} onClick={_handleClearImage}>
X X
</button> </button>

View File

@ -1,4 +1,4 @@
import React, { useRef, useState, ChangeEvent, MouseEventHandler } from "react"; import React, { useRef, useState, ChangeEvent } from "react";
import DrawImage from "../../../molecules/drawImage"; import DrawImage from "../../../molecules/drawImage";
import { useImageCreate } from "../../../../stores/imageCreateStore"; import { useImageCreate } from "../../../../stores/imageCreateStore";
@ -18,7 +18,7 @@ export default function InpaintingPanel() {
const [brushColor, setBrushColor] = useState("#fff"); const [brushColor, setBrushColor] = useState("#fff");
const [isErasing, setIsErasing] = useState(false); const [isErasing, setIsErasing] = useState(false);
const init_image = useImageCreate((state) => const initImage = useImageCreate((state) =>
state.getValueForRequestKey("init_image") state.getValueForRequestKey("init_image")
); );
@ -48,7 +48,7 @@ export default function InpaintingPanel() {
<div className={InpaintingPanelMain}> <div className={InpaintingPanelMain}>
<DrawImage <DrawImage
// ref={drawingRef} // ref={drawingRef}
imageData={init_image} imageData={initImage}
brushSize={brushSize} brushSize={brushSize}
brushShape={brushShape} brushShape={brushShape}
brushColor={brushColor} brushColor={brushColor}

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
import React from "react"; import React from "react";
import GeneratedImage from "../../../molecules/generatedImage"; import GeneratedImage from "../../../molecules/generatedImage";
import { import {
@ -27,7 +28,7 @@ export default function CurrentDisplay({ isLoading, image }: CurrentDisplayProps
use_upscale, use_upscale,
width, width,
height, height,
} = info!; } = info! as ImageRequest;
// Most important information is the prompt // Most important information is the prompt

View File

@ -24,12 +24,12 @@ export default function HeaderDisplay() {
useEffect(() => { useEffect(() => {
if (status === "success") { if (status === "success") {
// TODO also pass down the actual version // TODO also pass down the actual version
const { update_branch } = data; const { update_branch: updateBranch } = data;
// just hard coded for now // just hard coded for now
setVersion("v2.1"); setVersion("v2.1");
if (update_branch === "main") { if (updateBranch === "main") {
setRelease("(stable)"); setRelease("(stable)");
} else { } else {
setRelease("(beta)"); setRelease("(beta)");

View File

@ -17,8 +17,8 @@ interface ImageQueueState {
// figure out why TS is complaining about this // figure out why TS is complaining about this
// @ts-ignore // @ts-ignore
export const useImageQueue = create<ImageQueueState>((set, get) => ({ export const useImageQueue = create<ImageQueueState>((set, get) => ({
images: new Array(), images: [],
completedImageIds: new Array(), completedImageIds: [],
// use produce to make sure we don't mutate state // use produce to make sure we don't mutate state
addNewImage: (id: string, imgRec: ImageRequest, isRandom = false) => { addNewImage: (id: string, imgRec: ImageRequest, isRandom = false) => {
set( set(

View File

@ -79,7 +79,7 @@ const app = createGlobalTheme(":root", {
}, },
}, },
colors: colors, colors,
}); });
export const darkTheme = createTheme(colors, { export const darkTheme = createTheme(colors, {