mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-28 18:28:12 +08:00
Restore ESLint and Prettier auto-formatting and CI linting (#1457)
* Restore ESLint and Prettier autoformatting * Fix formatting and lints in web files * Hacky fix to eslint crash * Fix remaining lints * Add lint-fix script --------- Co-authored-by: 0hypercube <0hypercube@gmail.com>
This commit is contained in:
co-authored by
0hypercube
parent
9784d31edb
commit
a6ca43bb2d
@@ -1,4 +1,4 @@
|
||||
import {writable} from "svelte/store";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { type IconName } from "@graphite/utility-functions/icons";
|
||||
import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
@@ -17,18 +17,18 @@ export function createDialogState(editor: Editor) {
|
||||
panicDetails: "",
|
||||
});
|
||||
|
||||
function dismissDialog(): void {
|
||||
function dismissDialog() {
|
||||
update((state) => {
|
||||
// Disallow dismissing the crash dialog since it can confuse users why the app stopped responding if they dismiss it without realizing what it means
|
||||
if (state.panicDetails === "") state.visible = false;
|
||||
|
||||
|
||||
return state;
|
||||
});
|
||||
}
|
||||
|
||||
// Creates a crash dialog from JS once the editor has panicked.
|
||||
// Normal dialogs are created in the Rust backend, but for the crash dialog, the editor instance has panicked so it cannot respond to widget callbacks.
|
||||
function createCrashDialog(panicDetails: string): void {
|
||||
function createCrashDialog(panicDetails: string) {
|
||||
update((state) => {
|
||||
state.visible = true;
|
||||
|
||||
@@ -51,7 +51,7 @@ export function createDialogState(editor: Editor) {
|
||||
|
||||
state.title = displayDialog.title;
|
||||
state.icon = displayDialog.icon;
|
||||
|
||||
|
||||
return state;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {tick} from "svelte";
|
||||
import {writable} from "svelte/store";
|
||||
import { tick } from "svelte";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
import {
|
||||
@@ -35,7 +35,7 @@ export function createDocumentState(editor: Editor) {
|
||||
// Update layouts
|
||||
editor.subscriptions.subscribeJsMessage(UpdateDocumentModeLayout, async (updateDocumentModeLayout) => {
|
||||
await tick();
|
||||
|
||||
|
||||
update((state) => {
|
||||
// `state.documentModeLayout` is mutated in the function
|
||||
patchWidgetLayout(state.documentModeLayout, updateDocumentModeLayout);
|
||||
@@ -44,7 +44,7 @@ export function createDocumentState(editor: Editor) {
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateToolOptionsLayout, async (updateToolOptionsLayout) => {
|
||||
await tick();
|
||||
|
||||
|
||||
update((state) => {
|
||||
// `state.documentModeLayout` is mutated in the function
|
||||
patchWidgetLayout(state.toolOptionsLayout, updateToolOptionsLayout);
|
||||
@@ -53,7 +53,7 @@ export function createDocumentState(editor: Editor) {
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateDocumentBarLayout, async (updateDocumentBarLayout) => {
|
||||
await tick();
|
||||
|
||||
|
||||
update((state) => {
|
||||
// `state.documentModeLayout` is mutated in the function
|
||||
patchWidgetLayout(state.documentBarLayout, updateDocumentBarLayout);
|
||||
@@ -62,7 +62,7 @@ export function createDocumentState(editor: Editor) {
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateToolShelfLayout, async (updateToolShelfLayout) => {
|
||||
await tick();
|
||||
|
||||
|
||||
update((state) => {
|
||||
// `state.documentModeLayout` is mutated in the function
|
||||
patchWidgetLayout(state.toolShelfLayout, updateToolShelfLayout);
|
||||
@@ -79,7 +79,7 @@ export function createDocumentState(editor: Editor) {
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateWorkingColorsLayout, async (updateWorkingColorsLayout) => {
|
||||
await tick();
|
||||
|
||||
|
||||
update((state) => {
|
||||
// `state.documentModeLayout` is mutated in the function
|
||||
patchWidgetLayout(state.workingColorsLayout, updateWorkingColorsLayout);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {writable} from "svelte/store";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
|
||||
@@ -9,7 +9,7 @@ export function createFullscreenState(_: Editor) {
|
||||
keyboardLocked: false,
|
||||
});
|
||||
|
||||
function fullscreenModeChanged(): void {
|
||||
function fullscreenModeChanged() {
|
||||
update((state) => {
|
||||
state.windowFullscreen = Boolean(document.fullscreenElement);
|
||||
if (!state.windowFullscreen) state.keyboardLocked = false;
|
||||
@@ -17,7 +17,7 @@ export function createFullscreenState(_: Editor) {
|
||||
});
|
||||
}
|
||||
|
||||
async function enterFullscreen(): Promise<void> {
|
||||
async function enterFullscreen() {
|
||||
await document.documentElement.requestFullscreen();
|
||||
|
||||
if (keyboardLockApiSupported) {
|
||||
@@ -31,11 +31,11 @@ export function createFullscreenState(_: Editor) {
|
||||
}
|
||||
}
|
||||
|
||||
async function exitFullscreen(): Promise<void> {
|
||||
async function exitFullscreen() {
|
||||
await document.exitFullscreen();
|
||||
}
|
||||
|
||||
async function toggleFullscreen(): Promise<void> {
|
||||
async function toggleFullscreen() {
|
||||
return new Promise((resolve, reject) => {
|
||||
update((state) => {
|
||||
if (state.windowFullscreen) exitFullscreen().then(resolve).catch(reject);
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import {writable} from "svelte/store";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
import {
|
||||
type FrontendNode,
|
||||
type FrontendNodeLink,
|
||||
type FrontendNodeType,
|
||||
UpdateNodeGraph,
|
||||
UpdateNodeTypes,
|
||||
UpdateNodeThumbnail,
|
||||
UpdateZoomWithScroll,
|
||||
} from "@graphite/wasm-communication/messages";
|
||||
import { type FrontendNode, type FrontendNodeLink, type FrontendNodeType, UpdateNodeGraph, UpdateNodeTypes, UpdateNodeThumbnail, UpdateZoomWithScroll } from "@graphite/wasm-communication/messages";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export function createNodeGraphState(editor: Editor) {
|
||||
@@ -26,11 +18,10 @@ export function createNodeGraphState(editor: Editor) {
|
||||
update((state) => {
|
||||
state.nodes = updateNodeGraph.nodes;
|
||||
state.links = updateNodeGraph.links;
|
||||
let newThumbnails = new Map<bigint, string>();
|
||||
const newThumbnails = new Map<bigint, string>();
|
||||
state.nodes.forEach((node) => {
|
||||
const thumbnail = state.thumbnails.get(node.id);
|
||||
if (thumbnail)
|
||||
newThumbnails.set(node.id, thumbnail);
|
||||
if (thumbnail) newThumbnails.set(node.id, thumbnail);
|
||||
});
|
||||
state.thumbnails = newThumbnails;
|
||||
return state;
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
import { downloadFileText, downloadFileBlob, upload, downloadFileURL } from "@graphite/utility-functions/files";
|
||||
import { copyToClipboardFileURL } from "@graphite/io-managers/clipboard";
|
||||
import { downloadFileText, downloadFileBlob, upload } from "@graphite/utility-functions/files";
|
||||
import { extractPixelData, imageToPNG, rasterizeSVG, rasterizeSVGCanvas } from "@graphite/utility-functions/rasterization";
|
||||
import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
import {
|
||||
@@ -20,7 +21,6 @@ import {
|
||||
UpdateImageData,
|
||||
UpdateOpenDocumentsList,
|
||||
} from "@graphite/wasm-communication/messages";
|
||||
import { copyToClipboardFileURL } from "@graphite/io-managers/clipboard";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export function createPortfolioState(editor: Editor) {
|
||||
@@ -35,7 +35,7 @@ export function createPortfolioState(editor: Editor) {
|
||||
update((state) => {
|
||||
state.documents = updateOpenDocumentList.openDocuments;
|
||||
return state;
|
||||
})
|
||||
});
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateActiveDocument, (updateActiveDocument) => {
|
||||
update((state) => {
|
||||
@@ -43,7 +43,7 @@ export function createPortfolioState(editor: Editor) {
|
||||
const activeId = state.documents.findIndex((doc) => doc.id === updateActiveDocument.documentId);
|
||||
state.activeDocumentIndex = activeId;
|
||||
return state;
|
||||
})
|
||||
});
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerFetchAndOpenDocument, async (triggerFetchAndOpenDocument) => {
|
||||
try {
|
||||
@@ -98,7 +98,6 @@ export function createPortfolioState(editor: Editor) {
|
||||
} catch {
|
||||
// Fail silently if there's an error rasterizing the SVG, such as a zero-sized image
|
||||
}
|
||||
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateImageData, (updateImageData) => {
|
||||
updateImageData.imageData.forEach(async (element) => {
|
||||
@@ -126,12 +125,11 @@ export function createPortfolioState(editor: Editor) {
|
||||
|
||||
editor.instance.renderGraphUsingRasterizedRegionBelowLayer(documentId, layerPath, new Uint8Array(imageData.data), imageData.width, imageData.height);
|
||||
}
|
||||
}
|
||||
// getImageData may throw an exception if the resolution is too high
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
// getImageData may throw an exception if the resolution is too high
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Failed to rasterize the SVG canvas in JS to be sent back to Rust:", e);
|
||||
}
|
||||
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerRevokeBlobUrl, async (triggerRevokeBlobUrl) => {
|
||||
URL.revokeObjectURL(triggerRevokeBlobUrl.url);
|
||||
|
||||
Reference in New Issue
Block a user