Skip to content

Commit

Permalink
Update eslint & airbnb-base
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkih committed Dec 31, 2020
1 parent eaacd44 commit 5b47d7c
Show file tree
Hide file tree
Showing 17 changed files with 688 additions and 455 deletions.
1,054 changes: 643 additions & 411 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"babel-loader": "^8.1.0",
"babel-plugin-iife-wrap": "^1.1.0",
"babel-preset-minify": "^0.5.0",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "2.16.0",
"eslint": "^7.16.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
Expand All @@ -43,6 +43,7 @@
"webpack": "webpack",
"babel": "babel dist/mini-media-player-bundle.js --out-file dist/mini-media-player-bundle.js",
"lint": "eslint src/* --ext .js",
"lint:fix": "eslint --fix src/* --ext .js",
"watch": "webpack --watch",
"dev": "webpack --watch"
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MiniMediaPlayerDropdown extends LitElement {
}

get selectedId() {
return this.items.map(item => item.id).indexOf(this.selected);
return this.items.map((item) => item.id).indexOf(this.selected);
}

onChange(e) {
Expand All @@ -36,7 +36,7 @@ class MiniMediaPlayerDropdown extends LitElement {
.horizontalAlign=${'right'}
.verticalAlign=${'top'}
.verticalOffset=${44}
@click=${e => e.stopPropagation()}>
@click=${(e) => e.stopPropagation()}>
${this.icon ? html`
<ha-icon-button
class='mmp-dropdown__button icon'
Expand All @@ -54,7 +54,7 @@ class MiniMediaPlayerDropdown extends LitElement {
</mmp-button>
`}
<paper-listbox slot="dropdown-content" .selected=${this.selectedId} @iron-select=${this.onChange}>
${this.items.map(item => html`
${this.items.map((item) => html`
<paper-item value=${item.id || item.name}>
${item.icon ? html`<ha-icon .icon=${item.icon}></ha-icon>` : ''}
${item.name ? html`<span class='mmp-dropdown__item__label'>${item.name}</span>` : ''}
Expand Down
2 changes: 1 addition & 1 deletion src/components/groupItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MiniMediaPlayerGroupItem extends LitElement {
<mmp-checkbox
.checked=${this.checked}
.disabled=${this.disabled}
@change='${e => e.stopPropagation()}'
@change='${(e) => e.stopPropagation()}'
@click='${this.handleClick}'>
<span>
${this.item.name}
Expand Down
8 changes: 4 additions & 4 deletions src/components/groupList.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ class MiniMediaPlayerGroupList extends LitElement {
return html`
<div class='mmp-group-list'>
<span class='mmp-group-list__title'>${t(this.hass, 'title.speaker_management')}</span>
${this.entities.map(item => this.renderItem(item, id))}
${this.entities.map((item) => this.renderItem(item, id))}
<div class='mmp-group-list__buttons'>
<mmp-button raised ?disabled=${!isGrouped}
@click=${e => this.player.handleGroupChange(e, id, false)}>
@click=${(e) => this.player.handleGroupChange(e, id, false)}>
<span>${t(this.hass, 'label.leave')}</span>
</mmp-button>
${isGrouped && isMaster ? html`
<mmp-button raised
@click=${e => this.player.handleGroupChange(e, group, false)}>
@click=${(e) => this.player.handleGroupChange(e, group, false)}>
<span>${t(this.hass, 'label.ungroup')}</span>
</mmp-button>
` : html``}
<mmp-button raised ?disabled=${!isMaster}
@click=${e => this.player.handleGroupChange(e, this.entities.map(item => item.entity_id), true)}>
@click=${(e) => this.player.handleGroupChange(e, this.entities.map((item) => item.entity_id), true)}>
<span>${t(this.hass, 'label.group_all')}</span>
</mmp-button>
</div>
Expand Down
26 changes: 13 additions & 13 deletions src/components/mediaControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MiniMediaPlayerMediaControls extends LitElement {
<div class='flex mmp-media-controls__shuffle'>
<ha-icon-button
class='shuffle-button'
@click=${e => this.player.toggleShuffle(e)}
@click=${(e) => this.player.toggleShuffle(e)}
.icon=${ICON.SHUFFLE}
?color=${this.player.shuffle}>
</ha-icon-button>
Expand All @@ -47,13 +47,13 @@ class MiniMediaPlayerMediaControls extends LitElement {
<div class='flex mmp-media-controls__media' ?flow=${this.config.flow || this.break}>
${!hide.prev ? html`
<ha-icon-button
@click=${e => this.player.prev(e)}
@click=${(e) => this.player.prev(e)}
.icon=${ICON.PREV}>
</ha-icon-button>` : ''}
${this.renderPlayButtons()}
${!hide.next ? html`
<ha-icon-button
@click=${e => this.player.next(e)}
@click=${(e) => this.player.next(e)}
.icon=${ICON.NEXT}>
</ha-icon-button>` : ''}
</div>
Expand Down Expand Up @@ -85,7 +85,7 @@ class MiniMediaPlayerMediaControls extends LitElement {
${this.renderMuteButton(muted)}
<ha-slider
@change=${this.handleVolumeChange}
@click=${e => e.stopPropagation()}
@click=${(e) => e.stopPropagation()}
?disabled=${muted}
min=${this.minVol} max=${this.maxVol}
value=${this.player.vol * 100}
Expand All @@ -100,11 +100,11 @@ class MiniMediaPlayerMediaControls extends LitElement {
return html`
${this.renderMuteButton(muted)}
<ha-icon-button
@click=${e => this.player.volumeDown(e)}
@click=${(e) => this.player.volumeDown(e)}
.icon=${ICON.VOL_DOWN}>
</ha-icon-button>
<ha-icon-button
@click=${e => this.player.volumeUp(e)}
@click=${(e) => this.player.volumeUp(e)}
.icon=${ICON.VOL_UP}>
</ha-icon-button>
`;
Expand All @@ -123,36 +123,36 @@ class MiniMediaPlayerMediaControls extends LitElement {
case 'play_pause':
return html`
<ha-icon-button
@click=${e => this.player.playPause(e)}
@click=${(e) => this.player.playPause(e)}
.icon=${ICON.PLAY[this.player.isPlaying]}>
</ha-icon-button>
`;
case 'stop':
return html`
<ha-icon-button
@click=${e => this.player.stop(e)}
@click=${(e) => this.player.stop(e)}
.icon=${ICON.STOP.true}>
</ha-icon-button>
`;
case 'play_stop':
return html`
<ha-icon-button
@click=${e => this.player.playStop(e)}
@click=${(e) => this.player.playStop(e)}
.icon=${ICON.STOP[this.player.isPlaying]}>
</ha-icon-button>
`;
case 'next':
return html`
<ha-icon-button
@click=${e => this.player.next(e)}
@click=${(e) => this.player.next(e)}
.icon=${ICON.NEXT}>
</ha-icon-button>
`;
default:
if (!this.player.supportsMute) return;
return html`
<ha-icon-button
@click=${e => this.player.toggleMute(e)}
@click=${(e) => this.player.toggleMute(e)}
.icon=${ICON.MUTE[muted]}>
</ha-icon-button>
`;
Expand All @@ -164,13 +164,13 @@ class MiniMediaPlayerMediaControls extends LitElement {
return html`
${!hide.play_pause ? html`
<ha-icon-button
@click=${e => this.player.playPause(e)}
@click=${(e) => this.player.playPause(e)}
.icon=${ICON.PLAY[this.player.isPlaying]}>
</ha-icon-button>
` : html``}
${!hide.play_stop ? html`
<ha-icon-button
@click=${e => this.handleStop(e)}
@click=${(e) => this.handleStop(e)}
.icon=${hide.play_pause ? ICON.STOP[this.player.isPlaying] : ICON.STOP.true}>
</ha-icon-button>
` : html``}
Expand Down
4 changes: 2 additions & 2 deletions src/components/powerstrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MiniMediaPlayerPowerstrip extends LitElement {
${this.showPowerButton ? html`
<ha-icon-button class='power-button'
.icon=${ICON.POWER}
@click=${e => this.player.toggle(e)}
@click=${(e) => this.player.toggle(e)}
?color=${this.powerColor}>
</ha-icon-button>` : ''}
`;
Expand All @@ -110,7 +110,7 @@ class MiniMediaPlayerPowerstrip extends LitElement {
return html`
<ha-icon-button
.icon=${ICON.PLAY[this.player.isPlaying]}
@click=${e => this.player.playPause(e)}>
@click=${(e) => this.player.playPause(e)}>
</ha-icon-button>`;
else
return html`
Expand Down
2 changes: 1 addition & 1 deletion src/components/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MiniMediaPlayerProgress extends LitElement {
@mousedown=${this.initSeek}
@mouseup=${this.handleSeek}
@mouseleave=${this.resetSeek}
@click=${e => e.stopPropagation()}
@click=${(e) => e.stopPropagation()}
?paused=${!this.player.isPlaying}>
${this.showTime ? html`
<div class='mmp-progress__duration'>
Expand Down
4 changes: 2 additions & 2 deletions src/components/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class MiniMediaPlayerShortcuts extends LitElement {

const buttons = this.buttons ? html`
<div class='mmp-shortcuts__buttons'>
${this.buttons.map(item => html`
${this.buttons.map((item) => html`
<mmp-button
style="${styleMap(this.shortcutStyle(item))}"
raised
columns=${this.shortcuts.columns}
?color=${item.id === active}
class='mmp-shortcuts__button'
@click=${e => this.handleShortcut(e, item)}>
@click=${(e) => this.handleShortcut(e, item)}>
<div align=${this.shortcuts.align_text}>
${item.icon ? html`<ha-icon .icon=${item.icon}></ha-icon>` : ''}
${item.image ? html`<img src=${item.image}>` : ''}
Expand Down
2 changes: 1 addition & 1 deletion src/components/soundMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MiniMediaPlayerSoundMenu extends LitElement {
}

get modes() {
return this.player.soundModes.map(mode => ({
return this.player.soundModes.map((mode) => ({
name: mode,
id: mode,
type: 'soundMode',
Expand Down
2 changes: 1 addition & 1 deletion src/components/sourceMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MiniMediaPlayerSourceMenu extends LitElement {
}

get sources() {
return this.player.sources.map(source => ({
return this.player.sources.map((source) => ({
name: source,
id: source,
type: 'source',
Expand Down
2 changes: 1 addition & 1 deletion src/components/tts.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MiniMediaPlayerTts extends LitElement {
<paper-input id="tts-input" class='mmp-tts__input'
no-label-float
placeholder=${this.label}...
@click=${e => e.stopPropagation()}>
@click=${(e) => e.stopPropagation()}>
</paper-input>
<mmp-button class='mmp-tts__button' @click=${this.handleTts}>
<span>${t(this.hass, 'label.send')}</span>
Expand Down
1 change: 1 addition & 0 deletions src/ensureComponents.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
if (!customElements.get('ha-slider')) {
customElements.define(
'ha-slider',
Expand Down
8 changes: 4 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class MiniMediaPlayer extends LitElement {
if (changedProps.has('player') && this.config.artwork === 'material') {
this.setColors();
}
return UPDATE_PROPS.some(prop => changedProps.has(prop)) && this.player;
return UPDATE_PROPS.some((prop) => changedProps.has(prop)) && this.player;
}

firstUpdated() {
Expand Down Expand Up @@ -152,7 +152,7 @@ class MiniMediaPlayer extends LitElement {
<ha-card
class=${this.computeClasses()}
style=${this.computeStyles()}
@click=${e => this.handlePopup(e)}
@click=${(e) => this.handlePopup(e)}
artwork=${config.artwork}
content=${this.player.content}>
<div class='mmp__bg'>
Expand Down Expand Up @@ -320,10 +320,10 @@ class MiniMediaPlayer extends LitElement {
${this.config.info === 'scroll' ? html`
<div>
<div class='marquee'>
${items.map(i => html`<span class=${`attr__${i.attr}`}>${i.prefix + i.text}</span>`)}
${items.map((i) => html`<span class=${`attr__${i.attr}`}>${i.prefix + i.text}</span>`)}
</div>
</div>` : ''}
${items.map(i => html`<span class=${`attr__${i.attr}`}>${i.prefix + i.text}</span>`)}
${items.map((i) => html`<span class=${`attr__${i.attr}`}>${i.prefix + i.text}</span>`)}
</div>`;
}

Expand Down
10 changes: 5 additions & 5 deletions src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ export default class MediaPlayerObject {
}

get mediaInfo() {
return MEDIA_INFO.map(item => ({
return MEDIA_INFO.map((item) => ({
text: this.attr[item.attr],
prefix: '',
...item,
})).filter(item => item.text);
})).filter((item) => item.text);
}

get hasProgress() {
return !this.config.hide.progress
&& !this.idle
&& PROGRESS_PROPS.every(prop => prop in this.attr);
&& PROGRESS_PROPS.every((prop) => prop in this.attr);
}

get progress() {
Expand Down Expand Up @@ -307,8 +307,8 @@ export default class MediaPlayerObject {
setVolume(e, vol) {
if (this.config.speaker_group.sync_volume) {
this.group.forEach((entity) => {
const conf = this.config.speaker_group.entities.find(entry => (entry.entity_id === entity))
|| {};
const conf = this.config.speaker_group.entities
.find((entry) => (entry.entity_id === entity)) || {};
let offsetVol = vol;
if (conf.volume_offset) {
offsetVol += (conf.volume_offset / 100);
Expand Down
3 changes: 1 addition & 2 deletions src/utils/colorGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const getContrastRatio = (rgb1, rgb2) => Math.round(
(contrast(rgb1, rgb2) + Number.EPSILON) * 100,
) / 100;


const colorGenerator = (colors) => {
colors.sort((colorA, colorB) => colorB.population - colorA.population);

Expand Down Expand Up @@ -84,7 +83,7 @@ const colorGenerator = (colors) => {
return [foregroundColor, backgroundColor.hex];
};

export default picture => new Vibrant(picture, {
export default (picture) => new Vibrant(picture, {
colorCount: 16,
generator: colorGenerator,
}).getPalette();
2 changes: 1 addition & 1 deletion src/utils/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const arrayBufferToBase64 = (buffer) => {
let binary = '';
const bytes = [].slice.call(new Uint8Array(buffer));

bytes.forEach(b => binary += String.fromCharCode(b));
bytes.forEach((b) => binary += String.fromCharCode(b));

return window.btoa(binary);
};
Expand Down

0 comments on commit 5b47d7c

Please sign in to comment.