Fix Lit lint warnings (#10112)

This commit is contained in:
Paulus Schoutsen 2021-09-30 08:46:03 -07:00 committed by GitHub
parent 597d4a0426
commit 419942112b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 21 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable lit/no-template-arrow */
import { html, css, LitElement, TemplateResult } from "lit"; import { html, css, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import "../../../src/components/ha-card"; import "../../../src/components/ha-card";

View File

@ -1,3 +1,4 @@
/* eslint-disable lit/no-template-arrow */
import { html, css, LitElement, TemplateResult } from "lit"; import { html, css, LitElement, TemplateResult } from "lit";
import "../../../src/components/ha-card"; import "../../../src/components/ha-card";
import "../../../src/components/trace/hat-script-graph"; import "../../../src/components/trace/hat-script-graph";

View File

@ -181,9 +181,7 @@ export class SupervisorBackupContent extends LitElement {
> >
<ha-checkbox <ha-checkbox
.checked=${this.homeAssistant} .checked=${this.homeAssistant}
@click=${() => { @click=${this.toggleHomeAssistant}
this.homeAssistant = !this.homeAssistant;
}}
> >
</ha-checkbox> </ha-checkbox>
</ha-formfield> </ha-formfield>
@ -272,6 +270,10 @@ export class SupervisorBackupContent extends LitElement {
`; `;
} }
private toggleHomeAssistant() {
this.homeAssistant = !this.homeAssistant;
}
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {
return css` return css`
.partial-picker ha-formfield { .partial-picker ha-formfield {

View File

@ -28,6 +28,7 @@ import "../../components/supervisor-backup-content";
import type { SupervisorBackupContent } from "../../components/supervisor-backup-content"; import type { SupervisorBackupContent } from "../../components/supervisor-backup-content";
import { HassioBackupDialogParams } from "./show-dialog-hassio-backup"; import { HassioBackupDialogParams } from "./show-dialog-hassio-backup";
import { atLeastVersion } from "../../../../src/common/config/version"; import { atLeastVersion } from "../../../../src/common/config/version";
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
@customElement("dialog-hassio-backup") @customElement("dialog-hassio-backup")
class HassioBackupDialog class HassioBackupDialog
@ -107,7 +108,7 @@ class HassioBackupDialog
fixed fixed
slot="primaryAction" slot="primaryAction"
@action=${this._handleMenuAction} @action=${this._handleMenuAction}
@closed=${(ev: Event) => ev.stopPropagation()} @closed=${stopPropagation}
> >
<mwc-icon-button slot="trigger" alt="menu"> <mwc-icon-button slot="trigger" alt="menu">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon> <ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>

View File

@ -184,23 +184,34 @@ class HassioHostInfo extends LitElement {
<mwc-icon-button slot="trigger"> <mwc-icon-button slot="trigger">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon> <ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button> </mwc-icon-button>
<mwc-list-item @click=${() => this._handleMenuAction("hardware")}> <mwc-list-item
.action=${"hardware"}
@click=${this._handleMenuAction}
>
${this.supervisor.localize("system.host.hardware")} ${this.supervisor.localize("system.host.hardware")}
</mwc-list-item> </mwc-list-item>
${this.supervisor.host.features.includes("haos") ${this.supervisor.host.features.includes("haos")
? html`<mwc-list-item ? html`
@click=${() => this._handleMenuAction("import_from_usb")} <mwc-list-item
.action=${"import_from_usb"}
@click=${this._handleMenuAction}
> >
${this.supervisor.localize("system.host.import_from_usb")} ${this.supervisor.localize("system.host.import_from_usb")}
</mwc-list-item> </mwc-list-item>
${this.supervisor.host.features.includes("os_agent") && ${this.supervisor.host.features.includes("os_agent") &&
atLeastVersion(this.supervisor.host.agent_version, 1, 2, 0) atLeastVersion(this.supervisor.host.agent_version, 1, 2, 0)
? html`<mwc-list-item ? html`
@click=${() => this._handleMenuAction("move_datadisk")} <mwc-list-item
.action=${"move_datadisk"}
@click=${this._handleMenuAction}
> >
${this.supervisor.localize("system.host.move_datadisk")} ${this.supervisor.localize(
</mwc-list-item>` "system.host.move_datadisk"
: ""} ` )}
</mwc-list-item>
`
: ""}
`
: ""} : ""}
</ha-button-menu> </ha-button-menu>
</div> </div>
@ -223,8 +234,8 @@ class HassioHostInfo extends LitElement {
return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0]; return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0];
}); });
private async _handleMenuAction(action: string) { private async _handleMenuAction(ev) {
switch (action) { switch ((ev.target as any).action) {
case "hardware": case "hardware":
await this._showHardware(); await this._showHardware();
break; break;

View File

@ -39,8 +39,8 @@ export class HaAreaSelector extends LitElement {
.value=${this.value} .value=${this.value}
.label=${this.label} .label=${this.label}
no-add no-add
.deviceFilter=${(device) => this._filterDevices(device)} .deviceFilter=${this._filterDevices}
.entityFilter=${(entity) => this._filterEntities(entity)} .entityFilter=${this._filterEntities}
.includeDeviceClasses=${this.selector.area.entity?.device_class .includeDeviceClasses=${this.selector.area.entity?.device_class
? [this.selector.area.entity.device_class] ? [this.selector.area.entity.device_class]
: undefined} : undefined}
@ -51,16 +51,16 @@ export class HaAreaSelector extends LitElement {
></ha-area-picker>`; ></ha-area-picker>`;
} }
private _filterEntities(entity: EntityRegistryEntry): boolean { private _filterEntities = (entity: EntityRegistryEntry): boolean => {
if (this.selector.area.entity?.integration) { if (this.selector.area.entity?.integration) {
if (entity.platform !== this.selector.area.entity.integration) { if (entity.platform !== this.selector.area.entity.integration) {
return false; return false;
} }
} }
return true; return true;
} };
private _filterDevices(device: DeviceRegistryEntry): boolean { private _filterDevices = (device: DeviceRegistryEntry): boolean => {
if ( if (
this.selector.area.device?.manufacturer && this.selector.area.device?.manufacturer &&
device.manufacturer !== this.selector.area.device.manufacturer device.manufacturer !== this.selector.area.device.manufacturer
@ -84,7 +84,7 @@ export class HaAreaSelector extends LitElement {
} }
} }
return true; return true;
} };
private async _loadConfigEntries() { private async _loadConfigEntries() {
this._configEntries = (await getConfigEntries(this.hass)).filter( this._configEntries = (await getConfigEntries(this.hass)).filter(