Skip to content

Commit

Permalink
uth: lint with lit-analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Dec 17, 2023
1 parent 07a432f commit 5d45ff5
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const FOOTER_HEIGHT = 5;

export class Card extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property() config!: CardConfig;
@property({attribute: false}) config!: CardConfig;
@state() section!: Section;
@state() store!: Store;
@state() showLoader!: boolean;
Expand Down
14 changes: 7 additions & 7 deletions src/components/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ import { mdiCastVariant, mdiHome, mdiSpeakerMultiple, mdiStarOutline, mdiTune }
const { GROUPING, GROUPS, MEDIA_BROWSER, PLAYER, VOLUMES } = Section;

class Footer extends LitElement {
@property() config!: CardConfig;
@property({ attribute: false }) config!: CardConfig;
@property() section!: Section;

render() {
return html`
<ha-icon-button
hidden=${this.hide(PLAYER)}
hide=${this.hide(PLAYER)}
.path=${mdiHome}
@click="${() => dispatchShowSection(PLAYER)}"
selected="${this.selected(PLAYER)}"
></ha-icon-button>
<ha-icon-button
hidden=${this.hide(MEDIA_BROWSER)}
hide=${this.hide(MEDIA_BROWSER)}
.path=${mdiStarOutline}
@click="${() => dispatchShowSection(MEDIA_BROWSER)}"
selected="${this.selected(MEDIA_BROWSER)}"
></ha-icon-button>
<ha-icon-button
hidden=${this.hide(GROUPS)}
hide=${this.hide(GROUPS)}
.path=${mdiSpeakerMultiple}
@click="${() => dispatchShowSection(GROUPS)}"
selected="${this.selected(GROUPS)}"
></ha-icon-button>
<ha-icon-button
hidden=${this.hide(GROUPING)}
hide=${this.hide(GROUPING)}
.path=${mdiCastVariant}
@click="${() => dispatchShowSection(GROUPING)}"
selected="${this.selected(GROUPING)}"
></ha-icon-button>
<ha-icon-button
hidden=${this.hide(VOLUMES)}
hide=${this.hide(VOLUMES)}
.path=${mdiTune}
@click="${() => dispatchShowSection(VOLUMES)}"
selected="${this.selected(VOLUMES)}"
Expand Down Expand Up @@ -66,7 +66,7 @@ class Footer extends LitElement {
:host > *[selected] {
color: var(--accent-color);
}
:host > *[hidden] {
:host > *[hide] {
display: none;
}
`;
Expand Down
6 changes: 3 additions & 3 deletions src/components/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { REQUEST_PLAYER_EVENT } from '../constants';
import { MediaPlayer } from '../model/media-player';

class Group extends LitElement {
@property() store!: Store;
@property({ attribute: false }) store!: Store;
private config!: CardConfig;
@property() player!: MediaPlayer;
@property() selected = false;
@property({ attribute: false }) player!: MediaPlayer;
@property({ type: Boolean }) selected = false;

connectedCallback() {
super.connectedCallback();
Expand Down
2 changes: 1 addition & 1 deletion src/components/media-browser-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MediaPlayerEntityFeature } from '../types';
import Store from '../model/store';

class MediaBrowserHeader extends LitElement {
@property() store!: Store;
@property({attribute: false}) store!: Store;

render() {
return html`
Expand Down
4 changes: 2 additions & 2 deletions src/components/media-browser-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from '../utils/media-browser-utils';

export class MediaBrowserIcons extends LitElement {
@property() store!: Store;
@property() items!: MediaPlayerItem[];
@property({ attribute: false }) store!: Store;
@property({ attribute: false }) items!: MediaPlayerItem[];
private config!: CardConfig;

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/media-browser-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from '../utils/media-browser-utils';

export class MediaBrowserList extends LitElement {
@property() store!: Store;
@property() items!: MediaPlayerItem[];
@property({ attribute: false }) store!: Store;
@property({ type: Array }) items!: MediaPlayerItem[];
private config!: CardConfig;

render() {
Expand Down
8 changes: 4 additions & 4 deletions src/components/player-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { when } from 'lit/directives/when.js';
const { SHUFFLE_SET, REPEAT_SET, PLAY, PAUSE, NEXT_TRACK, PREVIOUS_TRACK } = MediaPlayerEntityFeature;

class PlayerControls extends LitElement {
@property() store!: Store;
@property({attribute: false}) store!: Store;
private config!: CardConfig;
private activePlayer!: MediaPlayer;
private mediaControlService!: MediaControlService;
Expand All @@ -27,11 +27,11 @@ class PlayerControls extends LitElement {
this.activePlayer.state !== 'idle',
() => html`
<div class="icons">
<ha-icon-button hidden=${noUpDown} @click="${this.volDown}" .path=${mdiVolumeMinus}></ha-icon-button>
<ha-icon-button hide=${noUpDown} @click="${this.volDown}" .path=${mdiVolumeMinus}></ha-icon-button>
<sonos-ha-player .store=${this.store} .features=${[SHUFFLE_SET, PREVIOUS_TRACK]}></sonos-ha-player>
<sonos-ha-player .store=${this.store} .features=${[PLAY, PAUSE]} class="big-icon"></sonos-ha-player>
<sonos-ha-player .store=${this.store} .features=${[NEXT_TRACK, REPEAT_SET]}></sonos-ha-player>
<ha-icon-button hidden=${noUpDown} @click="${this.volUp}" .path=${mdiVolumePlus}></ha-icon-button>
<ha-icon-button hide=${noUpDown} @click="${this.volUp}" .path=${mdiVolumePlus}></ha-icon-button>
</div>
`,
)}
Expand All @@ -54,7 +54,7 @@ class PlayerControls extends LitElement {
display: flex;
align-items: center;
}
.icons > *[hidden] {
.icons > *[hide] {
display: none;
}
.big-icon {
Expand Down
2 changes: 1 addition & 1 deletion src/components/player-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getSpeakerList } from '../utils/utils';
import { MediaPlayer } from '../model/media-player';

class PlayerHeader extends LitElement {
@property() store!: Store;
@property({attribute: false}) store!: Store;
private config!: CardConfig;
private activePlayer!: MediaPlayer;

Expand Down
2 changes: 1 addition & 1 deletion src/components/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MediaPlayer } from '../model/media-player';
import { styleMap } from 'lit-html/directives/style-map.js';

class Progress extends LitElement {
@property() store!: Store;
@property({attribute: false}) store!: Store;
private activePlayer!: MediaPlayer;

@state() private playingProgress!: number;
Expand Down
6 changes: 3 additions & 3 deletions src/components/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { mdiVolumeHigh, mdiVolumeMute } from '@mdi/js';
import { MediaPlayer } from '../model/media-player';

class Volume extends LitElement {
@property() store!: Store;
@property({ attribute: false }) store!: Store;
private config!: CardConfig;
private mediaControlService!: MediaControlService;
@property() player!: MediaPlayer;
@property() updateMembers = true;
@property({ attribute: false }) player!: MediaPlayer;
@property({ type: Boolean }) updateMembers = true;
@property() volumeClicked?: () => void;

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const mediaBrowserTitleStyle = css`
color: var(--secondary-text-color);
font-weight: bold;
padding: 0 0.5rem;
text-overflow-ellipsis: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
Expand Down
13 changes: 9 additions & 4 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ class AdvancedEditor extends BaseEditor {
const topFavorites = this.store.config.topFavorites ?? [];
const data = { ...this.store.config, topFavorites: topFavorites.join(', ') };
return html`
<sonos-card-editor-form .schema=${ADVANCED_SCHEMA} .store=${this.store} .data=${data} .changed=${this.changed}></sonos-card-editor-form>
<p>
The following needs to be configured using code (YAML):
<sonos-card-editor-form
.schema=${ADVANCED_SCHEMA}
.store=${this.store}
.data=${data}
.changed=${this.changed}
></sonos-card-editor-form>
<div>
The following needs to be configured using code (YAML):
<ul>
<li>customSources</li>
<li>customThumbnail</li>
<li>customThumbnailIfMissing</li>
<li>mediaBrowserTitlesToIgnore</li>
</ul>
</p>
</div>
`;
}
protected changed(ev: CustomEvent): void {
Expand Down
2 changes: 1 addition & 1 deletion src/editor/artwork-override-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BaseEditor } from './base-editor';

const newOverride = { ifMissing: false };
class ArtworkOverrideEditor extends BaseEditor {
@property() index!: number;
@property({ type: Number }) index!: number;
protected render(): TemplateResult {
this.config = this.store.config;
this.hass = this.store.hass;
Expand Down
6 changes: 3 additions & 3 deletions src/editor/base-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { CardConfig } from '../types';
import Store from '../model/store';

export abstract class BaseEditor extends LitElement {
@property() config!: CardConfig;
@property() hass!: HomeAssistant;
@property() store!: Store;
@property({attribute: false}) config!: CardConfig;
@property({attribute: false}) hass!: HomeAssistant;
@property({attribute: false}) store!: Store;

setConfig(config: CardConfig) {
this.config = JSON.parse(JSON.stringify(config));
Expand Down
2 changes: 1 addition & 1 deletion src/editor/custom-source-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { property } from 'lit/decorators.js';
import { BaseEditor } from './base-editor';

class CustomSourceEditor extends BaseEditor {
@property() index!: number;
@property({ type: Number }) index!: number;

protected render(): TemplateResult {
return html``;
Expand Down
4 changes: 2 additions & 2 deletions src/editor/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BaseEditor } from './base-editor';
import { property } from 'lit/decorators.js';

class Form extends BaseEditor {
@property() schema!: unknown;
@property() data!: unknown;
@property({attribute: false}) schema!: unknown;
@property({attribute: false}) data!: unknown;
@property() changed!: (ev: CustomEvent) => void;
protected render(): TemplateResult {
this.config = this.store.config;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/predefined-group-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BaseEditor } from './base-editor';
import { ConfigPredefinedGroupPlayer, PredefinedGroup } from '../types';

class PredefinedGroupEditor extends BaseEditor {
@property() index!: number;
@property({ type: Number }) index!: number;
@state() predefinedGroup!: PredefinedGroup<ConfigPredefinedGroupPlayer>;

private schema = [
Expand Down
2 changes: 1 addition & 1 deletion src/sections/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MediaPlayer } from '../model/media-player';
import '../components/grouping-button';

export class Grouping extends LitElement {
@property() store!: Store;
@property({attribute: false}) store!: Store;
private activePlayer!: MediaPlayer;
private mediaControlService!: MediaControlService;
private allGroups!: MediaPlayer[];
Expand Down
2 changes: 1 addition & 1 deletion src/sections/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { listStyle } from '../constants';
import { MediaPlayer } from '../model/media-player';

export class Groups extends LitElement {
@property() store!: Store;
@property({ attribute: false }) store!: Store;
private groups!: MediaPlayer[];
private activePlayer!: MediaPlayer;

Expand Down
2 changes: 1 addition & 1 deletion src/sections/media-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import MediaBrowseService from '../services/media-browse-service';
import { indexOfWithoutSpecialChars } from '../utils/media-browser-utils';

export class MediaBrowser extends LitElement {
@property() store!: Store;
@property({ attribute: false }) store!: Store;
private config!: CardConfig;
private activePlayer!: MediaPlayer;
private mediaPlayers!: MediaPlayer[];
Expand Down
2 changes: 1 addition & 1 deletion src/sections/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MUSIC_NOTES_BASE64_IMAGE, TV_BASE64_IMAGE } from '../constants';
import { MediaPlayer } from '../model/media-player';

export class Player extends LitElement {
@property() store!: Store;
@property({ attribute: false }) store!: Store;
private config!: CardConfig;
private activePlayer!: MediaPlayer;

Expand Down
12 changes: 6 additions & 6 deletions src/sections/volumes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { HassEntity } from 'home-assistant-js-websocket';
const { SELECT_SOURCE } = MediaPlayerEntityFeature;

class Volumes extends LitElement {
@property() store!: Store;
@property({ attribute: false }) store!: Store;
private config!: CardConfig;
private activePlayer!: MediaPlayer;
private mediaControlService!: MediaControlService;
Expand Down Expand Up @@ -48,18 +48,18 @@ class Volumes extends LitElement {
<div class="volume-name-text">${name}</div>
</div>
<div class="slider-row">
<ha-icon-button hidden=${noUpDown} @click="${volDown}" .path=${mdiVolumeMinus}></ha-icon-button>
<ha-icon-button hide=${noUpDown} @click="${volDown}" .path=${mdiVolumeMinus}></ha-icon-button>
<sonos-volume .store=${this.store} .player=${player} .updateMembers=${updateMembers}></sonos-volume>
<ha-icon-button hidden=${noUpDown} @click="${volUp}" .path=${mdiVolumePlus}></ha-icon-button>
<ha-icon-button hide=${noUpDown} @click="${volUp}" .path=${mdiVolumePlus}></ha-icon-button>
<ha-icon-button
hidden=${updateMembers || nothing}
hide=${updateMembers || nothing}
@click="${() => this.toggleShowSwitches(player)}"
.path=${mdiCog}
show-switches="${this.showSwitches[player.id] || nothing}"
></ha-icon-button>
</div>
<div class="switches">
<sonos-ha-player hidden=${hideSwitches || nothing} .store=${this.store} .features=${[SELECT_SOURCE]}>
<sonos-ha-player hide=${hideSwitches || nothing} .store=${this.store} .features=${[SELECT_SOURCE]}>
</sonos-ha-player>
${until(this.getAdditionalControls(hideSwitches, player))}
</div>
Expand Down Expand Up @@ -134,7 +134,7 @@ class Volumes extends LitElement {
color: var(--accent-color);
}
*[hidden] {
*[hide] {
display: none;
}
`;
Expand Down

0 comments on commit 5d45ff5

Please sign in to comment.