From 1e74ccb4f8380bb85dd7c9d97de5f5be16b83f39 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Thu, 25 Aug 2022 19:00:23 -0700 Subject: [PATCH] Enable some TS consistency lints --- frontend/.eslintrc.js | 6 +++- frontend/src/App.vue | 1 + frontend/src/components/panels/Document.vue | 14 ++++++--- .../components/widgets/buttons/TextButton.ts | 18 ------------ .../components/widgets/buttons/TextButton.vue | 18 ++++++++++++ frontend/src/io-managers/panic.ts | 3 +- frontend/src/io-managers/persistence.ts | 2 +- frontend/src/state-providers/dialog.ts | 3 +- frontend/src/state-providers/fonts.ts | 4 +-- frontend/src/wasm-communication/messages.ts | 29 +++++++++++++++---- .../wasm-communication/subscription-router.ts | 10 +++---- 11 files changed, 66 insertions(+), 42 deletions(-) delete mode 100644 frontend/src/components/widgets/buttons/TextButton.ts diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 84503665..0b935c1c 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -73,8 +73,12 @@ module.exports = { "@typescript-eslint/camelcase": "off", "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", ignoreRestSiblings: true }], - "@typescript-eslint/explicit-function-return-type": ["error"], + "@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/consistent-type-definitions": ["error", "type"], + "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "as", objectLiteralTypeAssertions: "never" }], + "@typescript-eslint/consistent-indexed-object-style": ["error", "record"], + "@typescript-eslint/consistent-generic-constructors": ["error", "constructor"], // Import plugin config (used to intelligently validate module import statements) "import/prefer-default-export": "off", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 311ee730..5e529350 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -248,6 +248,7 @@ const managerDestructors: { // Vue injects don't play well with TypeScript (all injects will show up as `any`) but we can define these types as a solution declare module "@vue/runtime-core" { // Systems `provide`d by the root App to be `inject`ed into descendant components and used for reactive bindings + // eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface ComponentCustomProperties { // Graphite WASM editor instance editor: Editor; diff --git a/frontend/src/components/panels/Document.vue b/frontend/src/components/panels/Document.vue index 908544f8..970f200a 100644 --- a/frontend/src/components/panels/Document.vue +++ b/frontend/src/components/panels/Document.vue @@ -404,6 +404,12 @@ export default defineComponent({ window.dispatchEvent(new Event("resize")); }, data() { + const scrollbarPos: XY = { x: 0.5, y: 0.5 }; + const scrollbarSize: XY = { x: 0.5, y: 0.5 }; + const scrollbarMultiplier: XY = { x: 0, y: 0 }; + + const rulerOrigin: XY = { x: 0, y: 0 }; + return { // Interactive text editing textInput: undefined as undefined | HTMLDivElement, @@ -414,12 +420,12 @@ export default defineComponent({ canvasCursor: "default" as MouseCursorIcon, // Scrollbars - scrollbarPos: { x: 0.5, y: 0.5 } as XY, - scrollbarSize: { x: 0.5, y: 0.5 } as XY, - scrollbarMultiplier: { x: 0, y: 0 } as XY, + scrollbarPos, + scrollbarSize, + scrollbarMultiplier, // Rulers - rulerOrigin: { x: 0, y: 0 } as XY, + rulerOrigin, rulerSpacing: 100 as number, rulerInterval: 100 as number, diff --git a/frontend/src/components/widgets/buttons/TextButton.ts b/frontend/src/components/widgets/buttons/TextButton.ts deleted file mode 100644 index 22b33540..00000000 --- a/frontend/src/components/widgets/buttons/TextButton.ts +++ /dev/null @@ -1,18 +0,0 @@ -// TODO: Try and get rid of the need for this file - -export interface TextButtonWidget { - tooltip?: string; - message?: string | object; - callback?: () => void; - props: { - kind: "TextButton"; - label: string; - icon?: string; - emphasized?: boolean; - minWidth?: number; - disabled?: boolean; - - // Callbacks - // `action` is used via `IconButtonWidget.callback` - }; -} diff --git a/frontend/src/components/widgets/buttons/TextButton.vue b/frontend/src/components/widgets/buttons/TextButton.vue index b686ec8a..a0814e7f 100644 --- a/frontend/src/components/widgets/buttons/TextButton.vue +++ b/frontend/src/components/widgets/buttons/TextButton.vue @@ -62,6 +62,7 @@ } +