Update lint rules (#9563)

Updated deps

Added `unused-imports`, prefer arrow, and import order
This commit is contained in:
Bram Kragten 2021-07-15 12:08:04 +02:00 committed by GitHub
parent 12f7366968
commit e797c01761
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
177 changed files with 1122 additions and 1146 deletions

View File

@ -35,55 +35,51 @@
"es6": true "es6": true
}, },
"rules": { "rules": {
"class-methods-use-this": 0, "class-methods-use-this": "off",
"new-cap": 0, "new-cap": "off",
"prefer-template": 0, "prefer-template": "off",
"object-shorthand": 0, "object-shorthand": "off",
"func-names": 0, "func-names": "off",
"prefer-arrow-callback": 0, "no-underscore-dangle": "off",
"no-underscore-dangle": 0, "strict": "off",
"strict": 0, "no-plusplus": "off",
"prefer-spread": 0, "no-bitwise": "error",
"no-plusplus": 0, "comma-dangle": "off",
"no-bitwise": 2, "vars-on-top": "off",
"comma-dangle": 0, "no-continue": "off",
"vars-on-top": 0, "no-param-reassign": "off",
"no-continue": 0, "no-multi-assign": "off",
"no-param-reassign": 0, "no-console": "error",
"no-multi-assign": 0, "radix": "off",
"no-console": 2, "no-alert": "off",
"radix": 0, "no-nested-ternary": "off",
"no-alert": 0, "prefer-destructuring": "off",
"no-return-await": 0,
"no-nested-ternary": 0,
"prefer-destructuring": 0,
"no-restricted-globals": [2, "event"], "no-restricted-globals": [2, "event"],
"prefer-promise-reject-errors": 0, "prefer-promise-reject-errors": "off",
"import/order": 0, "import/prefer-default-export": "off",
"import/prefer-default-export": 0, "import/no-default-export": "off",
"import/no-unresolved": 0, "import/no-unresolved": "off",
"import/no-cycle": 0, "import/no-cycle": "off",
"import/extensions": [ "import/extensions": [
2, "error",
"ignorePackages", "ignorePackages",
{ "ts": "never", "js": "never" } { "ts": "never", "js": "never" }
], ],
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"], "no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
"object-curly-newline": 0, "object-curly-newline": "off",
"default-case": 0, "default-case": "off",
"wc/no-self-class": 0, "wc/no-self-class": "off",
"no-shadow": 0, "no-shadow": "off",
"@typescript-eslint/camelcase": 0, "@typescript-eslint/camelcase": "off",
"@typescript-eslint/ban-ts-comment": 0, "@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-use-before-define": 0, "@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": 0, "@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": 0, "@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-function-return-type": 0, "@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-shadow": ["error"], "@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/naming-convention": [ "@typescript-eslint/naming-convention": [
0, "off",
{ {
"selector": "default", "selector": "default",
"format": ["camelCase", "snake_case"], "format": ["camelCase", "snake_case"],
@ -101,9 +97,21 @@
"format": ["PascalCase"] "format": ["PascalCase"]
} }
], ],
"lit/attribute-value-entities": 0 "@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-vars": [
"error",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"unused-imports/no-unused-imports": "error",
"lit/attribute-value-entities": "off"
}, },
"plugins": ["disable", "import", "lit", "prettier", "@typescript-eslint"], "plugins": ["disable", "unused-imports"],
"processor": "disable/disable", "processor": "disable/disable",
"ignorePatterns": ["src/resources/lit-virtualizer/*"] "ignorePatterns": ["src/resources/lit-virtualizer/*"]
} }

View File

