From 33cb6fcb009139eec2008011c5f88974800981bd Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Thu, 25 Aug 2022 21:32:27 -0700 Subject: [PATCH] Remove usage of 'null' in favor of 'undefined' --- frontend/.eslintrc.js | 1 + .../components/floating-menus/DialogModal.vue | 4 +- frontend/src/components/layout/LayoutCol.vue | 2 +- frontend/src/components/layout/LayoutRow.vue | 2 +- frontend/src/components/panels/LayerTree.vue | 6 +- frontend/src/components/widgets/WidgetRow.vue | 4 +- .../components/widgets/buttons/TextButton.vue | 4 +- .../widgets/inputs/MenuBarInput.vue | 8 +- .../widgets/labels/UserInputLabel.vue | 4 +- frontend/src/io-managers/input.ts | 10 +- frontend/src/io-managers/panic.ts | 2 +- frontend/src/utility-functions/icons.ts | 4 +- frontend/src/utility-functions/platform.ts | 12 +- frontend/src/wasm-communication/editor.ts | 4 +- frontend/src/wasm-communication/messages.ts | 6 +- frontend/vue.config.js | 8 +- website/static/carousel.js | 164 ------------------ website/static/js/navbar.js | 4 +- website/static/navbar.js | 115 ------------ website/templates/base.html | 2 +- website/templates/index.html | 2 +- 21 files changed, 45 insertions(+), 323 deletions(-) delete mode 100644 website/static/carousel.js delete mode 100644 website/static/navbar.js diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 0b935c1c..00f5f1a3 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -79,6 +79,7 @@ module.exports = { "@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"], + "@typescript-eslint/ban-types": ["error", { types: { null: "Use `undefined` instead." } }], // Import plugin config (used to intelligently validate module import statements) "import/prefer-default-export": "off", diff --git a/frontend/src/components/floating-menus/DialogModal.vue b/frontend/src/components/floating-menus/DialogModal.vue index 81786983..0205abfa 100644 --- a/frontend/src/components/floating-menus/DialogModal.vue +++ b/frontend/src/components/floating-menus/DialogModal.vue @@ -84,8 +84,8 @@ export default defineComponent({ }, mounted() { // Focus the first button in the popup - const element = this.$el as Element | null; - const emphasizedOrFirstButton = (element?.querySelector("[data-emphasized]") as HTMLButtonElement | null) || element?.querySelector("[data-text-button]"); + const element = this.$el as Element | undefined; + const emphasizedOrFirstButton = (element?.querySelector("[data-emphasized]") || element?.querySelector("[data-text-button]") || undefined) as HTMLButtonElement | undefined; emphasizedOrFirstButton?.focus(); }, components: { diff --git a/frontend/src/components/layout/LayoutCol.vue b/frontend/src/components/layout/LayoutCol.vue index 4ba7abba..b0f79265 100644 --- a/frontend/src/components/layout/LayoutCol.vue +++ b/frontend/src/components/layout/LayoutCol.vue @@ -1,5 +1,5 @@ diff --git a/frontend/src/components/layout/LayoutRow.vue b/frontend/src/components/layout/LayoutRow.vue index d9ac1d59..3f8c37d7 100644 --- a/frontend/src/components/layout/LayoutRow.vue +++ b/frontend/src/components/layout/LayoutRow.vue @@ -1,5 +1,5 @@ diff --git a/frontend/src/components/panels/LayerTree.vue b/frontend/src/components/panels/LayerTree.vue index e932d740..c092e346 100644 --- a/frontend/src/components/panels/LayerTree.vue +++ b/frontend/src/components/panels/LayerTree.vue @@ -59,8 +59,8 @@ :disabled="!listing.editingName" @blur="() => onEditLayerNameDeselect(listing)" @keydown.esc="onEditLayerNameDeselect(listing)" - @keydown.enter="(e) => onEditLayerNameChange(listing, e.target)" - @change="(e) => onEditLayerNameChange(listing, e.target)" + @keydown.enter="(e) => onEditLayerNameChange(listing, e.target || undefined)" + @change="(e) => onEditLayerNameChange(listing, e.target || undefined)" />
@@ -328,7 +328,7 @@ export default defineComponent({ await nextTick(); (tree.querySelector("[data-text-input]:not([disabled])") as HTMLInputElement).select(); }, - onEditLayerNameChange(listing: LayerListingInfo, inputElement: EventTarget | null) { + onEditLayerNameChange(listing: LayerListingInfo, inputElement: EventTarget | undefined) { // Eliminate duplicate events if (!listing.editingName) return; diff --git a/frontend/src/components/widgets/WidgetRow.vue b/frontend/src/components/widgets/WidgetRow.vue index f9a459e4..fdef6891 100644 --- a/frontend/src/components/widgets/WidgetRow.vue +++ b/frontend/src/components/widgets/WidgetRow.vue @@ -13,7 +13,7 @@ @update:selectedIndex="(value: number) => updateLayout(component.widgetId, value)" /> - + - + {{ (component.props as any).value }} diff --git a/frontend/src/components/widgets/buttons/TextButton.vue b/frontend/src/components/widgets/buttons/TextButton.vue index a0814e7f..59d95748 100644 --- a/frontend/src/components/widgets/buttons/TextButton.vue +++ b/frontend/src/components/widgets/buttons/TextButton.vue @@ -2,8 +2,8 @@