From 419942112bbf66f2b954d1c2b3b1fd921f8012d8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 30 Sep 2021 08:46:03 -0700 Subject: [PATCH] Fix Lit lint warnings (#10112) --- .../demos/demo-automation-trace-timeline.ts | 1 + gallery/src/demos/demo-automation-trace.ts | 1 + .../components/supervisor-backup-content.ts | 8 +++-- .../dialogs/backup/dialog-hassio-backup.ts | 3 +- hassio/src/system/hassio-host-info.ts | 33 ++++++++++++------- .../ha-selector/ha-selector-area.ts | 12 +++---- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/gallery/src/demos/demo-automation-trace-timeline.ts b/gallery/src/demos/demo-automation-trace-timeline.ts index 50461fca6d..f94cd97fb6 100644 --- a/gallery/src/demos/demo-automation-trace-timeline.ts +++ b/gallery/src/demos/demo-automation-trace-timeline.ts @@ -1,3 +1,4 @@ +/* eslint-disable lit/no-template-arrow */ import { html, css, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import "../../../src/components/ha-card"; diff --git a/gallery/src/demos/demo-automation-trace.ts b/gallery/src/demos/demo-automation-trace.ts index a1faa152ac..508576c22f 100644 --- a/gallery/src/demos/demo-automation-trace.ts +++ b/gallery/src/demos/demo-automation-trace.ts @@ -1,3 +1,4 @@ +/* eslint-disable lit/no-template-arrow */ import { html, css, LitElement, TemplateResult } from "lit"; import "../../../src/components/ha-card"; import "../../../src/components/trace/hat-script-graph"; diff --git a/hassio/src/components/supervisor-backup-content.ts b/hassio/src/components/supervisor-backup-content.ts index ac55733ace..58ca3bcb94 100644 --- a/hassio/src/components/supervisor-backup-content.ts +++ b/hassio/src/components/supervisor-backup-content.ts @@ -181,9 +181,7 @@ export class SupervisorBackupContent extends LitElement { > { - this.homeAssistant = !this.homeAssistant; - }} + @click=${this.toggleHomeAssistant} > @@ -272,6 +270,10 @@ export class SupervisorBackupContent extends LitElement { `; } + private toggleHomeAssistant() { + this.homeAssistant = !this.homeAssistant; + } + static get styles(): CSSResultGroup { return css` .partial-picker ha-formfield { diff --git a/hassio/src/dialogs/backup/dialog-hassio-backup.ts b/hassio/src/dialogs/backup/dialog-hassio-backup.ts index 47bbf18e25..0287c8fa01 100644 --- a/hassio/src/dialogs/backup/dialog-hassio-backup.ts +++ b/hassio/src/dialogs/backup/dialog-hassio-backup.ts @@ -28,6 +28,7 @@ import "../../components/supervisor-backup-content"; import type { SupervisorBackupContent } from "../../components/supervisor-backup-content"; import { HassioBackupDialogParams } from "./show-dialog-hassio-backup"; import { atLeastVersion } from "../../../../src/common/config/version"; +import { stopPropagation } from "../../../../src/common/dom/stop_propagation"; @customElement("dialog-hassio-backup") class HassioBackupDialog @@ -107,7 +108,7 @@ class HassioBackupDialog fixed slot="primaryAction" @action=${this._handleMenuAction} - @closed=${(ev: Event) => ev.stopPropagation()} + @closed=${stopPropagation} > diff --git a/hassio/src/system/hassio-host-info.ts b/hassio/src/system/hassio-host-info.ts index 00ef68e59e..89aab52da9 100644 --- a/hassio/src/system/hassio-host-info.ts +++ b/hassio/src/system/hassio-host-info.ts @@ -184,23 +184,34 @@ class HassioHostInfo extends LitElement { - this._handleMenuAction("hardware")}> + ${this.supervisor.localize("system.host.hardware")} ${this.supervisor.host.features.includes("haos") - ? html` this._handleMenuAction("import_from_usb")} + ? html` + ${this.supervisor.localize("system.host.import_from_usb")} ${this.supervisor.host.features.includes("os_agent") && atLeastVersion(this.supervisor.host.agent_version, 1, 2, 0) - ? html` this._handleMenuAction("move_datadisk")} - > - ${this.supervisor.localize("system.host.move_datadisk")} - ` - : ""} ` + ? html` + + ${this.supervisor.localize( + "system.host.move_datadisk" + )} + + ` + : ""} + ` : ""} @@ -223,8 +234,8 @@ class HassioHostInfo extends LitElement { return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0]; }); - private async _handleMenuAction(action: string) { - switch (action) { + private async _handleMenuAction(ev) { + switch ((ev.target as any).action) { case "hardware": await this._showHardware(); break; diff --git a/src/components/ha-selector/ha-selector-area.ts b/src/components/ha-selector/ha-selector-area.ts index 5d619bf0e8..5f307dd013 100644 --- a/src/components/ha-selector/ha-selector-area.ts +++ b/src/components/ha-selector/ha-selector-area.ts @@ -39,8 +39,8 @@ export class HaAreaSelector extends LitElement { .value=${this.value} .label=${this.label} no-add - .deviceFilter=${(device) => this._filterDevices(device)} - .entityFilter=${(entity) => this._filterEntities(entity)} + .deviceFilter=${this._filterDevices} + .entityFilter=${this._filterEntities} .includeDeviceClasses=${this.selector.area.entity?.device_class ? [this.selector.area.entity.device_class] : undefined} @@ -51,16 +51,16 @@ export class HaAreaSelector extends LitElement { >`; } - private _filterEntities(entity: EntityRegistryEntry): boolean { + private _filterEntities = (entity: EntityRegistryEntry): boolean => { if (this.selector.area.entity?.integration) { if (entity.platform !== this.selector.area.entity.integration) { return false; } } return true; - } + }; - private _filterDevices(device: DeviceRegistryEntry): boolean { + private _filterDevices = (device: DeviceRegistryEntry): boolean => { if ( this.selector.area.device?.manufacturer && device.manufacturer !== this.selector.area.device.manufacturer @@ -84,7 +84,7 @@ export class HaAreaSelector extends LitElement { } } return true; - } + }; private async _loadConfigEntries() { this._configEntries = (await getConfigEntries(this.hass)).filter(