From 1c7056bdaa3a8986450fca2ae8e5f877ea42bfdc Mon Sep 17 00:00:00 2001 From: Lipis Date: Mon, 1 Nov 2021 15:24:05 +0200 Subject: [PATCH] chore: bump Prettier to the latest (#4185) --- package.json | 2 +- src/actions/actionDeleteSelected.tsx | 6 +- src/actions/actionFinalize.tsx | 7 +- src/actions/actionGroup.tsx | 5 +- src/appState.ts | 9 +-- src/components/App.tsx | 76 ++++++++++--------- src/components/CheckboxItem.tsx | 8 +- src/components/LayerUI.tsx | 60 ++++++++------- src/components/Tooltip.tsx | 6 +- src/components/icons.tsx | 8 +- src/data/restore.ts | 13 ++-- src/element/binding.ts | 53 +++++++------ src/element/bounds.ts | 4 +- src/element/collision.ts | 2 +- src/element/linearElementEditor.ts | 11 +-- src/element/resizeElements.ts | 16 ++-- src/element/resizeTest.ts | 16 ++-- src/element/transformHandles.ts | 6 +- src/excalidraw-app/collab/CollabWrapper.tsx | 26 +++---- src/excalidraw-app/collab/Portal.tsx | 4 +- src/excalidraw-app/collab/reconciliation.ts | 5 +- .../components/GitHubCorner.tsx | 5 +- src/excalidraw-app/data/FileManager.ts | 8 +- src/excalidraw-app/data/firebase.ts | 5 +- src/excalidraw-app/data/index.ts | 7 +- src/excalidraw-app/index.tsx | 9 +-- src/ga.ts | 2 +- src/galines.ts | 2 +- src/global.d.ts | 7 +- .../excalidraw/webpack.prod.config.js | 4 +- src/packages/utils/webpack.prod.config.js | 4 +- src/renderer/renderElement.ts | 12 +-- src/renderer/renderScene.ts | 23 ++---- src/scene/export.ts | 7 +- src/scene/scrollbars.ts | 8 +- src/scene/selection.ts | 13 +--- src/tests/contextmenu.test.tsx | 20 ++--- src/tests/helpers/api.ts | 2 +- src/tests/reconciliation.test.ts | 4 +- src/tests/regressionTests.test.tsx | 12 +-- src/tests/test-utils.ts | 3 +- src/utils.ts | 2 +- yarn.lock | 8 +- 43 files changed, 226 insertions(+), 284 deletions(-) diff --git a/package.json b/package.json index 87c390ec..3fe719aa 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "jest-canvas-mock": "2.3.1", "lint-staged": "11.2.6", "pepjs": "0.5.3", - "prettier": "2.2.1", + "prettier": "2.4.1", "rewire": "5.0.0" }, "engines": { diff --git a/src/actions/actionDeleteSelected.tsx b/src/actions/actionDeleteSelected.tsx index 1be1019c..e38a4ed2 100644 --- a/src/actions/actionDeleteSelected.tsx +++ b/src/actions/actionDeleteSelected.tsx @@ -110,10 +110,8 @@ export const actionDeleteSelected = register({ }; } - let { - elements: nextElements, - appState: nextAppState, - } = deleteSelectedElements(elements, appState); + let { elements: nextElements, appState: nextAppState } = + deleteSelectedElements(elements, appState); fixBindingsAfterDeletion( nextElements, elements.filter(({ id }) => appState.selectedElementIds[id]), diff --git a/src/actions/actionFinalize.tsx b/src/actions/actionFinalize.tsx index cc91a3fc..e89112af 100644 --- a/src/actions/actionFinalize.tsx +++ b/src/actions/actionFinalize.tsx @@ -19,11 +19,8 @@ export const actionFinalize = register({ name: "finalize", perform: (elements, appState, _, { canvas, focusContainer }) => { if (appState.editingLinearElement) { - const { - elementId, - startBindingElement, - endBindingElement, - } = appState.editingLinearElement; + const { elementId, startBindingElement, endBindingElement } = + appState.editingLinearElement; const element = LinearElementEditor.getElement(elementId); if (element) { diff --git a/src/actions/actionGroup.tsx b/src/actions/actionGroup.tsx index 5da546fe..8a31b614 100644 --- a/src/actions/actionGroup.tsx +++ b/src/actions/actionGroup.tsx @@ -99,9 +99,8 @@ export const actionGroup = register({ // to the z order of the highest element in the layer stack const elementsInGroup = getElementsInGroup(updatedElements, newGroupId); const lastElementInGroup = elementsInGroup[elementsInGroup.length - 1]; - const lastGroupElementIndex = updatedElements.lastIndexOf( - lastElementInGroup, - ); + const lastGroupElementIndex = + updatedElements.lastIndexOf(lastElementInGroup); const elementsAfterGroup = updatedElements.slice(lastGroupElementIndex + 1); const elementsBeforeGroup = updatedElements .slice(0, lastGroupElementIndex) diff --git a/src/appState.ts b/src/appState.ts index f4daf771..a15a4e95 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -96,10 +96,9 @@ const APP_STATE_STORAGE_CONF = (< /** server (shareLink/collab/...) */ server: boolean; }, - T extends Record ->( - config: { [K in keyof T]: K extends keyof AppState ? T[K] : never }, -) => config)({ + T extends Record, +>(config: { [K in keyof T]: K extends keyof AppState ? T[K] : never }) => + config)({ theme: { browser: true, export: false, server: false }, collaborators: { browser: false, export: false, server: false }, currentChartType: { browser: true, export: false, server: false }, @@ -172,7 +171,7 @@ const APP_STATE_STORAGE_CONF = (< }); const _clearAppStateForStorage = < - ExportType extends "export" | "browser" | "server" + ExportType extends "export" | "browser" | "server", >( appState: Partial, exportType: ExportType, diff --git a/src/components/App.tsx b/src/components/App.tsx index aeb65290..310c5fc0 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -794,7 +794,8 @@ class App extends React.Component { }; public async componentDidMount() { - this.excalidrawContainerValue.container = this.excalidrawContainerRef.current; + this.excalidrawContainerValue.container = + this.excalidrawContainerRef.current; if ( process.env.NODE_ENV === ENV.TEST || @@ -836,10 +837,8 @@ class App extends React.Component { this.resizeObserver = new ResizeObserver(() => { // compute isMobile state // --------------------------------------------------------------------- - const { - width, - height, - } = this.excalidrawContainerRef.current!.getBoundingClientRect(); + const { width, height } = + this.excalidrawContainerRef.current!.getBoundingClientRect(); this.isMobile = width < MQ_MAX_WIDTH_PORTRAIT || (height < MQ_MAX_HEIGHT_LANDSCAPE && width < MQ_MAX_WIDTH_LANDSCAPE); @@ -1243,9 +1242,8 @@ class App extends React.Component { async (event: ClipboardEvent | null) => { // #686 const target = document.activeElement; - const isExcalidrawActive = this.excalidrawContainerRef.current?.contains( - target, - ); + const isExcalidrawActive = + this.excalidrawContainerRef.current?.contains(target); if (!isExcalidrawActive) { return; } @@ -2207,7 +2205,10 @@ class App extends React.Component { })); this.resetShouldCacheIgnoreZoomDebounced(); } else { - gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null; + gesture.lastCenter = + gesture.initialDistance = + gesture.initialScale = + null; } if (isHoldingSpace || isPanning || isDraggingScrollBar) { @@ -2516,13 +2517,11 @@ class App extends React.Component { ); } - const onPointerMove = this.onPointerMoveFromPointerDownHandler( - pointerDownState, - ); + const onPointerMove = + this.onPointerMoveFromPointerDownHandler(pointerDownState); - const onPointerUp = this.onPointerUpFromPointerDownHandler( - pointerDownState, - ); + const onPointerUp = + this.onPointerUpFromPointerDownHandler(pointerDownState); const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState); const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState); @@ -2727,10 +2726,11 @@ class App extends React.Component { allHitElements: [], wasAddedToSelection: false, hasBeenDuplicated: false, - hasHitCommonBoundingBoxOfSelectedElements: this.isHittingCommonBoundingBoxOfSelectedElements( - origin, - selectedElements, - ), + hasHitCommonBoundingBoxOfSelectedElements: + this.isHittingCommonBoundingBoxOfSelectedElements( + origin, + selectedElements, + ), }, drag: { hasOccurred: false, @@ -2807,14 +2807,15 @@ class App extends React.Component { const elements = this.scene.getElements(); const selectedElements = getSelectedElements(elements, this.state); if (selectedElements.length === 1 && !this.state.editingLinearElement) { - const elementWithTransformHandleType = getElementWithTransformHandleType( - elements, - this.state, - pointerDownState.origin.x, - pointerDownState.origin.y, - this.state.zoom, - event.pointerType, - ); + const elementWithTransformHandleType = + getElementWithTransformHandleType( + elements, + this.state, + pointerDownState.origin.x, + pointerDownState.origin.y, + this.state.zoom, + event.pointerType, + ); if (elementWithTransformHandleType != null) { this.setState({ resizingElement: elementWithTransformHandleType.element, @@ -2890,9 +2891,10 @@ class App extends React.Component { ); const hitElement = pointerDownState.hit.element; - const someHitElementIsSelected = pointerDownState.hit.allHitElements.some( - (element) => this.isASelectedElement(element), - ); + const someHitElementIsSelected = + pointerDownState.hit.allHitElements.some((element) => + this.isASelectedElement(element), + ); if ( (hitElement === null || !someHitElementIsSelected) && !event.shiftKey && @@ -3554,8 +3556,8 @@ class App extends React.Component { ? { // if using ctrl/cmd, select the hitElement only if we // haven't box-selected anything else - [pointerDownState.hit.element - .id]: !elementsWithinSelection.length, + [pointerDownState.hit.element.id]: + !elementsWithinSelection.length, } : null), }, @@ -4429,7 +4431,9 @@ class App extends React.Component { // This will only work as of Chrome 86, // but can be safely ignored on older releases. const item = event.dataTransfer.items[0]; - (file as any).handle = await (item as any).getAsFileSystemHandle(); + (file as any).handle = await ( + item as any + ).getAsFileSystemHandle(); } catch (error: any) { console.warn(error.name, error.message); } @@ -4551,10 +4555,8 @@ class App extends React.Component { const type = element ? "element" : "canvas"; const container = this.excalidrawContainerRef.current!; - const { - top: offsetTop, - left: offsetLeft, - } = container.getBoundingClientRect(); + const { top: offsetTop, left: offsetLeft } = + container.getBoundingClientRect(); const left = event.clientX - offsetLeft; const top = event.clientY - offsetTop; diff --git a/src/components/CheckboxItem.tsx b/src/components/CheckboxItem.tsx index fcda4837..41c28b86 100644 --- a/src/components/CheckboxItem.tsx +++ b/src/components/CheckboxItem.tsx @@ -13,9 +13,11 @@ export const CheckboxItem: React.FC<{ className={clsx("Checkbox", { "is-checked": checked })} onClick={(event) => { onChange(!checked); - ((event.currentTarget as HTMLDivElement).querySelector( - ".Checkbox-box", - ) as HTMLButtonElement).focus(); + ( + (event.currentTarget as HTMLDivElement).querySelector( + ".Checkbox-box", + ) as HTMLButtonElement + ).focus(); }} >