From 715903e3a029daceab6e57e021e69d94645b447b Mon Sep 17 00:00:00 2001 From: Trevor Crystal Date: Wed, 14 Sep 2022 21:34:48 -0400 Subject: [PATCH 1/3] Add eslint caching --- .gitignore | 2 ++ package.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bc6a21516..3c67ead47 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ tests/index.js app.yaml yarn-error.log +.eslintcache + # IntelliJ .idea/ diff --git a/package.json b/package.json index 2a4fdd3c5..b1852a888 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "build:jsdocs": "node ./build/scripts/docs/index.js", "test": "node ./build/scripts/test.js", "coverage": "node ./build/scripts/test.js --coverage", - "lint": "eslint .", - "lint:fix": "eslint . --fix", + "lint": "eslint . --cache", + "lint:fix": "eslint . --fix --cache", "postinstall": "tsc --project ./scripts/tsconfig.json && copyfiles ./scripts/utils/browser/openChrome.applescript ./build" }, "devDependencies": { From 9bfee75e9ebeea71200419ddf226e38053fd8800 Mon Sep 17 00:00:00 2001 From: Trevor Crystal Date: Wed, 14 Sep 2022 22:17:44 -0400 Subject: [PATCH 2/3] Require const enums --- linting/.core.cjs | 8 ++++++++ src/app/core/tools/WiringTool.ts | 2 +- src/site/pages/digital/src/utils/DigitalCreate.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/linting/.core.cjs b/linting/.core.cjs index 539f7ad92..9061d6e79 100644 --- a/linting/.core.cjs +++ b/linting/.core.cjs @@ -59,5 +59,13 @@ module.exports = { "arrow-body-style": "error", "arrow-spacing": "error", "eol-last": "error", + + "no-restricted-syntax": [ + "error", + { + "selector": "TSEnumDeclaration:not([const=true])", + "message": "Don't declare non-const enums", + }, + ], }, } diff --git a/src/app/core/tools/WiringTool.ts b/src/app/core/tools/WiringTool.ts index 8a8bdfaca..ff90a9018 100644 --- a/src/app/core/tools/WiringTool.ts +++ b/src/app/core/tools/WiringTool.ts @@ -12,7 +12,7 @@ import {Port, Wire} from "core/models"; export const WiringTool = (() => { - enum StateType { + const enum StateType { CLICKED, DRAGGED, } diff --git a/src/site/pages/digital/src/utils/DigitalCreate.ts b/src/site/pages/digital/src/utils/DigitalCreate.ts index 480531f8e..b4d42b724 100644 --- a/src/site/pages/digital/src/utils/DigitalCreate.ts +++ b/src/site/pages/digital/src/utils/DigitalCreate.ts @@ -75,7 +75,7 @@ export function DigitalCreateN(pos: Vector, itemId: string, designer: DigitalCir } -export enum SmartPlaceOptions { +export const enum SmartPlaceOptions { Off = 0, Inputs = 1 << 0, Outputs = 1 << 1, From 47b7f1f727f410c4a3df7fa1bf164df0668c4e03 Mon Sep 17 00:00:00 2001 From: Trevor Crystal Date: Sun, 18 Sep 2022 14:38:22 -0400 Subject: [PATCH 3/3] No longer require const enum --- linting/.core.cjs | 8 -------- src/app/core/tools/WiringTool.ts | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/linting/.core.cjs b/linting/.core.cjs index 9061d6e79..539f7ad92 100644 --- a/linting/.core.cjs +++ b/linting/.core.cjs @@ -59,13 +59,5 @@ module.exports = { "arrow-body-style": "error", "arrow-spacing": "error", "eol-last": "error", - - "no-restricted-syntax": [ - "error", - { - "selector": "TSEnumDeclaration:not([const=true])", - "message": "Don't declare non-const enums", - }, - ], }, } diff --git a/src/app/core/tools/WiringTool.ts b/src/app/core/tools/WiringTool.ts index ff90a9018..40dcd7160 100644 --- a/src/app/core/tools/WiringTool.ts +++ b/src/app/core/tools/WiringTool.ts @@ -13,8 +13,8 @@ import {Port, Wire} from "core/models"; export const WiringTool = (() => { const enum StateType { - CLICKED, - DRAGGED, + Clicked, + Dragged, } let port: Port; @@ -84,8 +84,8 @@ export const WiringTool = (() => { // 2) if the port was initial dragged on, // then letting go of the mouse will deactivate this // 3) the user cancels using Escape, Backspace or RMB - return (stateType === StateType.CLICKED && event.type === "click") || - (stateType === StateType.DRAGGED && event.type === "mouseup") || + return (stateType === StateType.Clicked && event.type === "click") || + (stateType === StateType.Dragged && event.type === "mouseup") || (event.type === "keydown" && event.key === "Escape") || (event.type === "keydown" && event.key === "Backspace") || (event.type === "mousedown" && event.button === RIGHT_MOUSE_BUTTON); @@ -100,7 +100,7 @@ export const WiringTool = (() => { wire = info.designer.createWire(port, undefined); setWirePoint(port.getWorldTargetPos()); - stateType = (event.type === "click" ? StateType.CLICKED : StateType.DRAGGED); + stateType = (event.type === "click" ? StateType.Clicked : StateType.Dragged); }, onDeactivate({}: Event, info: CircuitInfo): void { const { history, designer } = info;