diff --git a/build-scripts/gulp/hassio.js b/build-scripts/gulp/hassio.js
index a21853d37a..696e742a05 100644
--- a/build-scripts/gulp/hassio.js
+++ b/build-scripts/gulp/hassio.js
@@ -1,9 +1,6 @@
const gulp = require("gulp");
-const fs = require("fs");
-const path = require("path");
const env = require("../env");
-const paths = require("../paths");
require("./clean.js");
require("./gen-icons-json.js");
diff --git a/build-scripts/gulp/locale-data.js b/build-scripts/gulp/locale-data.js
index 4c085f99e2..9d572ab5b9 100755
--- a/build-scripts/gulp/locale-data.js
+++ b/build-scripts/gulp/locale-data.js
@@ -4,9 +4,6 @@ const del = require("del");
const path = require("path");
const gulp = require("gulp");
const fs = require("fs");
-const merge = require("gulp-merge-json");
-const rename = require("gulp-rename");
-const transform = require("gulp-json-transform");
const paths = require("../paths");
const outDir = "build/locale-data";
diff --git a/src/common/dom/apply_themes_on_element.ts b/src/common/dom/apply_themes_on_element.ts
index 31027462c0..721863e7f3 100644
--- a/src/common/dom/apply_themes_on_element.ts
+++ b/src/common/dom/apply_themes_on_element.ts
@@ -115,7 +115,7 @@ export const applyThemesOnElement = (
}
const newTheme =
- themeRules && cacheKey
+ Object.keys(themeRules).length && cacheKey
? PROCESSED_THEMES[cacheKey] || processTheme(cacheKey, themeRules)
: undefined;
diff --git a/src/common/string/filter/filter.ts b/src/common/string/filter/filter.ts
index fc99bc10b8..e7c0103263 100644
--- a/src/common/string/filter/filter.ts
+++ b/src/common/string/filter/filter.ts
@@ -180,10 +180,10 @@ export function fuzzyScore(
wordLow
);
- let row = 1;
+ let row: number;
let column = 1;
- let patternPos = patternStart;
- let wordPos = wordStart;
+ let patternPos: number;
+ let wordPos: number;
const hasStrongFirstMatch = [false];
diff --git a/src/components/trace/hat-trace-timeline.ts b/src/components/trace/hat-trace-timeline.ts
index 5c00d83322..291f188691 100644
--- a/src/components/trace/hat-trace-timeline.ts
+++ b/src/components/trace/hat-trace-timeline.ts
@@ -511,18 +511,16 @@ export class HaAutomationTracer extends LitElement {
className: isError ? "error" : undefined,
};
}
- // null means it was stopped by a condition
- if (entry) {
- entries.push(html`
-
- ${entry.description}
-
- `);
- }
+
+ entries.push(html`
+
+ ${entry.description}
+
+ `);
return html`${entries}`;
}
diff --git a/src/dialogs/quick-bar/ha-quick-bar.ts b/src/dialogs/quick-bar/ha-quick-bar.ts
index e081870ae8..bde8b0eba6 100644
--- a/src/dialogs/quick-bar/ha-quick-bar.ts
+++ b/src/dialogs/quick-bar/ha-quick-bar.ts
@@ -123,7 +123,7 @@ export class QuickBar extends LitElement {
: this._entityItems;
if (items && this._filter && this._filter !== " ") {
- items = this._filterItems(items || [], this._filter);
+ items = this._filterItems(items, this._filter);
}
return html`
diff --git a/src/panels/config/cloud/account/cloud-remote-pref.ts b/src/panels/config/cloud/account/cloud-remote-pref.ts
index 528a8739bb..aeadcf80ed 100644
--- a/src/panels/config/cloud/account/cloud-remote-pref.ts
+++ b/src/panels/config/cloud/account/cloud-remote-pref.ts
@@ -99,16 +99,12 @@ export class CloudRemotePref extends LitElement {
)}
- ${remote_certificate
- ? html`
-
-
- ${this.hass.localize(
- "ui.panel.config.cloud.account.remote.certificate_info"
- )}
-
- `
- : ""}
+
+
+ ${this.hass.localize(
+ "ui.panel.config.cloud.account.remote.certificate_info"
+ )}
+
`;
diff --git a/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts
index abae57e651..61f4841168 100644
--- a/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts
+++ b/src/panels/config/energy/dialogs/dialog-energy-battery-settings.ts
@@ -36,7 +36,7 @@ export class DialogEnergyBatterySettings
this._params = params;
this._source = params.source
? { ...params.source }
- : (this._source = emptyBatteryEnergyPreference());
+ : emptyBatteryEnergyPreference();
}
public closeDialog(): void {
diff --git a/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts
index 2322a3c309..102c6ab5b7 100644
--- a/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts
+++ b/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts
@@ -42,7 +42,7 @@ export class DialogEnergyGasSettings
this._params = params;
this._source = params.source
? { ...params.source }
- : (this._source = emptyGasEnergyPreference());
+ : emptyGasEnergyPreference();
this._costs = this._source.entity_energy_price
? "entity"
: this._source.number_energy_price
diff --git a/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts
index e138e98fad..822470debe 100644
--- a/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts
+++ b/src/panels/config/energy/dialogs/dialog-energy-grid-flow-settings.ts
@@ -46,10 +46,9 @@ export class DialogEnergyGridFlowSettings
this._params = params;
this._source = params.source
? { ...params.source }
- : (this._source =
- params.direction === "from"
- ? emptyFlowFromGridSourceEnergyPreference()
- : emptyFlowToGridSourceEnergyPreference());
+ : params.direction === "from"
+ ? emptyFlowFromGridSourceEnergyPreference()
+ : emptyFlowToGridSourceEnergyPreference();
this._costs = this._source.entity_energy_price
? "entity"
: this._source.number_energy_price
diff --git a/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts
index 5534ed156a..d4cdd03676 100644
--- a/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts
+++ b/src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts
@@ -49,7 +49,7 @@ export class DialogEnergySolarSettings
this._fetchSolarForecastConfigEntries();
this._source = params.source
? { ...params.source }
- : (this._source = emptySolarEnergyPreference());
+ : emptySolarEnergyPreference();
this._forecast = this._source.config_entry_solar_forecast !== null;
}
diff --git a/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js b/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js
index 7d9fb20bcc..c873af398e 100644
--- a/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js
+++ b/src/panels/config/integrations/integration-panels/zwave/ha-config-zwave.js
@@ -493,7 +493,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
}
computeEntities(selectedNode) {
- if (!this.nodes || selectedNode === -1) return -1;
+ if (!this.nodes || selectedNode === -1) {
+ return -1;
+ }
const nodeid = this.nodes[this.selectedNode].attributes.node_id;
const hass = this.hass;
return Object.keys(this.hass.states)
@@ -512,7 +514,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
}
selectedNodeChanged(selectedNode) {
- if (selectedNode === -1) return;
+ if (selectedNode === -1) {
+ return;
+ }
this.selectedEntity = -1;
this.hass
@@ -573,7 +577,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
}
selectedEntityChanged(selectedEntity) {
- if (selectedEntity === -1) return;
+ if (selectedEntity === -1) {
+ return;
+ }
this.hass
.callApi(
"GET",
@@ -640,12 +646,16 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
}
computeRefreshEntityServiceData(selectedEntity) {
- if (selectedEntity === -1) return -1;
+ if (selectedEntity === -1) {
+ return -1;
+ }
return { entity_id: this.entities[selectedEntity].entity_id };
}
computePollIntensityServiceData(entityPollingIntensity) {
- if (!this.selectedNode === -1 || this.selectedEntity === -1) return -1;
+ if (this.selectedNode === -1 || this.selectedEntity === -1) {
+ return -1;
+ }
return {
node_id: this.nodes[this.selectedNode].attributes.node_id,
value_id: this.entities[this.selectedEntity].attributes.value_id,
diff --git a/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js b/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js
index 94037f1e03..129587fcfb 100644
--- a/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js
+++ b/src/panels/config/integrations/integration-panels/zwave/zwave-groups.js
@@ -300,12 +300,13 @@ class ZwaveGroups extends LocalizeMixin(PolymerElement) {
_computeAssocServiceData(selectedGroup, type) {
if (
- !this.groups === -1 ||
+ !this.groups ||
selectedGroup === -1 ||
this.selectedNode === -1 ||
this._selectedTargetNode === -1
- )
+ ) {
return -1;
+ }
return {
node_id: this.nodes[this.selectedNode].attributes.node_id,
association: type,
diff --git a/src/panels/config/logs/dialog-system-log-detail.ts b/src/panels/config/logs/dialog-system-log-detail.ts
index cf3ace57d7..074a87eafb 100644
--- a/src/panels/config/logs/dialog-system-log-detail.ts
+++ b/src/panels/config/logs/dialog-system-log-detail.ts
@@ -65,7 +65,7 @@ class DialogSystemLogDetail extends LitElement {
this._manifest &&
(this._manifest.is_built_in ||
// Custom components with our offical docs should not link to our docs
- !this._manifest.documentation.includes("www.home-assistant.io"));
+ !this._manifest.documentation.includes("://www.home-assistant.io"));
return html`
diff --git a/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts
index db0a4a86df..5d24f900d5 100644
--- a/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts
+++ b/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts
@@ -164,21 +164,6 @@ export class HuiEnergyDevicesGraphCard
)
);
- const statisticsData = Object.values(this._data!);
- let endTime: Date;
-
- endTime = new Date(
- Math.max(
- ...statisticsData.map((stats) =>
- stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0
- )
- )
- );
-
- if (!endTime || endTime > new Date()) {
- endTime = new Date();
- }
-
const data: Array>["data"]> = [];
const borderColor: string[] = [];
const backgroundColor: string[] = [];
diff --git a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts
index f46af3d81d..582107472e 100644
--- a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts
+++ b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts
@@ -220,21 +220,7 @@ export class HuiEnergyGasGraphCard
this._unit = getEnergyGasUnit(this.hass, energyData.prefs) || "m³";
- const statisticsData = Object.values(energyData.stats);
const datasets: ChartDataset<"bar">[] = [];
- let endTime: Date;
-
- endTime = new Date(
- Math.max(
- ...statisticsData.map((stats) =>
- stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0
- )
- )
- );
-
- if (!endTime || endTime > new Date()) {
- endTime = new Date();
- }
const computedStyles = getComputedStyle(this);
const gasColor = computedStyles
diff --git a/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts
index fb89e115a1..54b272cfd4 100644
--- a/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts
+++ b/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts
@@ -226,21 +226,7 @@ export class HuiEnergySolarGraphCard
}
}
- const statisticsData = Object.values(energyData.stats);
const datasets: ChartDataset<"bar">[] = [];
- let endTime: Date;
-
- endTime = new Date(
- Math.max(
- ...statisticsData.map((stats) =>
- stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0
- )
- )
- );
-
- if (!endTime || endTime > new Date()) {
- endTime = new Date();
- }
const computedStyles = getComputedStyle(this);
const solarColor = computedStyles
diff --git a/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts
index 5b08a6b08a..db2b8a0db6 100644
--- a/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts
+++ b/src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts
@@ -88,7 +88,7 @@ export class HuiEnergyUsageGraphCard
)}
chart-type="bar"
>
- ${!this._chartData.datasets.length
+ ${!this._chartData.datasets.some((dataset) => dataset.data.length)
? html`
${isToday(this._start)
? "There is no data to show. It can take up to 2 hours for new data to arrive after you configure your energy dashboard."
@@ -228,6 +228,8 @@ export class HuiEnergyUsageGraphCard
);
private async _getStatistics(energyData: EnergyData): Promise {
+ const datasets: ChartDataset<"bar">[] = [];
+
const statistics: {
to_grid?: string[];
from_grid?: string[];
@@ -283,33 +285,9 @@ export class HuiEnergyUsageGraphCard
energyData.start
);
- const statisticsData = Object.values(energyData.stats);
-
- const datasets: ChartDataset<"bar">[] = [];
- let endTime: Date;
-
this._start = energyData.start;
this._end = energyData.end || endOfToday();
- if (statisticsData.length === 0) {
- this._chartData = {
- datasets,
- };
- return;
- }
-
- endTime = new Date(
- Math.max(
- ...statisticsData.map((stats) =>
- stats.length ? new Date(stats[stats.length - 1].start).getTime() : 0
- )
- )
- );
-
- if (endTime > new Date()) {
- endTime = new Date();
- }
-
const combinedData: {
to_grid?: { [statId: string]: { [start: string]: number } };
to_battery?: { [statId: string]: { [start: string]: number } };
diff --git a/src/panels/lovelace/components/hui-timestamp-display.ts b/src/panels/lovelace/components/hui-timestamp-display.ts
index 0cd5d44de9..211ff97268 100644
--- a/src/panels/lovelace/components/hui-timestamp-display.ts
+++ b/src/panels/lovelace/components/hui-timestamp-display.ts
@@ -104,12 +104,7 @@ class HuiTimestampDisplay extends LitElement {
this._relative =
this._format === "relative"
? relativeTime(this.ts, this.hass!.locale)
- : (this._relative = relativeTime(
- new Date(),
- this.hass!.locale,
- this.ts,
- false
- ));
+ : relativeTime(new Date(), this.hass!.locale, this.ts, false);
}
}
}
diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts
index aa1c3aa8fd..07addd5bb5 100644
--- a/src/panels/my/ha-panel-my.ts
+++ b/src/panels/my/ha-panel-my.ts
@@ -218,7 +218,7 @@ class HaPanelMy extends LitElement {
protected render() {
if (this._error) {
- let error = "Unknown error";
+ let error: string;
switch (this._error) {
case "not_supported":
error =