@ -5,8 +5,8 @@ import {
import { castContext } from "../cast_context"; import { castContext } from "../cast_context";
export const castDemoLovelace: () => LovelaceConfig = () => { export const castDemoLovelace: () => LovelaceConfig = () => {
const touchSupported = castContext.getDeviceCapabilities() const touchSupported =
.touch_input_supported; castContext.getDeviceCapabilities().touch_input_supported;
return { return {
views: [ views: [
{ {

View File

@ -113,8 +113,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
on: "/assets/arsaboo/icons/light_bulb_on.png", on: "/assets/arsaboo/icons/light_bulb_on.png",
}, },
state_filter: { state_filter: {
on: on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
off: "brightness(80%) saturate(0.8)", off: "brightness(80%) saturate(0.8)",
}, },
style: { style: {
@ -196,8 +195,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
on: "/assets/arsaboo/icons/light_bulb_on.png", on: "/assets/arsaboo/icons/light_bulb_on.png",
}, },
state_filter: { state_filter: {
on: on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
off: "brightness(80%) saturate(0.8)", off: "brightness(80%) saturate(0.8)",
}, },
style: { style: {
@ -277,8 +275,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
on: "/assets/arsaboo/icons/light_bulb_on.png", on: "/assets/arsaboo/icons/light_bulb_on.png",
}, },
state_filter: { state_filter: {
on: on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
off: "brightness(80%) saturate(0.8)", off: "brightness(80%) saturate(0.8)",
}, },
style: { style: {
@ -315,8 +312,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
on: "/assets/arsaboo/icons/light_bulb_on.png", on: "/assets/arsaboo/icons/light_bulb_on.png",
}, },
state_filter: { state_filter: {
on: on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
off: "brightness(80%) saturate(0.8)", off: "brightness(80%) saturate(0.8)",
}, },
style: { style: {

View File

@ -12,9 +12,8 @@ export const demoConfigs: Array<() => Promise<DemoConfig>> = [
// eslint-disable-next-line import/no-mutable-exports // eslint-disable-next-line import/no-mutable-exports
export let selectedDemoConfigIndex = 0; export let selectedDemoConfigIndex = 0;
// eslint-disable-next-line import/no-mutable-exports // eslint-disable-next-line import/no-mutable-exports
export let selectedDemoConfig: Promise<DemoConfig> = demoConfigs[ export let selectedDemoConfig: Promise<DemoConfig> =
selectedDemoConfigIndex demoConfigs[selectedDemoConfigIndex]();
]();
export const setDemoConfig = async ( export const setDemoConfig = async (
hass: MockHomeAssistant, hass: MockHomeAssistant,

View File

@ -980,8 +980,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () =>
icon: "mdi:account-off", icon: "mdi:account-off",
custom_ui_state_card: "state-card-custom-ui", custom_ui_state_card: "state-card-custom-ui",
templates: { templates: {
icon: icon: "if (state === 'on') return 'mdi:account'; else if (state === 'off') return 'mdi:account-off';\n",
"if (state === 'on') return 'mdi:account'; else if (state === 'off') return 'mdi:account-off';\n",
icon_color: icon_color:
"if (state === 'on') return 'rgb(56, 150, 56)'; else if (state === 'off') return 'rgb(249, 251, 255)';\n", "if (state === 'on') return 'rgb(56, 150, 56)'; else if (state === 'off') return 'rgb(249, 251, 255)';\n",
}, },
@ -1005,8 +1004,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () =>
icon: "mdi:account-multiple-minus", icon: "mdi:account-multiple-minus",
custom_ui_state_card: "state-card-custom-ui", custom_ui_state_card: "state-card-custom-ui",
templates: { templates: {
icon: icon: "if (state === 'on') return 'mdi:account-group'; else if (state === 'off') return 'mdi:account-multiple-minus';\n",
"if (state === 'on') return 'mdi:account-group'; else if (state === 'off') return 'mdi:account-multiple-minus';\n",
icon_color: icon_color:
"if (state === 'on') return 'rgb(56, 150, 56)'; else if (state === 'off') return 'rgb(249, 251, 255)';\n", "if (state === 'on') return 'rgb(56, 150, 56)'; else if (state === 'off') return 'rgb(249, 251, 255)';\n",
}, },

View File

@ -19,7 +19,7 @@ export class HADemoCard extends LitElement implements LovelaceCard {
@property({ attribute: false }) public hass!: MockHomeAssistant; @property({ attribute: false }) public hass!: MockHomeAssistant;
@state() private _switching?: boolean; @state() private _switching = false;
private _hidden = localStorage.hide_demo_card; private _hidden = localStorage.hide_demo_card;
@ -27,12 +27,7 @@ export class HADemoCard extends LitElement implements LovelaceCard {
return this._hidden ? 0 : 2; return this._hidden ? 0 : 2;
} }
public setConfig( public setConfig(_config: LovelaceCardConfig) {}
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
config: LovelaceCardConfig
// eslint-disable-next-line @typescript-eslint/no-empty-function
) {}
protected render(): TemplateResult { protected render(): TemplateResult {
if (this._hidden) { if (this._hidden) {

View File

@ -67,14 +67,7 @@ const incrementalUnits = ["clients", "queries", "ads"];
export const mockHistory = (mockHass: MockHomeAssistant) => { export const mockHistory = (mockHass: MockHomeAssistant) => {
mockHass.mockAPI( mockHass.mockAPI(
new RegExp("history/period/.+"), new RegExp("history/period/.+"),
( (hass, _method, path, _parameters) => {
hass,
// @ts-ignore
method,
path,
// @ts-ignore
parameters
) => {
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]); const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
const entities = params.filter_entity_id.split(","); const entities = params.filter_entity_id.split(",");
@ -95,7 +88,7 @@ export const mockHistory = (mockHass: MockHomeAssistant) => {
const numberState = Number(state.state); const numberState = Number(state.state);
if (isNaN(numberState)) { if (isNaN(numberState)) {
// eslint-disable-next-line // eslint-disable-next-line no-console
console.log( console.log(
"Ignoring state with unparsable state but with a unit", "Ignoring state with unparsable state but with a unit",
entityId, entityId,

View File

@ -10,10 +10,9 @@ export const mockLovelace = (
localizePromise: Promise<LocalizeFunc> localizePromise: Promise<LocalizeFunc>
) => { ) => {
hass.mockWS("lovelace/config", () => hass.mockWS("lovelace/config", () =>
Promise.all([ Promise.all([selectedDemoConfig, localizePromise]).then(
selectedDemoConfig, ([config, localize]) => config.lovelace(localize)
localizePromise, )
]).then(([config, localize]) => config.lovelace(localize))
); );
hass.mockWS("lovelace/config/save", () => Promise.resolve()); hass.mockWS("lovelace/config/save", () => Promise.resolve());

View File

@ -2,12 +2,12 @@ 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";
import "../../../src/components/trace/hat-trace-timeline"; import "../../../src/components/trace/hat-trace-timeline";
import { customElement, property, state } from "lit/decorators";
import { provideHass } from "../../../src/fake_data/provide_hass"; import { provideHass } from "../../../src/fake_data/provide_hass";
import { HomeAssistant } from "../../../src/types"; import { HomeAssistant } from "../../../src/types";
import { DemoTrace } from "../data/traces/types"; import { DemoTrace } from "../data/traces/types";
import { basicTrace } from "../data/traces/basic_trace"; import { basicTrace } from "../data/traces/basic_trace";
import { motionLightTrace } from "../data/traces/motion-light-trace"; import { motionLightTrace } from "../data/traces/motion-light-trace";
import { customElement, property, state } from "lit/decorators";
const traces: DemoTrace[] = [basicTrace, motionLightTrace]; const traces: DemoTrace[] = [basicTrace, motionLightTrace];

View File

@ -2,6 +2,8 @@ import { html, css, LitElement, TemplateResult } from "lit";
import "../../../src/components/ha-formfield"; import "../../../src/components/ha-formfield";
import "../../../src/components/ha-switch"; import "../../../src/components/ha-switch";
import { classMap } from "lit/directives/class-map";
import { customElement, property, state } from "lit/decorators";
import { IntegrationManifest } from "../../../src/data/integration"; import { IntegrationManifest } from "../../../src/data/integration";
import { provideHass } from "../../../src/fake_data/provide_hass"; import { provideHass } from "../../../src/fake_data/provide_hass";
@ -15,8 +17,6 @@ import type {
} from "../../../src/panels/config/integrations/ha-config-integrations"; } from "../../../src/panels/config/integrations/ha-config-integrations";
import { DeviceRegistryEntry } from "../../../src/data/device_registry"; import { DeviceRegistryEntry } from "../../../src/data/device_registry";
import { EntityRegistryEntry } from "../../../src/data/entity_registry"; import { EntityRegistryEntry } from "../../../src/data/entity_registry";
import { classMap } from "lit/directives/class-map";
import { customElement, property, state } from "lit/decorators";
const createConfigEntry = ( const createConfigEntry = (
title: string, title: string,

View File

@ -2,6 +2,7 @@ import "../../../../src/components/ha-card";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import "../../../../src/components/ha-circular-progress"; import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-markdown"; import "../../../../src/components/ha-markdown";
import { customElement, property, state } from "lit/decorators";
import { import {
fetchHassioAddonDocumentation, fetchHassioAddonDocumentation,
HassioAddonDetails, HassioAddonDetails,
@ -12,7 +13,6 @@ import { haStyle } from "../../../../src/resources/styles";
import { HomeAssistant } from "../../../../src/types"; import { HomeAssistant } from "../../../../src/types";
import { hassioStyle } from "../../resources/hassio-style"; import { hassioStyle } from "../../resources/hassio-style";
import { Supervisor } from "../../../../src/data/supervisor/supervisor"; import { Supervisor } from "../../../../src/data/supervisor/supervisor";
import { customElement, property, state } from "lit/decorators";
@customElement("hassio-addon-documentation-tab") @customElement("hassio-addon-documentation-tab")
class HassioAddonDocumentationDashboard extends LitElement { class HassioAddonDocumentationDashboard extends LitElement {

View File

@ -41,7 +41,8 @@ const IP_VERSIONS = ["ipv4", "ipv6"];
@customElement("dialog-hassio-network") @customElement("dialog-hassio-network")
export class DialogHassioNetwork export class DialogHassioNetwork
extends LitElement extends LitElement
implements HassDialog<HassioNetworkDialogParams> { implements HassDialog<HassioNetworkDialogParams>
{
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public supervisor!: Supervisor; @property({ attribute: false }) public supervisor!: Supervisor;
@ -492,7 +493,7 @@ export class DialogHassioNetwork
} }
private _handleRadioValueChangedAp(ev: CustomEvent): void { private _handleRadioValueChangedAp(ev: CustomEvent): void {
const value = ((ev.target as any).value as string) as const value = (ev.target as any).value as string as
| "open" | "open"
| "wep" | "wep"
| "wpa-psk"; | "wpa-psk";

View File

@ -161,9 +161,9 @@ class HassioRegistriesDialog extends LitElement {
public focus(): void { public focus(): void {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -161,9 +161,9 @@ class HassioRepositoriesDialog extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -12,7 +12,8 @@ import { HassioSnapshotUploadDialogParams } from "./show-dialog-snapshot-upload"
@customElement("dialog-hassio-snapshot-upload") @customElement("dialog-hassio-snapshot-upload")
export class DialogHassioSnapshotUpload export class DialogHassioSnapshotUpload
extends LitElement extends LitElement
implements HassDialog<HassioSnapshotUploadDialogParams> { implements HassDialog<HassioSnapshotUploadDialogParams>
{
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@state() private _params?: HassioSnapshotUploadDialogParams; @state() private _params?: HassioSnapshotUploadDialogParams;

View File

@ -30,7 +30,8 @@ import { HassioSnapshotDialogParams } from "./show-dialog-hassio-snapshot";
@customElement("dialog-hassio-snapshot") @customElement("dialog-hassio-snapshot")
class HassioSnapshotDialog class HassioSnapshotDialog
extends LitElement extends LitElement
implements HassDialog<HassioSnapshotDialogParams> { implements HassDialog<HassioSnapshotDialogParams>
{
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@state() private _error?: string; @state() private _error?: string;
@ -297,8 +298,7 @@ class HassioSnapshotDialog
if (window.location.href.includes("ui.nabu.casa")) { if (window.location.href.includes("ui.nabu.casa")) {
const confirm = await showConfirmationDialog(this, { const confirm = await showConfirmationDialog(this, {
title: "Potential slow download", title: "Potential slow download",
text: text: "Downloading snapshots over the Nabu Casa URL will take some time, it is recomended to use your local URL instead, do you want to continue?",
"Downloading snapshots over the Nabu Casa URL will take some time, it is recomended to use your local URL instead, do you want to continue?",
confirmText: "continue", confirmText: "continue",
dismissText: "cancel", dismissText: "cancel",
}); });

View File

@ -49,9 +49,9 @@ class DialogSupervisorUpdate extends LitElement {
public focus(): void { public focus(): void {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -121,7 +121,7 @@ export class HassioMain extends SupervisorBaseElement {
} }
} else { } else {
themeName = themeName =
((this.hass.selectedTheme as unknown) as string) || (this.hass.selectedTheme as unknown as string) ||
this.hass.themes.default_theme; this.hass.themes.default_theme;
} }

View File

@ -1,19 +1,19 @@
import { html, LitElement, TemplateResult } from "lit";
import { sanitizeUrl } from "@braintree/sanitize-url"; import { sanitizeUrl } from "@braintree/sanitize-url";
import { html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { navigate } from "../../src/common/navigate";
import { import {
createSearchParam, createSearchParam,
extractSearchParamsObject, extractSearchParamsObject,
} from "../../src/common/url/search-params"; } from "../../src/common/url/search-params";
import { Supervisor } from "../../src/data/supervisor/supervisor";
import "../../src/layouts/hass-error-screen"; import "../../src/layouts/hass-error-screen";
import { import {
ParamType, ParamType,
Redirect, Redirect,
Redirects, Redirects,
} from "../../src/panels/my/ha-panel-my"; } from "../../src/panels/my/ha-panel-my";
import { navigate } from "../../src/common/navigate";
import { HomeAssistant, Route } from "../../src/types"; import { HomeAssistant, Route } from "../../src/types";
import { Supervisor } from "../../src/data/supervisor/supervisor";
import { customElement, property, state } from "lit/decorators";
const REDIRECTS: Redirects = { const REDIRECTS: Redirects = {
supervisor: { supervisor: {

View File

@ -86,10 +86,8 @@ export class SupervisorBaseElement extends urlSyncMixin(
const unsubs = Object.keys(this._unsubs); const unsubs = Object.keys(this._unsubs);
for (const collection of Object.keys(this._collections)) { for (const collection of Object.keys(this._collections)) {
if (!unsubs.includes(collection)) { if (!unsubs.includes(collection)) {
this._unsubs[collection] = this._collections[ this._unsubs[collection] = this._collections[collection].subscribe(
collection (data) => this._updateSupervisor({ [collection]: data })
].subscribe((data) =>
this._updateSupervisor({ [collection]: data })
); );
} }
} }

View File

@ -172,21 +172,22 @@
"@types/mocha": "^8.2.2", "@types/mocha": "^8.2.2",
"@types/sortablejs": "^1.10.6", "@types/sortablejs": "^1.10.6",
"@types/webspeechapi": "^0.0.29", "@types/webspeechapi": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^4.22.0", "@typescript-eslint/eslint-plugin": "^4.28.3",
"@typescript-eslint/parser": "^4.22.0", "@typescript-eslint/parser": "^4.28.3",
"@web/dev-server": "^0.0.24", "@web/dev-server": "^0.0.24",
"@web/dev-server-rollup": "^0.2.11", "@web/dev-server-rollup": "^0.2.11",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"chai": "^4.3.4", "chai": "^4.3.4",
"del": "^4.0.0", "del": "^4.0.0",
"eslint": "^7.25.0", "eslint": "^7.30.0",
"eslint-config-airbnb-typescript": "^12.3.1", "eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-webpack": "^0.13.1", "eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-disable": "^2.0.1", "eslint-plugin-disable": "^2.0.1",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.23.4",
"eslint-plugin-lit": "^1.3.0", "eslint-plugin-lit": "^1.5.1",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-unused-imports": "^1.1.2",
"eslint-plugin-wc": "^1.3.0", "eslint-plugin-wc": "^1.3.0",
"fancy-log": "^1.3.3", "fancy-log": "^1.3.3",
"fs-extra": "^7.0.1", "fs-extra": "^7.0.1",
@ -198,7 +199,7 @@
"gulp-zopfli-green": "^3.0.1", "gulp-zopfli-green": "^3.0.1",
"html-minifier": "^4.0.0", "html-minifier": "^4.0.0",
"husky": "^1.3.1", "husky": "^1.3.1",
"lint-staged": "^10.5.4", "lint-staged": "^11.0.1",
"lit-analyzer": "^1.2.1", "lit-analyzer": "^1.2.1",
"lodash.template": "^4.5.0", "lodash.template": "^4.5.0",
"magic-string": "^0.25.7", "magic-string": "^0.25.7",
@ -207,7 +208,7 @@
"mocha": "^8.4.0", "mocha": "^8.4.0",
"object-hash": "^2.0.3", "object-hash": "^2.0.3",
"open": "^7.0.4", "open": "^7.0.4",
"prettier": "^2.0.4", "prettier": "^2.3.2",
"require-dir": "^1.2.0", "require-dir": "^1.2.0",
"rollup": "^2.8.2", "rollup": "^2.8.2",
"rollup-plugin-string": "^3.0.0", "rollup-plugin-string": "^3.0.0",
@ -220,7 +221,7 @@
"terser-webpack-plugin": "^5.1.4", "terser-webpack-plugin": "^5.1.4",
"ts-lit-plugin": "^1.2.1", "ts-lit-plugin": "^1.2.1",
"ts-mocha": "^8.0.0", "ts-mocha": "^8.0.0",
"typescript": "^4.2.4", "typescript": "^4.3.5",
"vinyl-buffer": "^1.0.1", "vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0", "vinyl-source-stream": "^2.0.0",
"webpack": "^5.43.0", "webpack": "^5.43.0",

View File

@ -26,6 +26,9 @@ function checkToLocaleStringSupportsOptions() {
return false; return false;
} }
export const toLocaleDateStringSupportsOptions = checkToLocaleDateStringSupportsOptions(); export const toLocaleDateStringSupportsOptions =
export const toLocaleTimeStringSupportsOptions = checkToLocaleTimeStringSupportsOptions(); checkToLocaleDateStringSupportsOptions();
export const toLocaleStringSupportsOptions = checkToLocaleStringSupportsOptions(); export const toLocaleTimeStringSupportsOptions =
checkToLocaleTimeStringSupportsOptions();
export const toLocaleStringSupportsOptions =
checkToLocaleStringSupportsOptions();

View File

@ -82,14 +82,18 @@ class Storage {
const storage = new Storage(); const storage = new Storage();
export const LocalStorage = ( export const LocalStorage =
(
storageKey?: string, storageKey?: string,
property?: boolean, property?: boolean,
propertyOptions?: PropertyDeclaration propertyOptions?: PropertyDeclaration
): any => (clsElement: ClassElement) => { ): any =>
(clsElement: ClassElement) => {
const key = String(clsElement.key); const key = String(clsElement.key);
storageKey = storageKey || String(clsElement.key); storageKey = storageKey || String(clsElement.key);
const initVal = clsElement.initializer ? clsElement.initializer() : undefined; const initVal = clsElement.initializer
? clsElement.initializer()
: undefined;
storage.addFromStorage(storageKey); storage.addFromStorage(storageKey);
@ -145,4 +149,4 @@ export const LocalStorage = (
} }
}, },
}; };
}; };

View File

@ -1,9 +1,9 @@
import type { LitElement } from "lit"; import type { LitElement } from "lit";
import type { ClassElement } from "../../types"; import type { ClassElement } from "../../types";
export const restoreScroll = (selector: string): any => ( export const restoreScroll =
element: ClassElement (selector: string): any =>
) => ({ (element: ClassElement) => ({
kind: "method", kind: "method",
placement: "prototype", placement: "prototype",
key: element.key, key: element.key,
@ -30,4 +30,4 @@ export const restoreScroll = (selector: string): any => (
} }
}; };
}, },
}); });

View File

@ -67,9 +67,11 @@ class SearchInput extends LitElement {
changedProps.has("noUnderline") && changedProps.has("noUnderline") &&
(this.noUnderline || changedProps.get("noUnderline") !== undefined) (this.noUnderline || changedProps.get("noUnderline") !== undefined)
) { ) {
(this._input.inputElement!.parentElement!.shadowRoot!.querySelector( (
this._input.inputElement!.parentElement!.shadowRoot!.querySelector(
"div.unfocused-line" "div.unfocused-line"
) as HTMLElement).style.display = this.noUnderline ? "none" : "block"; ) as HTMLElement
).style.display = this.noUnderline ? "none" : "block";
} }
} }

View File

@ -6,6 +6,7 @@
// 3. Disallow dates based on week number. // 3. Disallow dates based on week number.
// 4. Disallow dates only consisting of a year. // 4. Disallow dates only consisting of a year.
// https://regex101.com/r/kc5C14/3 // https://regex101.com/r/kc5C14/3
const regexp = /^\d{4}-(0[1-9]|1[0-2])-([12]\d|0[1-9]|3[01])[T| ](((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)(\8[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)$/; const regexp =
/^\d{4}-(0[1-9]|1[0-2])-([12]\d|0[1-9]|3[01])[T| ](((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)(\8[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)$/;
export const isTimestamp = (input: string): boolean => regexp.test(input); export const isTimestamp = (input: string): boolean => regexp.test(input);

View File

@ -64,18 +64,18 @@ class HaCallServiceButton extends EventsMixin(PolymerElement) {
this.hass this.hass
.callService(this.domain, this.service, this.serviceData) .callService(this.domain, this.service, this.serviceData)
.then( .then(
function () { () => {
el.progress = false; el.progress = false;
el.$.progress.actionSuccess(); el.$.progress.actionSuccess();
eventData.success = true; eventData.success = true;
}, },
function () { () => {
el.progress = false; el.progress = false;
el.$.progress.actionError(); el.$.progress.actionError();
eventData.success = false; eventData.success = false;
} }
) )
.then(function () { .then(() => {
el.fire("hass-service-called", eventData); el.fire("hass-service-called", eventData);
}); });
} }

View File

@ -176,9 +176,9 @@ export class StateHistoryChartTimeline extends LitElement {
labelColor: (item) => ({ labelColor: (item) => ({
borderColor: (item.dataset.data[item.dataIndex] as TimeLineData) borderColor: (item.dataset.data[item.dataIndex] as TimeLineData)
.color!, .color!,
backgroundColor: (item.dataset.data[ backgroundColor: (
item.dataIndex item.dataset.data[item.dataIndex] as TimeLineData
] as TimeLineData).color!, ).color!,
}), }),
}, },
}, },

View File

@ -19,10 +19,9 @@ export class TextBarElement extends BarElement {
draw(ctx) { draw(ctx) {
super.draw(ctx); super.draw(ctx);
const options = this.options as TextBaroptions; const options = this.options as TextBaroptions;
const { x, y, base, width, text } = (this as BarElement< const { x, y, base, width, text } = (
TextBarProps, this as BarElement<TextBarProps, TextBaroptions>
TextBaroptions ).getProps(["x", "y", "base", "width", "text"]);
>).getProps(["x", "y", "base", "width", "text"]);
if (!text) { if (!text) {
return; return;

View File

@ -1,4 +1,3 @@
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
import deepClone from "deep-clone-simple"; import deepClone from "deep-clone-simple";
import { import {
css, css,
@ -19,6 +18,7 @@ import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined"; import { ifDefined } from "lit/directives/if-defined";
import { styleMap } from "lit/directives/style-map"; import { styleMap } from "lit/directives/style-map";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
import { restoreScroll } from "../../common/decorators/restore-scroll"; import { restoreScroll } from "../../common/decorators/restore-scroll";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import "../../common/search/search-input"; import "../../common/search/search-input";
@ -360,9 +360,8 @@ export class HaDataTable extends LitElement {
.rowId=${row[this.id]} .rowId=${row[this.id]}
@click=${this._handleRowClick} @click=${this._handleRowClick}
class="mdc-data-table__row ${classMap({ class="mdc-data-table__row ${classMap({
"mdc-data-table__row--selected": this._checkedRows.includes( "mdc-data-table__row--selected":
String(row[this.id]) this._checkedRows.includes(String(row[this.id])),
),
clickable: this.clickable, clickable: this.clickable,
})}" })}"
aria-selected=${ifDefined( aria-selected=${ifDefined(
@ -406,17 +405,15 @@ export class HaDataTable extends LitElement {
"mdc-data-table__cell--icon": Boolean( "mdc-data-table__cell--icon": Boolean(
column.type === "icon" column.type === "icon"
), ),
"mdc-data-table__cell--icon-button": Boolean( "mdc-data-table__cell--icon-button":
column.type === "icon-button" Boolean(column.type === "icon-button"),
),
grows: Boolean(column.grows), grows: Boolean(column.grows),
forceLTR: Boolean(column.forceLTR), forceLTR: Boolean(column.forceLTR),
})}" })}"
style=${column.width style=${column.width
? styleMap({ ? styleMap({
[column.grows [column.grows ? "minWidth" : "width"]:
? "minWidth" column.width,
: "width"]: column.width,
maxWidth: column.maxWidth maxWidth: column.maxWidth
? column.maxWidth ? column.maxWidth
: "", : "",

View File

@ -15,6 +15,7 @@ import {
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
} from "lit"; } from "lit";
import { ComboBoxLitRenderer, comboBoxRenderer } from "lit-vaadin-helpers";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
@ -38,7 +39,6 @@ import { PolymerChangedEvent } from "../../polymer-types";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import "../ha-svg-icon"; import "../ha-svg-icon";
import "./ha-devices-picker"; import "./ha-devices-picker";
import { ComboBoxLitRenderer, comboBoxRenderer } from "lit-vaadin-helpers";
interface DevicesByArea { interface DevicesByArea {
[areaId: string]: AreaDevices; [areaId: string]: AreaDevices;

View File

@ -11,6 +11,7 @@ import {
} from "lit"; } from "lit";
import { customElement, property, state, query } from "lit/decorators"; import { customElement, property, state, query } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { computeDomain } from "../../common/entity/compute_domain"; import { computeDomain } from "../../common/entity/compute_domain";
import { compare } from "../../common/string/compare"; import { compare } from "../../common/string/compare";
@ -33,7 +34,6 @@ import { PolymerChangedEvent } from "../../polymer-types";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
interface Device { interface Device {
name: string; name: string;

View File

@ -1,5 +1,6 @@
import { html, LitElement, TemplateResult } from "lit"; import { html, LitElement, TemplateResult } from "lit";
import { customElement, property, state, query } from "lit/decorators"; import { customElement, property, state, query } from "lit/decorators";
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
import { isComponentLoaded } from "../common/config/is_component_loaded"; import { isComponentLoaded } from "../common/config/is_component_loaded";
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import { compare } from "../common/string/compare"; import { compare } from "../common/string/compare";
@ -9,7 +10,6 @@ import { showAlertDialog } from "../dialogs/generic/show-dialog-box";
import { PolymerChangedEvent } from "../polymer-types"; import { PolymerChangedEvent } from "../polymer-types";
import { HomeAssistant } from "../types"; import { HomeAssistant } from "../types";
import { HaComboBox } from "./ha-combo-box"; import { HaComboBox } from "./ha-combo-box";
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
const rowRenderer: ComboBoxLitRenderer<HassioAddonInfo> = (item) => html`<style> const rowRenderer: ComboBoxLitRenderer<HassioAddonInfo> = (item) => html`<style>
paper-item { paper-item {

View File

@ -2,6 +2,7 @@ import "@material/mwc-menu";
import type { Corner, Menu } from "@material/mwc-menu"; import type { Corner, Menu } from "@material/mwc-menu";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators"; import { customElement, property, query } from "lit/decorators";
@customElement("ha-button-menu") @customElement("ha-button-menu")
export class HaButtonMenu extends LitElement { export class HaButtonMenu extends LitElement {
@property() public corner: Corner = "TOP_START"; @property() public corner: Corner = "TOP_START";

View File

@ -43,9 +43,9 @@ export class HaFileUpload extends LitElement {
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
if (changedProperties.has("_drag") && !this.uploading) { if (changedProperties.has("_drag") && !this.uploading) {
(this.shadowRoot!.querySelector( (
"paper-input-container" this.shadowRoot!.querySelector("paper-input-container") as any
) as any)._setFocused(this._drag); )._setFocused(this._drag);
} }
} }

View File

@ -94,8 +94,9 @@ export class HaFormMultiSelect extends LitElement implements HaFormElement {
protected firstUpdated() { protected firstUpdated() {
this.updateComplete.then(() => { this.updateComplete.then(() => {
const input = (this.shadowRoot?.querySelector("paper-input") const input = (
?.inputElement as any)?.inputElement; this.shadowRoot?.querySelector("paper-input")?.inputElement as any
)?.inputElement;
if (input) { if (input) {
input.style.textOverflow = "ellipsis"; input.style.textOverflow = "ellipsis";
} }

View File

@ -1,6 +1,7 @@
import { Formfield } from "@material/mwc-formfield"; import { Formfield } from "@material/mwc-formfield";
import { css, CSSResultGroup } from "lit"; import { css, CSSResultGroup } from "lit";
import { customElement } from "lit/decorators"; import { customElement } from "lit/decorators";
@customElement("ha-formfield") @customElement("ha-formfield")
// @ts-expect-error // @ts-expect-error
export class HaFormfield extends Formfield { export class HaFormfield extends Formfield {

View File

@ -96,7 +96,7 @@ class HaHLSPlayer extends LitElement {
const useExoPlayerPromise = this._getUseExoPlayer(); const useExoPlayerPromise = this._getUseExoPlayer();
const masterPlaylistPromise = fetch(this.url); const masterPlaylistPromise = fetch(this.url);
const Hls: typeof HlsType = (await import("hls.js/dist/hls.light.min.js")) const Hls: typeof HlsType = (await import("hls.js/dist/hls.light.min"))
.default; .default;
let hlsSupported = Hls.isSupported(); let hlsSupported = Hls.isSupported();
@ -117,7 +117,8 @@ class HaHLSPlayer extends LitElement {
// Parse playlist assuming it is a master playlist. Match group 1 is whether hevc, match group 2 is regular playlist url // Parse playlist assuming it is a master playlist. Match group 1 is whether hevc, match group 2 is regular playlist url
// See https://tools.ietf.org/html/rfc8216 for HLS spec details // See https://tools.ietf.org/html/rfc8216 for HLS spec details
const playlistRegexp = /#EXT-X-STREAM-INF:.*?(?:CODECS=".*?(hev1|hvc1)?\..*?".*?)?(?:\n|\r\n)(.+)/g; const playlistRegexp =
/#EXT-X-STREAM-INF:.*?(?:CODECS=".*?(hev1|hvc1)?\..*?".*?)?(?:\n|\r\n)(.+)/g;
const match = playlistRegexp.exec(masterPlaylist); const match = playlistRegexp.exec(masterPlaylist);
const matchTwice = playlistRegexp.exec(masterPlaylist); const matchTwice = playlistRegexp.exec(masterPlaylist);

View File

@ -1,5 +1,6 @@
import { Radio } from "@material/mwc-radio"; import { Radio } from "@material/mwc-radio";
import { customElement } from "lit/decorators"; import { customElement } from "lit/decorators";
@customElement("ha-radio") @customElement("ha-radio")
export class HaRadio extends Radio { export class HaRadio extends Radio {
public firstUpdated() { public firstUpdated() {

View File

@ -153,9 +153,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
</h3> </h3>
<ul> <ul>
${this._related.entity.map((entityId) => { ${this._related.entity.map((entityId) => {
const entity: HassEntity | undefined = this.hass.states[ const entity: HassEntity | undefined =
entityId this.hass.states[entityId];
];
if (!entity) { if (!entity) {
return ""; return "";
} }
@ -203,9 +202,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
<h3>${this.hass.localize("ui.components.related-items.scene")}:</h3> <h3>${this.hass.localize("ui.components.related-items.scene")}:</h3>
<ul> <ul>
${this._related.scene.map((sceneId) => { ${this._related.scene.map((sceneId) => {
const scene: SceneEntity | undefined = this.hass.states[ const scene: SceneEntity | undefined =
sceneId this.hass.states[sceneId];
];
if (!scene) { if (!scene) {
return ""; return "";
} }
@ -231,9 +229,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
</h3> </h3>
<ul> <ul>
${this._related.automation.map((automationId) => { ${this._related.automation.map((automationId) => {
const automation: HassEntity | undefined = this.hass.states[ const automation: HassEntity | undefined =
automationId this.hass.states[automationId];
];
if (!automation) { if (!automation) {
return ""; return "";
} }
@ -260,9 +257,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
</h3> </h3>
<ul> <ul>
${this._related.script.map((scriptId) => { ${this._related.script.map((scriptId) => {
const script: HassEntity | undefined = this.hass.states[ const script: HassEntity | undefined =
scriptId this.hass.states[scriptId];
];
if (!script) { if (!script) {
return ""; return "";
} }

View File

@ -1,4 +1,5 @@
import { html, LitElement } from "lit"; import { html, LitElement } from "lit";
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
import { property, state } from "lit/decorators"; import { property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
@ -6,7 +7,6 @@ import { LocalizeFunc } from "../common/translations/localize";
import { domainToName } from "../data/integration"; import { domainToName } from "../data/integration";
import { HomeAssistant } from "../types"; import { HomeAssistant } from "../types";
import "./ha-combo-box"; import "./ha-combo-box";
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
const rowRenderer: ComboBoxLitRenderer<{ service: string; name: string }> = ( const rowRenderer: ComboBoxLitRenderer<{ service: string; name: string }> = (
item item

View File

@ -2,6 +2,7 @@ import { Switch } from "@material/mwc-switch";
import { css, CSSResultGroup } from "lit"; import { css, CSSResultGroup } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { forwardHaptic } from "../data/haptics"; import { forwardHaptic } from "../data/haptics";
@customElement("ha-switch") @customElement("ha-switch")
// @ts-expect-error // @ts-expect-error
export class HaSwitch extends Switch { export class HaSwitch extends Switch {

View File

@ -180,9 +180,8 @@ export class HaLocationsEditor extends LitElement {
const locationMarkers = {}; const locationMarkers = {};
const circles = {}; const circles = {};
const defaultZoneRadiusColor = getComputedStyle(this).getPropertyValue( const defaultZoneRadiusColor =
"--accent-color" getComputedStyle(this).getPropertyValue("--accent-color");
);
this.locations.forEach((location: MarkerLocation) => { this.locations.forEach((location: MarkerLocation) => {
let icon: DivIcon | undefined; let icon: DivIcon | undefined;

View File

@ -132,9 +132,8 @@ export class HaMediaPlayerBrowse extends LitElement {
return html``; return html``;
} }
const currentItem = this._mediaPlayerItems[ const currentItem =
this._mediaPlayerItems.length - 1 this._mediaPlayerItems[this._mediaPlayerItems.length - 1];
];
const previousItem: MediaPlayerItem | undefined = const previousItem: MediaPlayerItem | undefined =
this._mediaPlayerItems.length > 1 this._mediaPlayerItems.length > 1

View File

@ -111,14 +111,8 @@ export class HaTracePathDetails extends LitElement {
parts.push( parts.push(
data.map((trace, idx) => { data.map((trace, idx) => {
const { const { path, timestamp, result, error, changed_variables, ...rest } =
path, trace as any;
timestamp,
result,
error,
changed_variables,
...rest
} = trace as any;
return html` return html`
${curPath === this.selected.path ${curPath === this.selected.path

View File

@ -178,9 +178,8 @@ class HatScriptGraph extends LitElement {
trace !== undefined && trace[0].result?.choice === i; trace !== undefined && trace[0].result?.choice === i;
this.renderedNodes[branch_path] = { config, path: branch_path }; this.renderedNodes[branch_path] = { config, path: branch_path };
if (track_this) { if (track_this) {
this.trackedNodes[branch_path] = this.renderedNodes[ this.trackedNodes[branch_path] =
branch_path this.renderedNodes[branch_path];
];
} }
return html` return html`
<hat-graph> <hat-graph>
@ -489,9 +488,9 @@ class HatScriptGraph extends LitElement {
: ""} : ""}
${"condition" in this.trace.config ${"condition" in this.trace.config
? html`<hat-graph id="condition"> ? html`<hat-graph id="condition">
${ensureArray( ${ensureArray(this.trace.config.condition)?.map(
this.trace.config.condition (condition, i) => this.render_condition(condition!, i)
)?.map((condition, i) => this.render_condition(condition!, i))} )}
</hat-graph>` </hat-graph>`
: ""} : ""}
${"action" in this.trace.config ${"action" in this.trace.config
@ -535,12 +534,12 @@ class HatScriptGraph extends LitElement {
} }
} }
protected update(changedProps: PropertyValues<this>) { public willUpdate(changedProps: PropertyValues<this>) {
super.willUpdate(changedProps);
if (changedProps.has("trace")) { if (changedProps.has("trace")) {
this.renderedNodes = {}; this.renderedNodes = {};
this.trackedNodes = {}; this.trackedNodes = {};
} }
super.update(changedProps);
} }
protected updated(changedProps: PropertyValues<this>) { protected updated(changedProps: PropertyValues<this>) {

View File

@ -121,9 +121,8 @@ class LogbookRenderer {
return; return;
} }
const previousEntryDate = this.pendingItems[ const previousEntryDate =
this.pendingItems.length - 1 this.pendingItems[this.pendingItems.length - 1][0];
][0];
// If logbook entry is too long after the last one, // If logbook entry is too long after the last one,
// add a time passed label // add a time passed label

View File

@ -6,7 +6,8 @@ export const subscribeBootstrapIntegrations = (
hass: HomeAssistant, hass: HomeAssistant,
callback: (message: BootstrapIntegrationsTimings) => void callback: (message: BootstrapIntegrationsTimings) => void
) => { ) => {
const unsubProm = hass.connection.subscribeMessage<BootstrapIntegrationsTimings>( const unsubProm =
hass.connection.subscribeMessage<BootstrapIntegrationsTimings>(
(message) => callback(message), (message) => callback(message),
{ {
type: "subscribe_bootstrap_integrations", type: "subscribe_bootstrap_integrations",

View File

@ -9,7 +9,8 @@ export interface DiscoveryInformation {
version: string; version: string;
} }
export const fetchDiscoveryInformation = async (): Promise<DiscoveryInformation> => { export const fetchDiscoveryInformation =
async (): Promise<DiscoveryInformation> => {
const response = await fetch("/api/discovery_info", { method: "GET" }); const response = await fetch("/api/discovery_info", { method: "GET" });
return response.json(); return response.json();
}; };

View File

@ -14,7 +14,8 @@ import { HaDomainTogglerDialogParams } from "./show-dialog-domain-toggler";
@customElement("dialog-domain-toggler") @customElement("dialog-domain-toggler")
class DomainTogglerDialog class DomainTogglerDialog
extends LitElement extends LitElement
implements HassDialog<HaDomainTogglerDialogParams> { implements HassDialog<HaDomainTogglerDialogParams>
{
public hass!: HomeAssistant; public hass!: HomeAssistant;
@state() private _params?: HaDomainTogglerDialogParams; @state() private _params?: HaDomainTogglerDialogParams;

View File

@ -136,12 +136,12 @@ class MoreInfoConfigurator extends PolymerElement {
this.isConfiguring = true; this.isConfiguring = true;
this.hass.callService("configurator", "configure", data).then( this.hass.callService("configurator", "configure", data).then(
function () { () => {
this.isConfiguring = false; this.isConfiguring = false;
}.bind(this), },
function () { () => {
this.isConfiguring = false; this.isConfiguring = false;
}.bind(this) }
); );
} }
} }

View File

@ -444,9 +444,7 @@ class MoreInfoLight extends LitElement {
value = (value * 255) / 100; value = (value * 255) / 100;
const rgb = (getLightCurrentModeRgbColor(this.stateObj!)?.slice(0, 3) || [ const rgb = (getLightCurrentModeRgbColor(this.stateObj!)?.slice(0, 3) || [
255, 255, 255, 255,
255,
255,
]) as [number, number, number]; ]) as [number, number, number];
this._setRgbWColor( this._setRgbWColor(

View File

@ -181,7 +181,7 @@ export class HuiNotificationDrawer extends EventsMixin(
const notifications = notificationsBackend.concat(configuratorEntities); const notifications = notificationsBackend.concat(configuratorEntities);
notifications.sort(function (n1, n2) { notifications.sort((n1, n2) => {
const d1 = new Date(n1.created_at); const d1 = new Date(n1.created_at);
const d2 = new Date(n2.created_at); const d2 = new Date(n2.created_at);

View File

@ -1,4 +1,3 @@
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
import "@material/mwc-list/mwc-list"; import "@material/mwc-list/mwc-list";
import type { List } from "@material/mwc-list/mwc-list"; import type { List } from "@material/mwc-list/mwc-list";
import { SingleSelectedEvent } from "@material/mwc-list/mwc-list-foundation"; import { SingleSelectedEvent } from "@material/mwc-list/mwc-list-foundation";
@ -39,6 +38,7 @@ import { domainToName } from "../../data/integration";
import { getPanelNameTranslationKey } from "../../data/panel"; import { getPanelNameTranslationKey } from "../../data/panel";
import { PageNavigation } from "../../layouts/hass-tabs-subpage"; import { PageNavigation } from "../../layouts/hass-tabs-subpage";
import { configSections } from "../../panels/config/ha-panel-config"; import { configSections } from "../../panels/config/ha-panel-config";
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
import { haStyleDialog } from "../../resources/styles"; import { haStyleDialog } from "../../resources/styles";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import { import {

View File

@ -344,7 +344,8 @@ export class HaVoiceCommandDialog extends LitElement {
} }
private _scrollMessagesBottom() { private _scrollMessagesBottom() {
this.messages.scrollTarget.scrollTop = this.messages.scrollTarget.scrollHeight; this.messages.scrollTarget.scrollTop =
this.messages.scrollTarget.scrollHeight;
if (this.messages.scrollTarget.scrollTop === 0) { if (this.messages.scrollTarget.scrollTop === 0) {
fireEvent(this.messages, "iron-resize"); fireEvent(this.messages, "iron-resize");
} }

View File

@ -107,7 +107,7 @@ function initPushNotifications() {
); );
} }
self.addEventListener("push", function (event) { self.addEventListener("push", (event) => {
let data; let data;
if (event.data) { if (event.data) {
data = event.data.json(); data = event.data.json();
@ -122,7 +122,7 @@ function initPushNotifications() {
event.waitUntil( event.waitUntil(
self.registration self.registration
.showNotification(data.title, data) .showNotification(data.title, data)
.then(function (/* notification */) { .then((/* notification */) => {
firePushCallback( firePushCallback(
{ {
type: "received", type: "received",
@ -136,7 +136,7 @@ function initPushNotifications() {
} }
}); });
self.addEventListener("notificationclick", function (event) { self.addEventListener("notificationclick", (event) => {
notificationEventCallback("clicked", event); notificationEventCallback("clicked", event);
event.notification.close(); event.notification.close();
@ -158,7 +158,7 @@ function initPushNotifications() {
.matchAll({ .matchAll({
type: "window", type: "window",
}) })
.then(function (windowClients) { .then((windowClients) => {
let i; let i;
let client; let client;
for (i = 0; i < windowClients.length; i++) { for (i = 0; i < windowClients.length; i++) {
@ -175,7 +175,7 @@ function initPushNotifications() {
); );
}); });
self.addEventListener("notificationclose", function (event) { self.addEventListener("notificationclose", (event) => {
notificationEventCallback("closed", event); notificationEventCallback("closed", event);
}); });
} }

View File

@ -1,6 +1,6 @@
import { isNavigationClick } from "../common/dom/is-navigation-click";
import { html, PropertyValues } from "lit"; import { html, PropertyValues } from "lit";
import { customElement, state } from "lit/decorators"; import { customElement, state } from "lit/decorators";
import { isNavigationClick } from "../common/dom/is-navigation-click";
import { navigate } from "../common/navigate"; import { navigate } from "../common/navigate";
import { getStorageDefaultPanelUrlPath } from "../data/panel"; import { getStorageDefaultPanelUrlPath } from "../data/panel";
import "../resources/custom-card-support"; import "../resources/custom-card-support";

View File

@ -99,7 +99,7 @@ class SupervisorErrorScreen extends LitElement {
} }
} else { } else {
themeName = themeName =
((this.hass.selectedTheme as unknown) as string) || (this.hass.selectedTheme as unknown as string) ||
this.hass.themes.default_theme; this.hass.themes.default_theme;
} }

View File

@ -51,7 +51,7 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
private __checkSubscribed(): void { private __checkSubscribed(): void {
if ( if (
this.__unsubs !== undefined || this.__unsubs !== undefined ||
!((this as unknown) as Element).isConnected || !(this as unknown as Element).isConnected ||
this.hass === undefined this.hass === undefined
) { ) {
return; return;

View File

@ -254,7 +254,8 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
this._loading = true; this._loading = true;
// Determine if oauth redirect has been provided // Determine if oauth redirect has been provided
const externalAuthParams = extractSearchParamsObject() as AuthUrlSearchParams; const externalAuthParams =
extractSearchParamsObject() as AuthUrlSearchParams;
const authParams = const authParams =
externalAuthParams.client_id && externalAuthParams.redirect_uri externalAuthParams.client_id && externalAuthParams.redirect_uri
? externalAuthParams ? externalAuthParams

View File

@ -52,9 +52,13 @@ class HaConfigAreaPage extends LitElement {
@state() private _related?: RelatedResult; @state() private _related?: RelatedResult;
private _area = memoizeOne((areaId: string, areas: AreaRegistryEntry[]): private _area = memoizeOne(
| AreaRegistryEntry (
| undefined => areas.find((area) => area.area_id === areaId)); areaId: string,
areas: AreaRegistryEntry[]
): AreaRegistryEntry | undefined =>
areas.find((area) => area.area_id === areaId)
);
private _memberships = memoizeOne( private _memberships = memoizeOne(
( (

View File

@ -12,7 +12,8 @@ import { ActionElement, handleChangeEvent } from "../ha-automation-action-row";
@customElement("ha-automation-action-wait_for_trigger") @customElement("ha-automation-action-wait_for_trigger")
export class HaWaitForTriggerAction export class HaWaitForTriggerAction
extends LitElement extends LitElement
implements ActionElement { implements ActionElement
{
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@property() public action!: WaitForTriggerAction; @property() public action!: WaitForTriggerAction;

View File

@ -20,13 +20,8 @@ export default class HaNumericStateCondition extends LitElement {
} }
public render() { public render() {
const { const { value_template, entity_id, attribute, below, above } =
value_template, this.condition;
entity_id,
attribute,
below,
above,
} = this.condition;
return html` return html`
<ha-entity-picker <ha-entity-picker

View File

@ -1,15 +1,15 @@
import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { html, LitElement } from "lit"; import { html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
import { ensureArray } from "../../../../../common/ensure-array";
import { import {
AutomationConfig, AutomationConfig,
Trigger, Trigger,
TriggerCondition, TriggerCondition,
} from "../../../../../data/automation"; } from "../../../../../data/automation";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
import { ensureArray } from "../../../../../common/ensure-array";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
@customElement("ha-automation-condition-trigger") @customElement("ha-automation-condition-trigger")
export class HaTriggerCondition extends LitElement { export class HaTriggerCondition extends LitElement {

View File

@ -61,7 +61,8 @@ class HaAutomationPicker extends LitElement {
if (filteredAutomations === null) { if (filteredAutomations === null) {
return []; return [];
} }
return (filteredAutomations return (
filteredAutomations
? automations.filter((automation) => ? automations.filter((automation) =>
filteredAutomations!.includes(automation.entity_id) filteredAutomations!.includes(automation.entity_id)
) )

View File

@ -433,8 +433,8 @@ export class HaAutomationTrace extends LitElement {
private _timelinePathPicked(ev) { private _timelinePathPicked(ev) {
const path = ev.detail.value; const path = ev.detail.value;
const nodes = this.shadowRoot!.querySelector("hat-script-graph")! const nodes =
.trackedNodes; this.shadowRoot!.querySelector("hat-script-graph")!.trackedNodes;
if (nodes[path]) { if (nodes[path]) {
this._selected = nodes[path]; this._selected = nodes[path];
} }

View File

@ -197,7 +197,8 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
]) ])
)}`} )}`}
.entityFilter=${(entityState: HassEntity) => { .entityFilter=${(entityState: HassEntity) => {
const devId = this._placeholderValues[type][ const devId =
this._placeholderValues[type][
placeholder.index placeholder.index
][idx].device_id; ][idx].device_id;
return this._deviceEntityLookup[ return this._deviceEntityLookup[

View File

@ -7,6 +7,7 @@ import { fetchTags, Tag } from "../../../../../data/tag";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import { TriggerElement } from "../ha-automation-trigger-row"; import { TriggerElement } from "../ha-automation-trigger-row";
import "../../../../../components/ha-paper-dropdown-menu"; import "../../../../../components/ha-paper-dropdown-menu";
@customElement("ha-automation-trigger-tag") @customElement("ha-automation-trigger-tag")
export class HaTagTrigger extends LitElement implements TriggerElement { export class HaTagTrigger extends LitElement implements TriggerElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;

View File

@ -22,11 +22,8 @@ export class CloudGooglePref extends LitElement {
return html``; return html``;
} }
const { const { google_enabled, google_report_state, google_secure_devices_pin } =
google_enabled, this.cloudStatus.prefs;
google_report_state,
google_secure_devices_pin,
} = this.cloudStatus.prefs;
return html` return html`
<ha-card <ha-card

View File

@ -28,11 +28,8 @@ export class CloudRemotePref extends LitElement {
const { remote_enabled } = this.cloudStatus.prefs; const { remote_enabled } = this.cloudStatus.prefs;
const { const { remote_connected, remote_domain, remote_certificate } =
remote_connected, this.cloudStatus;
remote_domain,
remote_certificate,
} = this.cloudStatus;
if (!remote_certificate) { if (!remote_certificate) {
return html` return html`

View File

@ -32,9 +32,8 @@ export class HaDeviceActionsOzw extends LitElement {
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
const identifiers: const identifiers: OZWNodeIdentifiers | undefined =
| OZWNodeIdentifiers getIdentifiersFromDevice(this.device);
| undefined = getIdentifiersFromDevice(this.device);
if (!identifiers) { if (!identifiers) {
return; return;
} }

View File

@ -33,9 +33,8 @@ export class HaDeviceInfoOzw extends LitElement {
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
const identifiers: const identifiers: OZWNodeIdentifiers | undefined =
| OZWNodeIdentifiers getIdentifiersFromDevice(this.device);
| undefined = getIdentifiersFromDevice(this.device);
if (!identifiers) { if (!identifiers) {
return; return;
} }

View File

@ -31,9 +31,8 @@ export class HaDeviceActionsZWaveJS extends LitElement {
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
this._entryId = this.device.config_entries[0]; this._entryId = this.device.config_entries[0];
const identifiers: const identifiers: ZWaveJSNodeIdentifiers | undefined =
| ZWaveJSNodeIdentifiers getIdentifiersFromDevice(this.device);
| undefined = getIdentifiersFromDevice(this.device);
if (!identifiers) { if (!identifiers) {
return; return;
} }

View File

@ -40,9 +40,8 @@ export class HaDeviceInfoZWaveJS extends LitElement {
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
if (changedProperties.has("device")) { if (changedProperties.has("device")) {
const identifiers: const identifiers: ZWaveJSNodeIdentifiers | undefined =
| ZWaveJSNodeIdentifiers getIdentifiersFromDevice(this.device);
| undefined = getIdentifiersFromDevice(this.device);
if (!identifiers) { if (!identifiers) {
return; return;
} }

View File

@ -110,18 +110,19 @@ export class HaConfigDevicePage extends LitElement {
) )
); );
private _computeArea = memoizeOne((areas, device): private _computeArea = memoizeOne(
| AreaRegistryEntry (areas, device): AreaRegistryEntry | undefined => {
| undefined => {
if (!areas || !device || !device.area_id) { if (!areas || !device || !device.area_id) {
return undefined; return undefined;
} }
return areas.find((area) => area.area_id === device.area_id); return areas.find((area) => area.area_id === device.area_id);
}); }
);
private _batteryEntity = memoizeOne((entities: EntityRegistryEntry[]): private _batteryEntity = memoizeOne(
| EntityRegistryEntry (entities: EntityRegistryEntry[]): EntityRegistryEntry | undefined =>
| undefined => findBatteryEntity(this.hass, entities)); findBatteryEntity(this.hass, entities)
);
private _batteryChargingEntity = memoizeOne( private _batteryChargingEntity = memoizeOne(
(entities: EntityRegistryEntry[]): EntityRegistryEntry | undefined => (entities: EntityRegistryEntry[]): EntityRegistryEntry | undefined =>

View File

@ -100,9 +100,8 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
if (this.entry.entity_id !== this._origEntityId) { if (this.entry.entity_id !== this._origEntityId) {
return html``; return html``;
} }
const stateObj: HassEntity | undefined = this.hass.states[ const stateObj: HassEntity | undefined =
this.entry.entity_id this.hass.states[this.entry.entity_id];
];
const invalidDomainUpdate = const invalidDomainUpdate =
computeDomain(this._entityId.trim()) !== computeDomain(this._entityId.trim()) !==
computeDomain(this.entry.entity_id); computeDomain(this.entry.entity_id);

View File

@ -442,10 +442,8 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
this._entries this._entries
); );
const { const { filteredEntities, filteredDomains } =
filteredEntities, this._filteredEntitiesAndDomains(
filteredDomains,
} = this._filteredEntitiesAndDomains(
this._entities, this._entities,
this._devices, this._devices,
this._areas, this._areas,

View File

@ -54,9 +54,9 @@ class HaCounterForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -32,9 +32,9 @@ class HaInputBooleanForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -43,9 +43,9 @@ class HaInputDateTimeForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -58,9 +58,9 @@ class HaInputNumberForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -44,9 +44,9 @@ class HaInputSelectForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -49,9 +49,9 @@ class HaInputTextForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -35,9 +35,9 @@ class HaTimerForm extends LitElement {
public focus() { public focus() {
this.updateComplete.then(() => this.updateComplete.then(() =>
(this.shadowRoot?.querySelector( (
"[dialogInitialFocus]" this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
) as HTMLElement)?.focus() )?.focus()
); );
} }

View File

@ -38,8 +38,7 @@ export class HaConfigHelpers extends LitElement {
@state() private _stateItems: HassEntity[] = []; @state() private _stateItems: HassEntity[] = [];
private _columns = memoize( private _columns = memoize((narrow, _language): DataTableColumnContainer => {
(narrow, _language): DataTableColumnContainer => {
const columns: DataTableColumnContainer = { const columns: DataTableColumnContainer = {
icon: { icon: {
title: "", title: "",
@ -76,16 +75,13 @@ export class HaConfigHelpers extends LitElement {
}; };
} }
columns.type = { columns.type = {
title: this.hass.localize( title: this.hass.localize("ui.panel.config.helpers.picker.headers.type"),
"ui.panel.config.helpers.picker.headers.type"
),
sortable: true, sortable: true,
width: "25%", width: "25%",
filterable: true, filterable: true,
template: (type) => template: (type) =>
html` html`
${this.hass.localize(`ui.panel.config.helpers.types.${type}`) || ${this.hass.localize(`ui.panel.config.helpers.types.${type}`) || type}
type}
`, `,
}; };
columns.editable = { columns.editable = {
@ -110,8 +106,7 @@ export class HaConfigHelpers extends LitElement {
`, `,
}; };
return columns; return columns;
} });
);
private _getItems = memoize((stateItems: HassEntity[]) => private _getItems = memoize((stateItems: HassEntity[]) =>
stateItems.map((entityState) => ({ stateItems.map((entityState) => ({

View File

@ -87,9 +87,8 @@ class IntegrationsCard extends LitElement {
> >
` `
: ""; : "";
const setupSeconds = this._setups?.[domain]?.seconds?.toFixed( const setupSeconds =
2 this._setups?.[domain]?.seconds?.toFixed(2);
);
return html` return html`
<tr> <tr>
<td> <td>
@ -100,7 +99,11 @@ class IntegrationsCard extends LitElement {
/> />
</td> </td>
<td class="name"> <td class="name">
${domainToName(this.hass.localize, domain, manifest)}<br /> ${domainToName(
this.hass.localize,
domain,
manifest
)}<br />
<span class="domain">${domain}</span> <span class="domain">${domain}</span>
${this.narrow ${this.narrow
? html`<div class="mobile-row"> ? html`<div class="mobile-row">

View File

@ -1,5 +1,6 @@
import { CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { customElement, property, state } from "lit/decorators";
import { computeRTLDirection } from "../../../../../common/util/compute_rtl"; import { computeRTLDirection } from "../../../../../common/util/compute_rtl";
import "../../../../../components/ha-code-editor"; import "../../../../../components/ha-code-editor";
import { createCloseHeading } from "../../../../../components/ha-dialog"; import { createCloseHeading } from "../../../../../components/ha-dialog";
@ -14,7 +15,6 @@ import type {
import "../../../../../components/ha-circular-progress"; import "../../../../../components/ha-circular-progress";
import { fetchDevices, ZHADevice } from "../../../../../data/zha"; import { fetchDevices, ZHADevice } from "../../../../../data/zha";
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
import { customElement, property, state } from "lit/decorators";
export interface DeviceRowData extends DataTableRowData { export interface DeviceRowData extends DataTableRowData {
id: string; id: string;

View File

@ -35,9 +35,8 @@ class DialogZHAReconfigureDevice extends LitElement {
ClusterConfigurationStatus ClusterConfigurationStatus
> = new Map(); > = new Map();
@state() private _params: @state() private _params: ZHAReconfigureDeviceDialogParams | undefined =
| ZHAReconfigureDeviceDialogParams undefined;
| undefined = undefined;
@state() private _allSuccessful = true; @state() private _allSuccessful = true;
@ -341,7 +340,8 @@ class DialogZHAReconfigureDevice extends LitElement {
this._unsubscribe(); this._unsubscribe();
this._status = this._allSuccessful ? "finished" : "failed"; this._status = this._allSuccessful ? "finished" : "failed";
} else { } else {
const clusterConfigurationStatus = this._clusterConfigurationStatuses!.get( const clusterConfigurationStatus =
this._clusterConfigurationStatuses!.get(
message.zha_channel_msg_data.cluster_id message.zha_channel_msg_data.cluster_id
); );
if (message.type === ZHA_CHANNEL_MSG_BIND) { if (message.type === ZHA_CHANNEL_MSG_BIND) {

View File

@ -171,8 +171,9 @@ class ZHAAddDevicesPage extends LitElement {
if (this.shadowRoot) { if (this.shadowRoot) {
const paperTextArea = this.shadowRoot.querySelector("paper-textarea"); const paperTextArea = this.shadowRoot.querySelector("paper-textarea");
if (paperTextArea) { if (paperTextArea) {
const textArea = (paperTextArea.inputElement as IronAutogrowTextareaElement) const textArea = (
.textarea; paperTextArea.inputElement as IronAutogrowTextareaElement
).textarea;
textArea.scrollTop = textArea.scrollHeight; textArea.scrollTop = textArea.scrollHeight;
} }
} }

View File

@ -192,7 +192,8 @@ export class ZHAClusterCommands extends LitElement {
private _onManufacturerCodeOverrideChanged(value: ChangeEvent): void { private _onManufacturerCodeOverrideChanged(value: ChangeEvent): void {
this._manufacturerCodeOverride = value.detail!.value; this._manufacturerCodeOverride = value.detail!.value;
this._issueClusterCommandServiceData = this._computeIssueClusterCommandServiceData(); this._issueClusterCommandServiceData =
this._computeIssueClusterCommandServiceData();
} }
private _onHelpTap(): void { private _onHelpTap(): void {
@ -201,7 +202,8 @@ export class ZHAClusterCommands extends LitElement {
private _selectedCommandChanged(event: ItemSelectedEvent): void { private _selectedCommandChanged(event: ItemSelectedEvent): void {
this._selectedCommandIndex = event.target!.selected; this._selectedCommandIndex = event.target!.selected;
this._issueClusterCommandServiceData = this._computeIssueClusterCommandServiceData(); this._issueClusterCommandServiceData =
this._computeIssueClusterCommandServiceData();
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {

View File

@ -10,6 +10,7 @@ import {
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
} from "lit"; } from "lit";
import { customElement, property } from "lit/decorators";
import { computeRTL } from "../../../../../common/util/compute_rtl"; import { computeRTL } from "../../../../../common/util/compute_rtl";
import "../../../../../components/ha-card"; import "../../../../../components/ha-card";
import "../../../../../components/ha-fab"; import "../../../../../components/ha-fab";
@ -25,7 +26,6 @@ import {
updateZHAConfiguration, updateZHAConfiguration,
ZHAConfiguration, ZHAConfiguration,
} from "../../../../../data/zha"; } from "../../../../../data/zha";
import { customElement, property } from "lit/decorators";
export const zhaTabs: PageNavigation[] = [ export const zhaTabs: PageNavigation[] = [
{ {

View File

@ -2,6 +2,8 @@ import "@polymer/paper-input/paper-input";
import "@polymer/paper-listbox/paper-listbox"; import "@polymer/paper-listbox/paper-listbox";
import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import memoizeOne from "memoize-one";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
import { computeStateName } from "../../../../../common/entity/compute_state_name"; import { computeStateName } from "../../../../../common/entity/compute_state_name";
import "../../../../../components/buttons/ha-call-service-button"; import "../../../../../components/buttons/ha-call-service-button";
@ -20,12 +22,10 @@ import {
EntityRegistryEntry, EntityRegistryEntry,
updateEntityRegistryEntry, updateEntityRegistryEntry,
} from "../../../../../data/entity_registry"; } from "../../../../../data/entity_registry";
import memoizeOne from "memoize-one";
import { EntityRegistryStateEntry } from "../../../devices/ha-config-device-page"; import { EntityRegistryStateEntry } from "../../../devices/ha-config-device-page";
import { compare } from "../../../../../common/string/compare"; import { compare } from "../../../../../common/string/compare";
import { getIeeeTail } from "./functions"; import { getIeeeTail } from "./functions";
import { slugify } from "../../../../../common/string/slugify"; import { slugify } from "../../../../../common/string/slugify";
import { customElement, property, state } from "lit/decorators";
@customElement("zha-device-card") @customElement("zha-device-card")
class ZHADeviceCard extends SubscribeMixin(LitElement) { class ZHADeviceCard extends SubscribeMixin(LitElement) {

View File

@ -1,32 +1,31 @@
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
import "@material/mwc-button"; import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import {
Edge,
EdgeOptions,
Network,
Node,
} from "vis-network/peer/esm/vis-network";
import { navigate } from "../../../../../common/navigate"; import { navigate } from "../../../../../common/navigate";
import "../../../../../common/search/search-input";
import "../../../../../components/device/ha-device-picker";
import "../../../../../components/ha-button-menu";
import "../../../../../components/ha-checkbox";
import type { HaCheckbox } from "../../../../../components/ha-checkbox";
import "../../../../../components/ha-formfield";
import "../../../../../components/ha-svg-icon";
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
import { import {
fetchDevices, fetchDevices,
refreshTopology, refreshTopology,
ZHADevice, ZHADevice,
} from "../../../../../data/zha"; } from "../../../../../data/zha";
import "../../../../../layouts/hass-tabs-subpage"; import "../../../../../layouts/hass-tabs-subpage";
import type { HomeAssistant, Route } from "../../../../../types";
import {
Network,
Edge,
Node,
EdgeOptions,
} from "vis-network/peer/esm/vis-network";
import "../../../../../common/search/search-input";
import "../../../../../components/device/ha-device-picker";
import "../../../../../components/ha-button-menu";
import "../../../../../components/ha-svg-icon";
import { PolymerChangedEvent } from "../../../../../polymer-types"; import { PolymerChangedEvent } from "../../../../../polymer-types";
import type { HomeAssistant, Route } from "../../../../../types";
import { formatAsPaddedHex } from "./functions"; import { formatAsPaddedHex } from "./functions";
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
import "../../../../../components/ha-checkbox";
import type { HaCheckbox } from "../../../../../components/ha-checkbox";
import { zhaTabs } from "./zha-config-dashboard"; import { zhaTabs } from "./zha-config-dashboard";
import { customElement, property, query, state } from "lit/decorators";
import "../../../../../components/ha-formfield";
@customElement("zha-network-visualization-page") @customElement("zha-network-visualization-page")
export class ZHANetworkVisualizationPage extends LitElement { export class ZHANetworkVisualizationPage extends LitElement {
@ -225,9 +224,9 @@ export class ZHANetworkVisualizationPage extends LitElement {
}); });
if (device.neighbors && device.neighbors.length > 0) { if (device.neighbors && device.neighbors.length > 0) {
device.neighbors.forEach((neighbor) => { device.neighbors.forEach((neighbor) => {
const idx = edges.findIndex(function (e) { const idx = edges.findIndex(
return device.ieee === e.to && neighbor.ieee === e.from; (e) => device.ieee === e.to && neighbor.ieee === e.from
}); );
if (idx === -1) { if (idx === -1) {
edges.push({ edges.push({
from: device.ieee, from: device.ieee,

View File

@ -131,7 +131,7 @@ class ZwaveNodeProtection extends LocalizeMixin(PolymerElement) {
let options = []; let options = [];
let value_id = -1; let value_id = -1;
let selected = -1; let selected = -1;
this.protection.forEach(function (item) { this.protection.forEach((item) => {
if (item.key === "options") options = item.value; if (item.key === "options") options = item.value;
else if (item.key === "value_id") value_id = item.value; else if (item.key === "value_id") value_id = item.value;
else if (item.key === "selected") selected = item.value; else if (item.key === "selected") selected = item.value;

View File

@ -4,12 +4,12 @@ import "../../../../../components/ha-switch";
import "../../../../../components/ha-formfield"; import "../../../../../components/ha-formfield";
import { CSSResultGroup, html, LitElement, TemplateResult, css } from "lit"; import { CSSResultGroup, html, LitElement, TemplateResult, css } from "lit";
import "../../../../../components/ha-circular-progress"; import "../../../../../components/ha-circular-progress";
import { customElement, property, state } from "lit/decorators";
import { createCloseHeading } from "../../../../../components/ha-dialog"; import { createCloseHeading } from "../../../../../components/ha-dialog";
import { haStyleDialog } from "../../../../../resources/styles"; import { haStyleDialog } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import { ZWaveJSAddNodeDialogParams } from "./show-dialog-zwave_js-add-node"; import { ZWaveJSAddNodeDialogParams } from "./show-dialog-zwave_js-add-node";
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
import { customElement, property, state } from "lit/decorators";
export interface ZWaveJSAddNodeDevice { export interface ZWaveJSAddNodeDevice {
id: string; id: string;

View File

@ -1,3 +1,5 @@
import { mdiServerNetwork, mdiMathLog } from "@mdi/js";
import { customElement, property } from "lit/decorators";
import { import {
HassRouterPage, HassRouterPage,
RouterOptions, RouterOptions,
@ -6,9 +8,6 @@ import { HomeAssistant } from "../../../../../types";
import { navigate } from "../../../../../common/navigate"; import { navigate } from "../../../../../common/navigate";
import { PageNavigation } from "../../../../../layouts/hass-tabs-subpage"; import { PageNavigation } from "../../../../../layouts/hass-tabs-subpage";
import { mdiServerNetwork, mdiMathLog } from "@mdi/js";
import { customElement, property } from "lit/decorators";
export const configTabs: PageNavigation[] = [ export const configTabs: PageNavigation[] = [
{ {
translationKey: "ui.panel.config.zwave_js.navigation.network", translationKey: "ui.panel.config.zwave_js.navigation.network",

View File

@ -59,9 +59,8 @@ const getDevice = memoizeOne(
entries?.find((device) => device.id === deviceId) entries?.find((device) => device.id === deviceId)
); );
const getNodeId = memoizeOne((device: DeviceRegistryEntry): const getNodeId = memoizeOne(
| number (device: DeviceRegistryEntry): number | undefined => {
| undefined => {
const identifier = device.identifiers.find( const identifier = device.identifiers.find(
(ident) => ident[0] === "zwave_js" (ident) => ident[0] === "zwave_js"
); );
@ -70,7 +69,8 @@ const getNodeId = memoizeOne((device: DeviceRegistryEntry):
} }
return parseInt(identifier[1].split("-")[1]); return parseInt(identifier[1].split("-")[1]);
}); }
);
@customElement("zwave_js-node-config") @customElement("zwave_js-node-config")
class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {

View File

@ -285,7 +285,8 @@ export class DialogLovelaceDashboardDetail extends LitElement {
if (this._params!.dashboard) { if (this._params!.dashboard) {
await this._params!.updateDashboard(values); await this._params!.updateDashboard(values);
} else { } else {
(values as LovelaceDashboardCreateParams).url_path = this._urlPath.trim(); (values as LovelaceDashboardCreateParams).url_path =
this._urlPath.trim();
(values as LovelaceDashboardCreateParams).mode = "storage"; (values as LovelaceDashboardCreateParams).mode = "storage";
await this._params!.createDashboard( await this._params!.createDashboard(
values as LovelaceDashboardCreateParams values as LovelaceDashboardCreateParams

View File

@ -168,8 +168,9 @@ export class HaConfigLovelaceDashboards extends LitElement {
); );
private _getItems = memoize((dashboards: LovelaceDashboard[]) => { private _getItems = memoize((dashboards: LovelaceDashboard[]) => {
const defaultMode = (this.hass.panels?.lovelace const defaultMode = (
?.config as LovelacePanelConfig).mode; this.hass.panels?.lovelace?.config as LovelacePanelConfig
).mode;
const defaultUrlPath = this.hass.defaultPanel; const defaultUrlPath = this.hass.defaultPanel;
const isDefault = defaultUrlPath === "lovelace"; const isDefault = defaultUrlPath === "lovelace";
return [ return [
@ -261,9 +262,9 @@ export class HaConfigLovelaceDashboards extends LitElement {
urlPath, urlPath,
createDashboard: async (values: LovelaceDashboardCreateParams) => { createDashboard: async (values: LovelaceDashboardCreateParams) => {
const created = await createDashboard(this.hass!, values); const created = await createDashboard(this.hass!, values);
this._dashboards = this._dashboards!.concat( this._dashboards = this._dashboards!.concat(created).sort(
created (res1, res2) => compare(res1.url_path, res2.url_path)
).sort((res1, res2) => compare(res1.url_path, res2.url_path)); );
}, },
updateDashboard: async (values) => { updateDashboard: async (values) => {
const updated = await updateDashboard( const updated = await updateDashboard(

View File

@ -220,9 +220,9 @@ class HaConfigPerson extends LitElement {
users: this._allowedUsers(users, entry), users: this._allowedUsers(users, entry),
createEntry: async (values) => { createEntry: async (values) => {
const created = await createPerson(this.hass!, values); const created = await createPerson(this.hass!, values);
this._storageItems = this._storageItems!.concat( this._storageItems = this._storageItems!.concat(created).sort(
created (ent1, ent2) => compare(ent1.name, ent2.name)
).sort((ent1, ent2) => compare(ent1.name, ent2.name)); );
}, },
updateEntry: async (values) => { updateEntry: async (values) => {
const updated = await updatePerson(this.hass!, entry!.id, values); const updated = await updatePerson(this.hass!, entry!.id, values);

Some files were not shown because too many files have changed in this diff Show More