Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Lit lint warnings #10112

Merged
merged 1 commit into from Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions 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";
Expand Down
1 change: 1 addition & 0 deletions 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";
Expand Down
8 changes: 5 additions & 3 deletions hassio/src/components/supervisor-backup-content.ts
Expand Up @@ -181,9 +181,7 @@ export class SupervisorBackupContent extends LitElement {
>
<ha-checkbox
.checked=${this.homeAssistant}
@click=${() => {
this.homeAssistant = !this.homeAssistant;
}}
@click=${this.toggleHomeAssistant}
>
</ha-checkbox>
</ha-formfield>
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion hassio/src/dialogs/backup/dialog-hassio-backup.ts
Expand Up @@ -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
Expand Down Expand Up @@ -107,7 +108,7 @@ class HassioBackupDialog
fixed
slot="primaryAction"
@action=${this._handleMenuAction}
@closed=${(ev: Event) => ev.stopPropagation()}
@closed=${stopPropagation}
>
<mwc-icon-button slot="trigger" alt="menu">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
Expand Down
33 changes: 22 additions & 11 deletions hassio/src/system/hassio-host-info.ts
Expand Up @@ -184,23 +184,34 @@ class HassioHostInfo extends LitElement {
<mwc-icon-button slot="trigger">
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button>
<mwc-list-item @click=${() => this._handleMenuAction("hardware")}>
<mwc-list-item
.action=${"hardware"}
@click=${this._handleMenuAction}
>
${this.supervisor.localize("system.host.hardware")}
</mwc-list-item>
${this.supervisor.host.features.includes("haos")
? html`<mwc-list-item
@click=${() => this._handleMenuAction("import_from_usb")}
? html`
<mwc-list-item
.action=${"import_from_usb"}
@click=${this._handleMenuAction}
>
${this.supervisor.localize("system.host.import_from_usb")}
</mwc-list-item>
${this.supervisor.host.features.includes("os_agent") &&
atLeastVersion(this.supervisor.host.agent_version, 1, 2, 0)
? html`<mwc-list-item
@click=${() => this._handleMenuAction("move_datadisk")}
>
${this.supervisor.localize("system.host.move_datadisk")}
</mwc-list-item>`
: ""} `
? html`
<mwc-list-item
.action=${"move_datadisk"}
@click=${this._handleMenuAction}
>
${this.supervisor.localize(
"system.host.move_datadisk"
)}
</mwc-list-item>
`
: ""}
`
: ""}
</ha-button-menu>
</div>
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/components/ha-selector/ha-selector-area.ts
Expand Up @@ -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}
Expand All @@ -51,16 +51,16 @@ export class HaAreaSelector extends LitElement {
></ha-area-picker>`;
}

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
Expand All @@ -84,7 +84,7 @@ export class HaAreaSelector extends LitElement {
}
}
return true;
}
};

private async _loadConfigEntries() {
this._configEntries = (await getConfigEntries(this.hass)).filter(
Expand Down