diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5ca0ed8c6..f8e358ac8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -129,10 +129,10 @@ async fn get_user( fn main() { tauri::Builder::default() - .setup(|app| { + .setup(|_app| { #[cfg(debug_assertions)] // only include this code on debug builds { - let window = app.get_window("main").unwrap(); + let window = _app.get_window("main").unwrap(); // comment out the below if you don't devtools to open everytime. // it's useful because otherwise devtools shuts everytime rust code changes. window.open_devtools(); diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 5e8804d37..fb49dee9c 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -1,4 +1,3 @@ -import { ToolTip } from './useStore' import { Fragment, WheelEvent, useRef, useMemo } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faSearch, faX } from '@fortawesome/free-solid-svg-icons' @@ -15,23 +14,6 @@ export const sketchButtonClassnames = { icon: 'text-fern-20 h-auto group-hover:text-fern-10 hover:text-fern-10 dark:text-chalkboard-100 dark:group-hover:text-chalkboard-100 dark:hover:text-chalkboard-100 group-disabled:bg-chalkboard-60 hover:group-disabled:text-inherit', } -const sketchFnLabels: Record = { - sketch_line: 'Line', - line: 'Line', - move: 'Move', - angledLine: 'Angled Line', - angledLineThatIntersects: 'Angled Line That Intersects', - angledLineOfXLength: 'Angled Line Of X Length', - angledLineOfYLength: 'Angled Line Of Y Length', - angledLineToX: 'Angled Line To X', - angledLineToY: 'Angled Line To Y', - lineTo: 'Line to Point', - xLine: 'Horizontal Line', - yLine: 'Vertical Line', - xLineTo: 'Horizontal Line to Point', - yLineTo: 'Vertical Line to Point', -} - export const Toolbar = () => { const { state, send, context } = useModelingContext() const toolbarButtonsRef = useRef(null) diff --git a/src/components/AstExplorer.tsx b/src/components/AstExplorer.tsx index 1ac3b5196..f1c6c07c3 100644 --- a/src/components/AstExplorer.tsx +++ b/src/components/AstExplorer.tsx @@ -184,6 +184,7 @@ function DisplayObj({ ) } + return null })} diff --git a/src/components/FileTree.tsx b/src/components/FileTree.tsx index 101f5d4f9..f9f3bf0dc 100644 --- a/src/components/FileTree.tsx +++ b/src/components/FileTree.tsx @@ -2,7 +2,7 @@ import { IndexLoaderData, paths } from 'Router' import { ActionButton } from './ActionButton' import Tooltip from './Tooltip' import { FileEntry } from '@tauri-apps/api/fs' -import { Dispatch, useEffect, useRef, useState } from 'react' +import { Dispatch, useRef, useState } from 'react' import { useNavigate } from 'react-router-dom' import { Dialog, Disclosure } from '@headlessui/react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' diff --git a/src/components/ModelingMachineProvider.tsx b/src/components/ModelingMachineProvider.tsx index c51241e07..a09247201 100644 --- a/src/components/ModelingMachineProvider.tsx +++ b/src/components/ModelingMachineProvider.tsx @@ -20,7 +20,6 @@ import { recast, parse, Program, - VariableDeclarator, PipeExpression, CallExpression, } from 'lang/wasm' diff --git a/src/components/Stream.tsx b/src/components/Stream.tsx index 765d45337..b55cb5784 100644 --- a/src/components/Stream.tsx +++ b/src/components/Stream.tsx @@ -267,11 +267,11 @@ export const Stream = ({ className = '' }) => { } engineCommandManager.sendSceneCommand(command).then(async () => { if (!context.sketchPathToNode) return - const varDec = getNodeFromPath( + getNodeFromPath( kclManager.ast, context.sketchPathToNode, 'VariableDeclarator' - ).node + ) // Get the current plane string for plane we are on. let currentPlaneString = '' if (context.sketchPlaneId === kclManager.getPlaneId('xy')) { diff --git a/src/components/Toolbar/EqualLength.tsx b/src/components/Toolbar/EqualLength.tsx index 9ff476b2b..5d5202142 100644 --- a/src/components/Toolbar/EqualLength.tsx +++ b/src/components/Toolbar/EqualLength.tsx @@ -69,7 +69,7 @@ export function applyConstraintEqualLength({ modifiedAst: Program pathToNodeMap: PathToNodeMap } { - const { enabled, transforms } = setEqualLengthInfo({ selectionRanges }) + const { transforms } = setEqualLengthInfo({ selectionRanges }) const { modifiedAst, pathToNodeMap } = transformSecondarySketchLinesTagFirst({ ast: kclManager.ast, selectionRanges, diff --git a/src/editor/lsp/client.ts b/src/editor/lsp/client.ts index bc96c1584..075126787 100644 --- a/src/editor/lsp/client.ts +++ b/src/editor/lsp/client.ts @@ -108,6 +108,7 @@ export default class Client extends jsrpc.JSONRPCServerAndClient { break } } + // eslint-disable-next-line @typescript-eslint/no-unused-vars messageString += message return }) diff --git a/src/hooks/useEngineConnectionSubscriptions.ts b/src/hooks/useEngineConnectionSubscriptions.ts index 8e83b2e18..df550292c 100644 --- a/src/hooks/useEngineConnectionSubscriptions.ts +++ b/src/hooks/useEngineConnectionSubscriptions.ts @@ -2,8 +2,6 @@ import { useEffect } from 'react' import { useStore } from 'useStore' import { engineCommandManager } from '../lang/std/engineConnection' import { useModelingContext } from './useModelingContext' -import { v4 as uuidv4 } from 'uuid' -import { SourceRange } from 'lang/wasm' import { getEventForSelectWithPoint } from 'lib/selections' export function useEngineConnectionSubscriptions() { @@ -13,11 +11,6 @@ export function useEngineConnectionSubscriptions() { })) const { send, context } = useModelingContext() - interface RangeAndId { - id: string - range: SourceRange - } - useEffect(() => { if (!engineCommandManager) return diff --git a/src/hooks/useSetupEngineManager.ts b/src/hooks/useSetupEngineManager.ts index c568a1d2f..73b1dd8a5 100644 --- a/src/hooks/useSetupEngineManager.ts +++ b/src/hooks/useSetupEngineManager.ts @@ -1,5 +1,5 @@ import { useLayoutEffect, useEffect, useRef } from 'react' -import { _executor, parse } from '../lang/wasm' +import { parse } from '../lang/wasm' import { useStore } from '../useStore' import { engineCommandManager } from '../lang/std/engineConnection' import { deferExecution } from 'lib/utils' diff --git a/src/lang/modifyAst.ts b/src/lang/modifyAst.ts index df4f97e9d..8da1a5524 100644 --- a/src/lang/modifyAst.ts +++ b/src/lang/modifyAst.ts @@ -310,7 +310,7 @@ export function extrudeSketch( const name = findUniqueName(node, 'part') const VariableDeclaration = createVariableDeclaration(name, extrudeCall) let showCallIndex = getShowIndex(_node) - if (showCallIndex == -1) { + if (showCallIndex === -1) { // We didn't find a show, so let's just append everything showCallIndex = _node.body.length } diff --git a/src/lang/std/engineConnection.ts b/src/lang/std/engineConnection.ts index f3ec96efe..bbb5e80a2 100644 --- a/src/lang/std/engineConnection.ts +++ b/src/lang/std/engineConnection.ts @@ -982,7 +982,7 @@ export class EngineCommandManager { if (parseCommand.type === 'modeling_cmd_req') return this.handlePendingCommand(id, parseCommand?.cmd, range) } - throw 'shouldnt reach here' + throw Error('shouldnt reach here') } handlePendingCommand( id: string, diff --git a/src/lang/std/sketch.ts b/src/lang/std/sketch.ts index 74efa2330..c91d22eea 100644 --- a/src/lang/std/sketch.ts +++ b/src/lang/std/sketch.ts @@ -20,7 +20,6 @@ import { import { isLiteralArrayOrStatic } from './sketchcombos' import { toolTips, ToolTip } from '../../useStore' import { createPipeExpression, splitPathAtPipeExpression } from '../modifyAst' -import { generateUuidFromHashSeed } from '../../lib/uuid' import { SketchLineHelper, ModifyAstBase, TransformCallback } from './stdTypes' @@ -92,18 +91,12 @@ export function createFirstArg( throw new Error('all sketch line types should have been covered') } +// eslint-disable-next-line @typescript-eslint/no-unused-vars type LineData = { from: [number, number, number] to: [number, number, number] } -function makeId(seed: string | any) { - if (typeof seed === 'string') { - return generateUuidFromHashSeed(seed) - } - return generateUuidFromHashSeed(JSON.stringify(seed)) -} - export const lineTo: SketchLineHelper = { add: ({ node, @@ -250,9 +243,6 @@ export const line: SketchLineHelper = { ]) if (callExpression.arguments?.[0].type === 'ObjectExpression') { - const toProp = callExpression.arguments?.[0].properties?.find( - ({ key }) => key.name === 'to' - ) mutateObjExpProp(callExpression.arguments?.[0], toArrExp, 'to') } else { mutateArrExp(callExpression.arguments?.[0], toArrExp) @@ -974,14 +964,12 @@ export function addNewSketchLn({ const node = JSON.parse(JSON.stringify(_node)) const { add, updateArgs } = sketchLineHelperMap?.[fnName] || {} if (!add || !updateArgs) throw new Error('not a sketch line helper') - const { node: varDec } = getNodeFromPath( + getNodeFromPath(node, pathToNode, 'VariableDeclarator') + getNodeFromPath( node, pathToNode, - 'VariableDeclarator' + 'PipeExpression' ) - const { node: pipeExp, shallowPath: pipePath } = getNodeFromPath< - PipeExpression | CallExpression - >(node, pathToNode, 'PipeExpression') return add({ node, previousProgramMemory, diff --git a/src/lib/testHelpers.ts b/src/lib/testHelpers.ts index 02100124c..e1a382786 100644 --- a/src/lib/testHelpers.ts +++ b/src/lib/testHelpers.ts @@ -9,6 +9,7 @@ import { v4 as uuidv4 } from 'uuid' type WebSocketResponse = Models['OkWebSocketResponseData_type'] class MockEngineCommandManager { + // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor(mockParams: { setIsStreamReady: (isReady: boolean) => void setMediaStream: (stream: MediaStream) => void diff --git a/src/machines/modelingMachine.ts b/src/machines/modelingMachine.ts index a643da886..63c298d8b 100644 --- a/src/machines/modelingMachine.ts +++ b/src/machines/modelingMachine.ts @@ -882,7 +882,7 @@ export const modelingMachine = createMachine( // TODO implement source ranges for all of these constraints // need to make the async like the modal constraints 'Make selection horizontal': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert( + const { modifiedAst } = applyConstraintHorzVert( selectionRanges, 'horizontal', kclManager.ast, @@ -891,7 +891,7 @@ export const modelingMachine = createMachine( kclManager.updateAst(modifiedAst, true) }, 'Make selection vertical': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert( + const { modifiedAst } = applyConstraintHorzVert( selectionRanges, 'vertical', kclManager.ast, @@ -900,33 +900,33 @@ export const modelingMachine = createMachine( kclManager.updateAst(modifiedAst, true) }, 'Constrain horizontally align': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({ + const { modifiedAst } = applyConstraintHorzVertAlign({ selectionRanges, constraint: 'setVertDistance', }) kclManager.updateAst(modifiedAst, true) }, 'Constrain vertically align': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({ + const { modifiedAst } = applyConstraintHorzVertAlign({ selectionRanges, constraint: 'setHorzDistance', }) kclManager.updateAst(modifiedAst, true) }, 'Constrain equal length': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyConstraintEqualLength({ + const { modifiedAst } = applyConstraintEqualLength({ selectionRanges, }) kclManager.updateAst(modifiedAst, true) }, 'Constrain parallel': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyConstraintEqualAngle({ + const { modifiedAst } = applyConstraintEqualAngle({ selectionRanges, }) kclManager.updateAst(modifiedAst, true) }, 'Constrain remove constraints': ({ selectionRanges }) => { - const { modifiedAst, pathToNodeMap } = applyRemoveConstrainingValues({ + const { modifiedAst } = applyRemoveConstrainingValues({ selectionRanges, }) kclManager.updateAst(modifiedAst, true)