Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add type import check to eslint #22488

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
"lit-a11y/no-autofocus": "off",
"lit-a11y/alt-text": "warn",
"lit-a11y/anchor-is-valid": "warn",
"lit-a11y/role-has-required-aria-attrs": "warn"
"lit-a11y/role-has-required-aria-attrs": "warn",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-import-type-side-effects": "error"
},
"plugins": ["unused-imports"]
}
9 changes: 5 additions & 4 deletions cast/src/launcher/layout/hc-cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import "@material/mwc-button/mwc-button";
import "@material/mwc-list/mwc-list";
import type { ActionDetail } from "@material/mwc-list/mwc-list";
import { mdiCast, mdiCastConnected, mdiViewDashboard } from "@mdi/js";
import { Auth, Connection } from "home-assistant-js-websocket";
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
import type { Auth, Connection } from "home-assistant-js-websocket";
import type { CSSResultGroup, TemplateResult } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { CastManager } from "../../../../src/cast/cast_manager";
import type { CastManager } from "../../../../src/cast/cast_manager";
import {
castSendShowLovelaceView,
ensureConnectedCastSession,
Expand All @@ -24,7 +25,7 @@ import {
getLovelaceCollection,
} from "../../../../src/data/lovelace";
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
import { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
import type { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
import "../../../../src/layouts/hass-loading-screen";
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
import "./hc-layout";
Expand Down
12 changes: 8 additions & 4 deletions cast/src/launcher/layout/hc-connect.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import "@material/mwc-button";
import { mdiCastConnected, mdiCast } from "@mdi/js";
import {
import type {
Auth,
Connection,
getAuthOptions,
} from "home-assistant-js-websocket";
import {
createConnection,
ERR_CANNOT_CONNECT,
ERR_HASS_HOST_REQUIRED,
ERR_INVALID_AUTH,
ERR_INVALID_HTTPS_TO_HTTP,
getAuth,
getAuthOptions,
} from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import { CastManager, getCastManager } from "../../../../src/cast/cast_manager";
import type { CastManager } from "../../../../src/cast/cast_manager";
import { getCastManager } from "../../../../src/cast/cast_manager";
import { castSendShowDemo } from "../../../../src/cast/receiver_messages";
import {
loadTokens,
Expand Down
11 changes: 4 additions & 7 deletions cast/src/launcher/layout/hc-layout.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {
Auth,
Connection,
getUser,
HassUser,
} from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import type { Auth, Connection, HassUser } from "home-assistant-js-websocket";
import { getUser } from "home-assistant-js-websocket";
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-card";

Expand Down
3 changes: 2 additions & 1 deletion cast/src/receiver/demo/cast-demo-entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { convertEntities, Entity } from "../../../../src/fake_data/entity";
import type { Entity } from "../../../../src/fake_data/entity";
import { convertEntities } from "../../../../src/fake_data/entity";

export const castDemoEntities: () => Entity[] = () =>
convertEntities({
Expand Down
4 changes: 2 additions & 2 deletions cast/src/receiver/demo/cast-demo-lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LovelaceCardConfig } from "../../../../src/data/lovelace/config/card";
import { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
import type { LovelaceCardConfig } from "../../../../src/data/lovelace/config/card";
import type { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
import { castContext } from "../cast_context";

export const castDemoLovelace: () => LovelaceConfig = () => {
Expand Down
4 changes: 2 additions & 2 deletions cast/src/receiver/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { framework } from "./cast_framework";
import { CAST_NS } from "../../../src/cast/const";
import { HassMessage } from "../../../src/cast/receiver_messages";
import type { HassMessage } from "../../../src/cast/receiver_messages";
import "../../../src/resources/custom-card-support";
import { castContext } from "./cast_context";
import { HcMain } from "./layout/hc-main";
import { ReceivedMessage } from "./types";
import type { ReceivedMessage } from "./types";

const lovelaceController = new HcMain();
document.body.append(lovelaceController);
Expand Down
10 changes: 4 additions & 6 deletions cast/src/receiver/layout/hc-demo.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { mockHistory } from "../../../../demo/src/stubs/history";
import { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
import {
MockHomeAssistant,
provideHass,
} from "../../../../src/fake_data/provide_hass";
import type { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
import type { MockHomeAssistant } from "../../../../src/fake_data/provide_hass";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import { HassElement } from "../../../../src/state/hass-element";
import { HomeAssistant } from "../../../../src/types";
import type { HomeAssistant } from "../../../../src/types";
import { castDemoEntities } from "../demo/cast-demo-entities";
import { castDemoLovelace } from "../demo/cast-demo-lovelace";
import "./hc-lovelace";
Expand Down
5 changes: 3 additions & 2 deletions cast/src/receiver/layout/hc-launch-screen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import { HomeAssistant } from "../../../../src/types";
import type { HomeAssistant } from "../../../../src/types";

@customElement("hc-launch-screen")
class HcLaunchScreen extends LitElement {
Expand Down
14 changes: 10 additions & 4 deletions cast/src/receiver/layout/hc-lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import {
css,
type CSSResultGroup,
html,
LitElement,
type TemplateResult,
} from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
import type { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
import { getPanelTitleFromUrlPath } from "../../../../src/data/panel";
import { Lovelace } from "../../../../src/panels/lovelace/types";
import type { Lovelace } from "../../../../src/panels/lovelace/types";
import "../../../../src/panels/lovelace/views/hui-view";
import "../../../../src/panels/lovelace/views/hui-view-container";
import { HomeAssistant } from "../../../../src/types";
import type { HomeAssistant } from "../../../../src/types";
import "./hc-launch-screen";

(window as any).loadCardHelpers = () =>
Expand Down
20 changes: 9 additions & 11 deletions cast/src/receiver/layout/hc-main.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
import {
createConnection,
getAuth,
UnsubscribeFunc,
} from "home-assistant-js-websocket";
import { html, TemplateResult } from "lit";
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import { createConnection, getAuth } from "home-assistant-js-websocket";
import type { TemplateResult } from "lit";
import { html } from "lit";
import { customElement, state } from "lit/decorators";
import { CAST_NS } from "../../../../src/cast/const";
import {
import type {
ConnectMessage,
GetStatusMessage,
HassMessage,
ShowDemoMessage,
ShowLovelaceViewMessage,
} from "../../../../src/cast/receiver_messages";
import {
ReceiverErrorCode,
import type {
ReceiverErrorMessage,
ReceiverStatusMessage,
} from "../../../../src/cast/sender_messages";
import { ReceiverErrorCode } from "../../../../src/cast/sender_messages";
import { atLeastVersion } from "../../../../src/common/config/version";
import { isNavigationClick } from "../../../../src/common/dom/is-navigation-click";
import {
getLegacyLovelaceCollection,
getLovelaceCollection,
} from "../../../../src/data/lovelace";
import {
isStrategyDashboard,
import type {
LegacyLovelaceConfig,
LovelaceConfig,
LovelaceDashboardStrategyConfig,
} from "../../../../src/data/lovelace/config/types";
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
import { fetchResources } from "../../../../src/data/lovelace/resource";
import { loadLovelaceResources } from "../../../../src/panels/lovelace/common/load-resources";
import { HassElement } from "../../../../src/state/hass-element";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/arsaboo/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertEntities } from "../../../../src/fake_data/entity";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoEntitiesArsaboo: DemoConfig["entities"] = (localize) =>
convertEntities({
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/arsaboo/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";
import { demoEntitiesArsaboo } from "./entities";
import { demoLovelaceArsaboo } from "./lovelace";
import { demoThemeArsaboo } from "./theme";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/arsaboo/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
title: "Home Assistant",
Expand Down
6 changes: 3 additions & 3 deletions demo/src/configs/demo-configs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
import { Lovelace } from "../../../src/panels/lovelace/types";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
import type { Lovelace } from "../../../src/panels/lovelace/types";
import { energyEntities } from "../stubs/entities";
import { DemoConfig } from "./types";
import type { DemoConfig } from "./types";

export const demoConfigs: Array<() => Promise<DemoConfig>> = [
() => import("./sections").then((mod) => mod.demoSections),
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/jimpower/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertEntities } from "../../../../src/fake_data/entity";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoEntitiesJimpower: DemoConfig["entities"] = () =>
convertEntities({
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/jimpower/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";
import { demoEntitiesJimpower } from "./entities";
import { demoLovelaceJimpower } from "./lovelace";
import { demoThemeJimpower } from "./theme";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/jimpower/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "../../custom-cards/card-modder";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoLovelaceJimpower: DemoConfig["lovelace"] = () => ({
name: "Kingia Castle",
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/kernehed/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertEntities } from "../../../../src/fake_data/entity";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoEntitiesKernehed: DemoConfig["entities"] = () =>
convertEntities({
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/kernehed/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";
import { demoEntitiesKernehed } from "./entities";
import { demoLovelaceKernehed } from "./lovelace";
import { demoThemeKernehed } from "./theme";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/kernehed/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoLovelaceKernehed: DemoConfig["lovelace"] = () => ({
name: "Hem",
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/sections/description.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { html } from "lit";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoLovelaceDescription: DemoConfig["description"] = (
localize
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/sections/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertEntities } from "../../../../src/fake_data/entity";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoEntitiesSections: DemoConfig["entities"] = (localize) =>
convertEntities({
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/sections/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";
import { demoLovelaceDescription } from "./description";
import { demoEntitiesSections } from "./entities";
import { demoLovelaceSections } from "./lovelace";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/sections/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isFrontpageEmbed } from "../../util/is_frontpage";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoLovelaceSections: DemoConfig["lovelace"] = (localize) => ({
title: "Home Assistant Demo",
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/teachingbirds/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertEntities } from "../../../../src/fake_data/entity";
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () =>
convertEntities({
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/teachingbirds/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";
import { demoEntitiesTeachingbirds } from "./entities";
import { demoLovelaceTeachingbirds } from "./lovelace";
import { demoThemeTeachingbirds } from "./theme";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/configs/teachingbirds/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DemoConfig } from "../types";
import type { DemoConfig } from "../types";

export const demoLovelaceTeachingbirds: DemoConfig["lovelace"] = () => ({
title: "Home",
Expand Down
8 changes: 4 additions & 4 deletions demo/src/configs/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TemplateResult } from "lit";
import { LocalizeFunc } from "../../../src/common/translations/localize";
import { LovelaceConfig } from "../../../src/data/lovelace/config/types";
import { Entity } from "../../../src/fake_data/entity";
import type { TemplateResult } from "lit";
import type { LocalizeFunc } from "../../../src/common/translations/localize";
import type { LovelaceConfig } from "../../../src/data/lovelace/config/types";
import type { Entity } from "../../../src/fake_data/entity";

export interface DemoConfig {
index?: number;
Expand Down
9 changes: 5 additions & 4 deletions demo/src/custom-cards/cast-demo-row.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { mdiTelevision } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import type { CSSResultGroup } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { CastManager } from "../../../src/cast/cast_manager";
import type { CastManager } from "../../../src/cast/cast_manager";
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
import "../../../src/components/ha-icon";
import {
import type {
CastConfig,
LovelaceRow,
} from "../../../src/panels/lovelace/entity-rows/types";
import { HomeAssistant } from "../../../src/types";
import type { HomeAssistant } from "../../../src/types";

@customElement("cast-demo-row")
class CastDemoRow extends LitElement implements LovelaceRow {
Expand Down
12 changes: 8 additions & 4 deletions demo/src/custom-cards/ha-demo-card.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import type { CSSResultGroup } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { until } from "lit/directives/until";
import { fireEvent } from "../../../src/common/dom/fire_event";
import "../../../src/components/ha-card";
import "../../../src/components/ha-button";
import "../../../src/components/ha-circular-progress";
import { LovelaceCardConfig } from "../../../src/data/lovelace/config/card";
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
import { Lovelace, LovelaceCard } from "../../../src/panels/lovelace/types";
import type { LovelaceCardConfig } from "../../../src/data/lovelace/config/card";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
import type {
Lovelace,
LovelaceCard,
} from "../../../src/panels/lovelace/types";
import {
demoConfigs,
selectedDemoConfig,
Expand Down
8 changes: 3 additions & 5 deletions demo/src/ha-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import "../../src/resources/compatibility";
import { customElement } from "lit/decorators";
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
import { navigate } from "../../src/common/navigate";
import {
MockHomeAssistant,
provideHass,
} from "../../src/fake_data/provide_hass";
import type { MockHomeAssistant } from "../../src/fake_data/provide_hass";
import { provideHass } from "../../src/fake_data/provide_hass";
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
import { HomeAssistant } from "../../src/types";
import type { HomeAssistant } from "../../src/types";
import { selectedDemoConfig } from "./configs/demo-configs";
import { mockAreaRegistry } from "./stubs/area_registry";
import { mockAuth } from "./stubs/auth";
Expand Down
2 changes: 1 addition & 1 deletion demo/src/stubs/area_registry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AreaRegistryEntry } from "../../../src/data/area_registry";
import type { AreaRegistryEntry } from "../../../src/data/area_registry";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";

export const mockAreaRegistry = (
Expand Down
2 changes: 1 addition & 1 deletion demo/src/stubs/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";

export const mockAuth = (hass: MockHomeAssistant) => {
hass.mockWS("config/auth/list", () => []);
Expand Down
Loading
Loading