diff --git a/.eslintrc.json b/.eslintrc.json index 73d6cea999..b1db8a1786 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,8 +4,7 @@ "plugin:@typescript-eslint/recommended", "plugin:wc/recommended", "plugin:lit/recommended", - "prettier", - "prettier/@typescript-eslint" + "prettier" ], "parser": "@typescript-eslint/parser", "parserOptions": { @@ -85,6 +84,25 @@ "@typescript-eslint/explicit-function-return-type": 0, "@typescript-eslint/explicit-module-boundary-types": 0, "@typescript-eslint/no-shadow": ["error"], + "@typescript-eslint/naming-convention": [ + 0, + { + "selector": "default", + "format": ["camelCase", "snake_case"], + "leadingUnderscore": "allow", + "trailingUnderscore": "allow" + }, + { + "selector": ["variable"], + "format": ["camelCase", "snake_case", "UPPER_CASE"], + "leadingUnderscore": "allow", + "trailingUnderscore": "allow" + }, + { + "selector": "typeLike", + "format": ["PascalCase"] + } + ], "lit/attribute-value-entities": 0 }, "plugins": ["disable", "import", "lit", "prettier", "@typescript-eslint"], diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6663a4988e..05c8af47e4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,9 +37,11 @@ jobs: - name: Build resources run: ./node_modules/.bin/gulp gen-icons-json build-translations gather-gallery-demos - name: Run eslint - run: ./node_modules/.bin/eslint '{**/src,src}/**/*.{js,ts,html}' --ignore-path .gitignore + run: yarn run lint:eslint - name: Run tsc - run: ./node_modules/.bin/tsc + run: yarn run lint:types + - name: Run prettier + run: yarn run lint:prettier test: runs-on: ubuntu-latest steps: diff --git a/cast/src/launcher/layout/hc-cast.ts b/cast/src/launcher/layout/hc-cast.ts index 7bcbe70d59..c91e38f2af 100644 --- a/cast/src/launcher/layout/hc-cast.ts +++ b/cast/src/launcher/layout/hc-cast.ts @@ -54,9 +54,7 @@ class HcCast extends LitElement { const error = this.castManager.castState === "NO_DEVICES_AVAILABLE" ? html` -

- There were no suitable Chromecast devices to cast to found. -

+

There were no suitable Chromecast devices to cast to found.

` : undefined; diff --git a/cast/src/launcher/layout/hc-connect.ts b/cast/src/launcher/layout/hc-connect.ts index 8f3e1272ee..518c582f2c 100644 --- a/cast/src/launcher/layout/hc-connect.ts +++ b/cast/src/launcher/layout/hc-connect.ts @@ -86,9 +86,7 @@ export class HcConnect extends LitElement {
- - Retry - + Retry
Log out diff --git a/demo/src/stubs/translations.ts b/demo/src/stubs/translations.ts index 62ee9ac1bd..7eced853f0 100644 --- a/demo/src/stubs/translations.ts +++ b/demo/src/stubs/translations.ts @@ -3,8 +3,6 @@ import { MockHomeAssistant } from "../../../src/fake_data/provide_hass"; export const mockTranslations = (hass: MockHomeAssistant) => { hass.mockWS( "frontend/get_translations", - (/* msg: {language: string, category: string} */) => { - return { resources: {} }; - } + (/* msg: {language: string, category: string} */) => ({ resources: {} }) ); }; diff --git a/gallery/src/demos/demo-hui-alarm-panel-card.ts b/gallery/src/demos/demo-hui-alarm-panel-card.ts index 4c66b22559..0042b31874 100644 --- a/gallery/src/demos/demo-hui-alarm-panel-card.ts +++ b/gallery/src/demos/demo-hui-alarm-panel-card.ts @@ -93,4 +93,8 @@ class DemoAlarmPanelEntity extends LitElement { } } -customElements.define("demo-hui-alarm-panel-card", DemoAlarmPanelEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-alarm-panel-card": DemoAlarmPanelEntity; + } +} diff --git a/gallery/src/demos/demo-hui-conditional-card.ts b/gallery/src/demos/demo-hui-conditional-card.ts index cf70db64aa..9d91c76f88 100644 --- a/gallery/src/demos/demo-hui-conditional-card.ts +++ b/gallery/src/demos/demo-hui-conditional-card.ts @@ -75,4 +75,8 @@ class DemoConditional extends LitElement { } } -customElements.define("demo-hui-conditional-card", DemoConditional); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-conditional-card": DemoConditional; + } +} diff --git a/gallery/src/demos/demo-hui-entities-card.ts b/gallery/src/demos/demo-hui-entities-card.ts index 7511e061b5..8f030ec6cb 100644 --- a/gallery/src/demos/demo-hui-entities-card.ts +++ b/gallery/src/demos/demo-hui-entities-card.ts @@ -239,4 +239,8 @@ class DemoEntities extends LitElement { } } -customElements.define("demo-hui-entities-card", DemoEntities); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-entities-card": DemoEntities; + } +} diff --git a/gallery/src/demos/demo-hui-entity-button-card.ts b/gallery/src/demos/demo-hui-entity-button-card.ts index 1e3201fa10..56d7018e36 100644 --- a/gallery/src/demos/demo-hui-entity-button-card.ts +++ b/gallery/src/demos/demo-hui-entity-button-card.ts @@ -91,4 +91,8 @@ class DemoButtonEntity extends LitElement { } } -customElements.define("demo-hui-entity-button-card", DemoButtonEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-entity-button-card": DemoButtonEntity; + } +} diff --git a/gallery/src/demos/demo-hui-entity-filter-card.ts b/gallery/src/demos/demo-hui-entity-filter-card.ts index c3e22f0e46..309e43f7dd 100644 --- a/gallery/src/demos/demo-hui-entity-filter-card.ts +++ b/gallery/src/demos/demo-hui-entity-filter-card.ts @@ -132,4 +132,8 @@ class DemoEntityFilter extends LitElement { } } -customElements.define("demo-hui-entity-filter-card", DemoEntityFilter); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-entity-filter-card": DemoEntityFilter; + } +} diff --git a/gallery/src/demos/demo-hui-gauge-card.ts b/gallery/src/demos/demo-hui-gauge-card.ts index 35e794f317..659955354b 100644 --- a/gallery/src/demos/demo-hui-gauge-card.ts +++ b/gallery/src/demos/demo-hui-gauge-card.ts @@ -129,4 +129,8 @@ class DemoGaugeEntity extends LitElement { } } -customElements.define("demo-hui-gauge-card", DemoGaugeEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-gauge-card": DemoGaugeEntity; + } +} diff --git a/gallery/src/demos/demo-hui-glance-card.ts b/gallery/src/demos/demo-hui-glance-card.ts index 2d3d83193e..9f407307eb 100644 --- a/gallery/src/demos/demo-hui-glance-card.ts +++ b/gallery/src/demos/demo-hui-glance-card.ts @@ -186,7 +186,7 @@ const CONFIGS = [ name: - light.kitchen_lights - entity: lock.kitchen_door - name: + name: - light.ceiling_lights `, }, @@ -194,7 +194,7 @@ const CONFIGS = [ heading: "Custom tap action", config: ` - type: glance - columns: 4 + columns: 4 entities: - entity: lock.kitchen_door name: Custom @@ -232,4 +232,8 @@ class DemoGlanceEntity extends LitElement { } } -customElements.define("demo-hui-glance-card", DemoGlanceEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-glance-card": DemoGlanceEntity; + } +} diff --git a/gallery/src/demos/demo-hui-grid-and-stack-card.ts b/gallery/src/demos/demo-hui-grid-and-stack-card.ts index 8beb16a20d..4891d6626e 100644 --- a/gallery/src/demos/demo-hui-grid-and-stack-card.ts +++ b/gallery/src/demos/demo-hui-grid-and-stack-card.ts @@ -108,6 +108,7 @@ const CONFIGS = [ heading: "Columns 4", config: ` - type: grid + columns: 4 cards: - type: entity entity: light.kitchen_lights @@ -142,6 +143,15 @@ const CONFIGS = [ entity: light.kitchen_lights `, }, + { + heading: "Size for single card", + config: ` +- type: grid + cards: + - type: entity + entity: light.kitchen_lights + `, + }, { heading: "Vertical Stack", diff --git a/gallery/src/demos/demo-hui-iframe-card.ts b/gallery/src/demos/demo-hui-iframe-card.ts index a2d493476b..f4497e9428 100644 --- a/gallery/src/demos/demo-hui-iframe-card.ts +++ b/gallery/src/demos/demo-hui-iframe-card.ts @@ -42,4 +42,8 @@ class DemoIframe extends LitElement { } } -customElements.define("demo-hui-iframe-card", DemoIframe); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-iframe-card": DemoIframe; + } +} diff --git a/gallery/src/demos/demo-hui-light-card.ts b/gallery/src/demos/demo-hui-light-card.ts index 71d12b4af8..26c419f9e5 100644 --- a/gallery/src/demos/demo-hui-light-card.ts +++ b/gallery/src/demos/demo-hui-light-card.ts @@ -85,4 +85,8 @@ class DemoLightEntity extends LitElement { } } -customElements.define("demo-hui-light-card", DemoLightEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-light-card": DemoLightEntity; + } +} diff --git a/gallery/src/demos/demo-hui-map-card.ts b/gallery/src/demos/demo-hui-map-card.ts index 2cc55f499d..ccb47deabb 100644 --- a/gallery/src/demos/demo-hui-map-card.ts +++ b/gallery/src/demos/demo-hui-map-card.ts @@ -183,4 +183,8 @@ class DemoMap extends LitElement { } } -customElements.define("demo-hui-map-card", DemoMap); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-map-card": DemoMap; + } +} diff --git a/gallery/src/demos/demo-hui-markdown-card.ts b/gallery/src/demos/demo-hui-markdown-card.ts index 8321eff7d3..94f63f404d 100644 --- a/gallery/src/demos/demo-hui-markdown-card.ts +++ b/gallery/src/demos/demo-hui-markdown-card.ts @@ -276,4 +276,8 @@ class DemoMarkdown extends LitElement { } } -customElements.define("demo-hui-markdown-card", DemoMarkdown); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-markdown-card": DemoMarkdown; + } +} diff --git a/gallery/src/demos/demo-hui-media-control-card.ts b/gallery/src/demos/demo-hui-media-control-card.ts index 55bbc0168c..3b032c409e 100644 --- a/gallery/src/demos/demo-hui-media-control-card.ts +++ b/gallery/src/demos/demo-hui-media-control-card.ts @@ -180,4 +180,8 @@ class DemoHuiMediaControlCard extends LitElement { } } -customElements.define("demo-hui-media-control-card", DemoHuiMediaControlCard); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-media-control-card": DemoHuiMediaControlCard; + } +} diff --git a/gallery/src/demos/demo-hui-media-player-rows.ts b/gallery/src/demos/demo-hui-media-player-rows.ts index 9ffabfee9b..500bfca693 100644 --- a/gallery/src/demos/demo-hui-media-player-rows.ts +++ b/gallery/src/demos/demo-hui-media-player-rows.ts @@ -77,4 +77,8 @@ class DemoHuiMediaPlayerRow extends LitElement { } } -customElements.define("demo-hui-media-player-row", DemoHuiMediaPlayerRow); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-media-player-row": DemoHuiMediaPlayerRow; + } +} diff --git a/gallery/src/demos/demo-hui-picture-elements-card.ts b/gallery/src/demos/demo-hui-picture-elements-card.ts index 6e6ffd86a0..5ab818911c 100644 --- a/gallery/src/demos/demo-hui-picture-elements-card.ts +++ b/gallery/src/demos/demo-hui-picture-elements-card.ts @@ -147,4 +147,8 @@ class DemoPictureElements extends LitElement { } } -customElements.define("demo-hui-picture-elements-card", DemoPictureElements); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-picture-elements-card": DemoPictureElements; + } +} diff --git a/gallery/src/demos/demo-hui-picture-entity-card.ts b/gallery/src/demos/demo-hui-picture-entity-card.ts index fd0c5fea94..3a1b64f76e 100644 --- a/gallery/src/demos/demo-hui-picture-entity-card.ts +++ b/gallery/src/demos/demo-hui-picture-entity-card.ts @@ -102,4 +102,8 @@ class DemoPictureEntity extends LitElement { } } -customElements.define("demo-hui-picture-entity-card", DemoPictureEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-picture-entity-card": DemoPictureEntity; + } +} diff --git a/gallery/src/demos/demo-hui-picture-glance-card.ts b/gallery/src/demos/demo-hui-picture-glance-card.ts index 9ecafb7f5a..f6790efc3d 100644 --- a/gallery/src/demos/demo-hui-picture-glance-card.ts +++ b/gallery/src/demos/demo-hui-picture-glance-card.ts @@ -143,4 +143,8 @@ class DemoPictureGlance extends LitElement { } } -customElements.define("demo-hui-picture-glance-card", DemoPictureGlance); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-picture-glance-card": DemoPictureGlance; + } +} diff --git a/gallery/src/demos/demo-hui-plant-card.ts b/gallery/src/demos/demo-hui-plant-card.ts index a1d49afe5b..9e8aff318e 100644 --- a/gallery/src/demos/demo-hui-plant-card.ts +++ b/gallery/src/demos/demo-hui-plant-card.ts @@ -52,4 +52,8 @@ export class DemoPlantEntity extends LitElement { } } -customElements.define("demo-hui-plant-card", DemoPlantEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-plant-card": DemoPlantEntity; + } +} diff --git a/gallery/src/demos/demo-hui-shopping-list-card.ts b/gallery/src/demos/demo-hui-shopping-list-card.ts index a17bd61f12..61f9aa9062 100644 --- a/gallery/src/demos/demo-hui-shopping-list-card.ts +++ b/gallery/src/demos/demo-hui-shopping-list-card.ts @@ -48,4 +48,8 @@ class DemoShoppingListEntity extends LitElement { } } -customElements.define("demo-hui-shopping-list-card", DemoShoppingListEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-shopping-list-card": DemoShoppingListEntity; + } +} diff --git a/gallery/src/demos/demo-hui-thermostat-card.ts b/gallery/src/demos/demo-hui-thermostat-card.ts index 30e08d3e29..e6cdaae788 100644 --- a/gallery/src/demos/demo-hui-thermostat-card.ts +++ b/gallery/src/demos/demo-hui-thermostat-card.ts @@ -96,4 +96,8 @@ class DemoThermostatEntity extends LitElement { } } -customElements.define("demo-hui-thermostat-card", DemoThermostatEntity); +declare global { + interface HTMLElementTagNameMap { + "demo-hui-thermostat-card": DemoThermostatEntity; + } +} diff --git a/gallery/src/demos/demo-integration-card.ts b/gallery/src/demos/demo-integration-card.ts index 03a44a1853..2c9039b7b3 100644 --- a/gallery/src/demos/demo-integration-card.ts +++ b/gallery/src/demos/demo-integration-card.ts @@ -61,6 +61,9 @@ const nameAsDomainEntry = createConfigEntry("ESPHome"); const longNameEntry = createConfigEntry( "Entry with a super long name that is going to the next line" ); +const longNonBreakingNameEntry = createConfigEntry( + "EntryWithASuperLongNameThatDoesNotBreak" +); const configPanelEntry = createConfigEntry("Config Panel", { domain: "mqtt", localized_domain_name: "MQTT", @@ -141,6 +144,7 @@ const configEntries: Array<{ { items: [optionsFlowEntry] }, { items: [nameAsDomainEntry] }, { items: [longNameEntry] }, + { items: [longNonBreakingNameEntry] }, { items: [setupErrorEntry] }, { items: [migrationErrorEntry] }, { items: [setupRetryEntry] }, @@ -154,6 +158,7 @@ const configEntries: Array<{ setupErrorEntry, migrationErrorEntry, longNameEntry, + longNonBreakingNameEntry, setupRetryEntry, failedUnloadEntry, notLoadedEntry, diff --git a/hassio/src/addon-store/hassio-addon-repository.ts b/hassio/src/addon-store/hassio-addon-repository.ts index 746ee5cd8d..4e33f15e8b 100644 --- a/hassio/src/addon-store/hassio-addon-repository.ts +++ b/hassio/src/addon-store/hassio-addon-repository.ts @@ -47,9 +47,7 @@ class HassioAddonRepositoryEl extends LitElement { const repo = this.repo; let _addons = this.addons; if (!this.hass.userData?.showAdvanced) { - _addons = _addons.filter((addon) => { - return !addon.advanced; - }); + _addons = _addons.filter((addon) => !addon.advanced); } const addons = this._getAddons(_addons, this.filter); @@ -68,9 +66,7 @@ class HassioAddonRepositoryEl extends LitElement { } return html`
-

- ${repo.name} -

+

${repo.name}

${addons.map( (addon) => html` diff --git a/hassio/src/addon-store/hassio-addon-store.ts b/hassio/src/addon-store/hassio-addon-store.ts index 5ca3d77d73..fd41a504db 100644 --- a/hassio/src/addon-store/hassio-addon-store.ts +++ b/hassio/src/addon-store/hassio-addon-store.ts @@ -86,9 +86,7 @@ class HassioAddonStore extends LitElement { main-page supervisor > - - ${this.supervisor.localize("panel.store")} - + ${this.supervisor.localize("panel.store")} { - return repositories.sort(sortRepos).map((repo) => { + ) => + repositories.sort(sortRepos).map((repo) => { const filteredAddons = addons.filter( (addon) => addon.repository === repo.slug ); @@ -171,8 +169,7 @@ class HassioAddonStore extends LitElement { > ` : html``; - }); - } + }) ); private _handleAction(ev: CustomEvent) { diff --git a/hassio/src/addon-view/config/hassio-addon-audio.ts b/hassio/src/addon-view/config/hassio-addon-audio.ts index de682a9520..79275a39cf 100644 --- a/hassio/src/addon-view/config/hassio-addon-audio.ts +++ b/hassio/src/addon-view/config/hassio-addon-audio.ts @@ -69,13 +69,13 @@ class HassioAddonAudio extends LitElement { .selected=${this._selectedInput!} > ${this._inputDevices && - this._inputDevices.map((item) => { - return html` + this._inputDevices.map( + (item) => html` ${item.name} - `; - })} + ` + )} ${this._outputDevices && - this._outputDevices.map((item) => { - return html` + this._outputDevices.map( + (item) => html` ${item.name} - `; - })} + ` + )}
diff --git a/hassio/src/addon-view/config/hassio-addon-config.ts b/hassio/src/addon-view/config/hassio-addon-config.ts index 706dd12789..56ebbfa5f5 100644 --- a/hassio/src/addon-view/config/hassio-addon-config.ts +++ b/hassio/src/addon-view/config/hassio-addon-config.ts @@ -65,19 +65,15 @@ class HassioAddonConfig extends LitElement { @query("ha-yaml-editor") private _editor?: HaYamlEditor; - public computeLabel = (entry: HaFormSchema): string => { - return ( - this.addon.translations[this.hass.language]?.configuration?.[entry.name] - ?.name || - this.addon.translations.en?.configuration?.[entry.name].name || - entry.name - ); - }; + public computeLabel = (entry: HaFormSchema): string => + this.addon.translations[this.hass.language]?.configuration?.[entry.name] + ?.name || + this.addon.translations.en?.configuration?.[entry.name].name || + entry.name; private _filteredShchema = memoizeOne( - (options: Record, schema: HaFormSchema[]) => { - return schema.filter((entry) => entry.name in options || entry.required); - } + (options: Record, schema: HaFormSchema[]) => + schema.filter((entry) => entry.name in options || entry.required) ); protected render(): TemplateResult { diff --git a/hassio/src/addon-view/config/hassio-addon-network.ts b/hassio/src/addon-view/config/hassio-addon-network.ts index 57eeacd187..256f81175f 100644 --- a/hassio/src/addon-view/config/hassio-addon-network.ts +++ b/hassio/src/addon-view/config/hassio-addon-network.ts @@ -79,12 +79,10 @@ class HassioAddonNetwork extends LitElement { "addon.configuration.network.host" )} - - ${this.supervisor.localize("common.description")} - + ${this.supervisor.localize("common.description")} - ${this._config!.map((item) => { - return html` + ${this._config!.map( + (item) => html` ${item.container} @@ -100,8 +98,8 @@ class HassioAddonNetwork extends LitElement { ${this._computeDescription(item)} - `; - })} + ` + )}
@@ -124,25 +122,20 @@ class HassioAddonNetwork extends LitElement { } } - private _computeDescription = (item: NetworkItem): string => { - return ( - this.addon.translations[this.hass.language]?.network?.[item.container] - ?.description || - this.addon.translations.en?.network?.[item.container]?.description || - item.description - ); - }; + private _computeDescription = (item: NetworkItem): string => + this.addon.translations[this.hass.language]?.network?.[item.container] + ?.description || + this.addon.translations.en?.network?.[item.container]?.description || + item.description; private _setNetworkConfig(): void { const network = this.addon.network || {}; const description = this.addon.network_description || {}; - const items: NetworkItem[] = Object.keys(network).map((key) => { - return { - container: key, - host: network[key], - description: description[key], - }; - }); + const items: NetworkItem[] = Object.keys(network).map((key) => ({ + container: key, + host: network[key], + description: description[key], + })); this._config = items.sort((a, b) => (a.container > b.container ? 1 : -1)); } diff --git a/hassio/src/addon-view/info/hassio-addon-info.ts b/hassio/src/addon-view/info/hassio-addon-info.ts index b0f10392fa..03d2c1bf65 100644 --- a/hassio/src/addon-view/info/hassio-addon-info.ts +++ b/hassio/src/addon-view/info/hassio-addon-info.ts @@ -566,9 +566,7 @@ class HassioAddonInfo extends LitElement { ${this.supervisor.localize("addon.dashboard.hostname")} - - ${this.addon.hostname} - + ${this.addon.hostname} ${metrics.map( (metric) => @@ -997,7 +995,7 @@ class HassioAddonInfo extends LitElement { addons: [this.addon.slug], homeassistant: false, }, - updateHandler: async () => await this._updateAddon(), + updateHandler: async () => this._updateAddon(), }); } diff --git a/hassio/src/components/hassio-card-content.ts b/hassio/src/components/hassio-card-content.ts index 02d3fc7e1b..03884e6b94 100644 --- a/hassio/src/components/hassio-card-content.ts +++ b/hassio/src/components/hassio-card-content.ts @@ -56,13 +56,13 @@ class HassioCardContent extends LitElement { > `}
-
- ${this.title} -
+
${this.title}
${this.description} - ${/* treat as available when undefined */ - this.available === false ? " (Not available)" : ""} + ${ + /* treat as available when undefined */ + this.available === false ? " (Not available)" : "" + } ${this.datetime ? html` - - ${this.description} - + ${this.description}
- - ${roundedValue} % - + ${roundedValue} % 50, diff --git a/hassio/src/dashboard/hassio-update.ts b/hassio/src/dashboard/hassio-update.ts index ccff99445b..1a11ee99e4 100644 --- a/hassio/src/dashboard/hassio-update.ts +++ b/hassio/src/dashboard/hassio-update.ts @@ -40,9 +40,8 @@ import { HomeAssistant } from "../../../src/types"; import { showDialogSupervisorUpdate } from "../dialogs/update/show-dialog-update"; import { hassioStyle } from "../resources/hassio-style"; -const computeVersion = (key: string, version: string): string => { - return key === "os" ? version : `${key}-${version}`; -}; +const computeVersion = (key: string, version: string): string => + key === "os" ? version : `${key}-${version}`; @customElement("hassio-update") export class HassioUpdate extends LitElement { @@ -50,11 +49,12 @@ export class HassioUpdate extends LitElement { @property({ attribute: false }) public supervisor!: Supervisor; - private _pendingUpdates = memoizeOne((supervisor: Supervisor): number => { - return Object.keys(supervisor).filter( - (value) => supervisor[value].update_available - ).length; - }); + private _pendingUpdates = memoizeOne( + (supervisor: Supervisor): number => + Object.keys(supervisor).filter( + (value) => supervisor[value].update_available + ).length + ); protected render(): TemplateResult { if (!this.supervisor) { diff --git a/hassio/src/dialogs/network/dialog-hassio-network.ts b/hassio/src/dialogs/network/dialog-hassio-network.ts index 8e6f9610e4..04f2710465 100644 --- a/hassio/src/dialogs/network/dialog-hassio-network.ts +++ b/hassio/src/dialogs/network/dialog-hassio-network.ts @@ -47,7 +47,8 @@ import { HassioNetworkDialogParams } from "./show-dialog-network"; const IP_VERSIONS = ["ipv4", "ipv6"]; @customElement("dialog-hassio-network") -export class DialogHassioNetwork extends LitElement +export class DialogHassioNetwork + extends LitElement implements HassDialog { @property({ attribute: false }) public hass!: HomeAssistant; @@ -76,9 +77,9 @@ export class DialogHassioNetwork extends LitElement this._dirty = false; this._curTabIndex = 0; this.supervisor = params.supervisor; - this._interfaces = params.supervisor.network.interfaces.sort((a, b) => { - return a.primary > b.primary ? -1 : 1; - }); + this._interfaces = params.supervisor.network.interfaces.sort((a, b) => + a.primary > b.primary ? -1 : 1 + ); this._interface = { ...this._interfaces[this._curTabIndex] }; await this.updateComplete; diff --git a/hassio/src/dialogs/registries/dialog-hassio-registries.ts b/hassio/src/dialogs/registries/dialog-hassio-registries.ts index 292fab3f43..4b77b41436 100644 --- a/hassio/src/dialogs/registries/dialog-hassio-registries.ts +++ b/hassio/src/dialogs/registries/dialog-hassio-registries.ts @@ -108,8 +108,8 @@ class HassioRegistriesDialog extends LitElement { ` : html`${this._registries?.length - ? this._registries.map((entry) => { - return html` + ? this._registries.map( + (entry) => html` ${entry.registry} - `; - }) + ` + ) : html` ${this._error}
` : ""}
${repositories.length - ? repositories.map((repo) => { - return html` + ? repositories.map( + (repo) => html`
${repo.name}
@@ -105,13 +105,9 @@ class HassioRepositoriesDialog extends LitElement {
- `; - }) - : html` - - No repositories - - `} + ` + ) + : html` No repositories `}
{ - return repo.source; - }); + const newRepositories = repositories.map((repo) => repo.source); newRepositories.push(input.value); try { @@ -228,19 +222,13 @@ class HassioRepositoriesDialog extends LitElement { private async _removeRepository(ev: Event) { const slug = (ev.currentTarget as any).slug; const repositories = this._filteredRepositories(this._repositories!); - const repository = repositories.find((repo) => { - return repo.slug === slug; - }); + const repository = repositories.find((repo) => repo.slug === slug); if (!repository) { return; } const newRepositories = repositories - .map((repo) => { - return repo.source; - }) - .filter((repo) => { - return repo !== repository.source; - }); + .map((repo) => repo.source) + .filter((repo) => repo !== repository.source); try { await setSupervisorOption(this.hass, { diff --git a/hassio/src/dialogs/snapshot/dialog-hassio-snapshot-upload.ts b/hassio/src/dialogs/snapshot/dialog-hassio-snapshot-upload.ts index 1f657bf0d8..d4948bd553 100644 --- a/hassio/src/dialogs/snapshot/dialog-hassio-snapshot-upload.ts +++ b/hassio/src/dialogs/snapshot/dialog-hassio-snapshot-upload.ts @@ -18,7 +18,8 @@ import "../../components/hassio-upload-snapshot"; import { HassioSnapshotUploadDialogParams } from "./show-dialog-snapshot-upload"; @customElement("dialog-hassio-snapshot-upload") -export class DialogHassioSnapshotUpload extends LitElement +export class DialogHassioSnapshotUpload + extends LitElement implements HassDialog { @property({ attribute: false }) public hass!: HomeAssistant; @@ -57,9 +58,7 @@ export class DialogHassioSnapshotUpload extends LitElement >
- - Upload snapshot - + Upload snapshot diff --git a/hassio/src/dialogs/snapshot/dialog-hassio-snapshot.ts b/hassio/src/dialogs/snapshot/dialog-hassio-snapshot.ts index 34042058d3..b44c9eb6c3 100755 --- a/hassio/src/dialogs/snapshot/dialog-hassio-snapshot.ts +++ b/hassio/src/dialogs/snapshot/dialog-hassio-snapshot.ts @@ -53,14 +53,13 @@ const _computeFolders = (folders) => { return list; }; -const _computeAddons = (addons) => { - return addons.map((addon) => ({ +const _computeAddons = (addons) => + addons.map((addon) => ({ slug: addon.slug, name: addon.name, version: addon.version, checked: true, })); -}; interface AddonItem { slug: string; @@ -122,9 +121,7 @@ class HassioSnapshotDialog extends LitElement {
- - ${this._computeName} - + ${this._computeName} @@ -152,8 +149,8 @@ class HassioSnapshotDialog extends LitElement { ? html`
Folders:
- ${this._folders.map((item) => { - return html` + ${this._folders.map( + (item) => html` Add-on:
- ${this._addons.map((item) => { - return html` + ${this._addons.map( + (item) => html`
-

- ${this.supervisor.localize("snapshot.create_snapshot")} -

+

${this.supervisor.localize("snapshot.create_snapshot")}

${this.supervisor.localize("snapshot.description")}

diff --git a/hassio/src/system/hassio-core-info.ts b/hassio/src/system/hassio-core-info.ts index bb00dcd05c..bdb156fe20 100644 --- a/hassio/src/system/hassio-core-info.ts +++ b/hassio/src/system/hassio-core-info.ts @@ -178,7 +178,7 @@ class HassioCoreInfo extends LitElement { folders: ["homeassistant"], homeassistant: true, }, - updateHandler: async () => await this._updateCore(), + updateHandler: async () => this._updateCore(), }); } diff --git a/hassio/src/system/hassio-host-info.ts b/hassio/src/system/hassio-host-info.ts index 09e363c1c1..db5e4e2f7e 100644 --- a/hassio/src/system/hassio-host-info.ts +++ b/hassio/src/system/hassio-host-info.ts @@ -97,9 +97,7 @@ class HassioHostInfo extends LitElement { ${this.supervisor.localize("system.host.ip_address")} - - ${primaryIpAddress} - + ${primaryIpAddress} - - ${this.supervisor.localize("system.supervisor.beta_backup")} - + ${this.supervisor.localize("system.supervisor.beta_backup")}

${this.supervisor.localize("system.supervisor.beta_release_items")}