Fix a bunch of lint errors (#1044)

* Fix a bunch of lint errors

* Add behavior jsdoc

* Convert ha-markdown to polymer element

* Update lint command
pull/1053/head
Paulus Schoutsen 2018-03-29 16:57:15 -07:00 committed by GitHub
parent 0e227708b9
commit 06502cb93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 108 additions and 316 deletions

View File

@ -6,6 +6,8 @@ class HassioData extends Polymer.Element {
static get properties() {
return {
hass: Object,
supervisor: {
type: Object,
notify: true,

View File

@ -16,7 +16,7 @@
"dev-es5": "npm run gulp ru_all_es5 gen-service-worker-es5",
"dev-watch-es5": "npm run gulp watch_ru_all_es5 gen-service-worker-es5",
"lint_js": "eslint src panels js hassio test-mocha --ext js,html",
"lint_html": "ls -1 src/home-assistant.html panels/**/ha-panel-*.html | xargs polymer lint --input",
"lint_html": "find src panels hassio -name '*.html' | grep -v hassio/index.html | xargs polymer lint --input",
"mocha": "node_modules/.bin/mocha --opts test-mocha/mocha.opts",
"test": "npm run lint_js && npm run lint_html && npm run mocha"
},

View File

@ -8,6 +8,7 @@
<link rel="import" href="../../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel='import' href='../../../src/layouts/ha-app-layout.html'>
<link rel='import' href='../../../src/components/ha-markdown.html'>
<link rel='import' href='../../../src/util/hass-mixins.html'>
<link rel="import" href="../ha-config-section.html">

View File

@ -7,6 +7,8 @@
<link rel="import" href="../../../src/util/hass-mixins.html">
<link rel="import" href='../../../src/resources/ha-style.html'>
<link rel="import" href="../ha-config-section.html">
<dom-module id="ha-config-cloud-account">
<template>
<style include="iron-flex ha-style">
@ -116,6 +118,7 @@ class HaConfigCloudAccount extends window.hassMixins.EventsMixin(Polymer.Element
static get properties() {
return {
hass: Object,
isWide: Boolean,
account: {
type: Object,
observer: '_accountChanged',

View File

@ -4,12 +4,16 @@
<link rel="import" href='../../../bower_components/paper-icon-button/paper-icon-button.html'>
<link rel="import" href='../../../bower_components/paper-input/paper-input.html'>
<link rel="import" href='../../../bower_components/paper-ripple/paper-ripple.html'>
<link rel="import" href='../../../bower_components/paper-item/paper-item.html'>
<link rel="import" href='../../../bower_components/paper-item/paper-item-body.html'>
<link rel="import" href="../../../src/layouts/hass-subpage.html">
<link rel="import" href="../../../src/util/hass-mixins.html">
<link rel="import" href='../../../src/resources/ha-style.html'>
<link rel="import" href='../../../src/components/buttons/ha-progress-button.html'>
<link rel="import" href="../ha-config-section.html">
<dom-module id="ha-config-cloud-login">
<template>
<style include="iron-flex ha-style">

View File

@ -7,6 +7,8 @@
<link rel="import" href='../../../src/resources/ha-style.html'>
<link rel="import" href='../../../src/components/buttons/ha-progress-button.html'>
<link rel="import" href="../ha-config-section.html">
<dom-module id="ha-config-cloud-register">
<template>
<style include="iron-flex ha-style">

View File

@ -49,7 +49,6 @@
<ha-config-cloud-forgot-password
page-name='forgot-password'
hass='[[hass]]'
is-wide='[[isWide]]'
email='{{_loginEmail}}'
></ha-config-cloud-forgot-password>
</template>

View File

@ -8,6 +8,8 @@
<link rel='import' href='../../../src/resources/ha-style.html'>
<link rel='import' href='../../../src/layouts/hass-subpage.html'>
<link rel='import' href='../ha-config-section.html'>
<link rel='import' href='./ha-config-flow.html'>
<dom-module id="ha-config-entries">
@ -106,6 +108,7 @@
static get properties() {
return {
hass: Object,
isWide: Boolean,
_flowId: {
type: String,

View File

@ -84,7 +84,7 @@
>
<template is='dom-repeat'
items='[[schema.options]]'>
<paper-item item-name='[[item]]'>[[item]]</paper-item>
<paper-item item-name$='[[item]]'>[[item]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>

View File

@ -8,7 +8,6 @@
<link rel='import' href='../../../src/util/hass-mixins.html'>
<link rel="import" href="./ha-config-section-core.html">
<!-- <link rel="import" href="./ha-config-section-group.html"> -->
<link rel="import" href="./ha-config-section-hassbian.html">
<link rel="import" href="./ha-config-section-push-notifications.html">
<link rel="import" href="./ha-config-section-translation.html">
@ -44,15 +43,6 @@
</app-header>
<div class$='[[computeClasses(isWide)]]'>
<!--
Sortable.js doesn't work in Polymer 2 making this panel useless.
Disabling for now.
<ha-config-section-group
is-wide='[[isWide]]'
hass='[[hass]]'
></ha-config-section-group>
-->
<ha-config-section-core
is-wide='[[isWide]]'
hass='[[hass]]'

View File

@ -1,82 +0,0 @@
<link rel="import" href="../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../../bower_components/paper-card/paper-card.html">
<link rel="import" href="../../../bower_components/paper-checkbox/paper-checkbox.html">
<link rel="import" href="../../../bower_components/paper-spinner/paper-spinner.html">
<link rel="import" href="../../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel='import' href='../../../bower_components/paper-listbox/paper-listbox.html'>
<link rel='import' href='../../../bower_components/paper-item/paper-item.html'>
<link rel="import" href="../../../src/resources/ha-style.html">
<link rel="import" href="../../../src/util/hass-util.html">
<link rel="import" href="../ha-config-section.html">
<link rel="import" href="../ha-entity-config.html">
<link rel="import" href="./ha-form-group.html">
<dom-module id="ha-config-section-group">
<template>
<ha-config-section is-wide='[[isWide]]'>
<span slot='header'>Groups & Views</span>
<span slot='introduction'>
Use groups to organize your entities and make Home Assistant really your own.
<br><br>
Got more groups than you can handle? Create views to manage your groups.
</span>
<ha-entity-config
hass='[[hass]]'
label='Group'
entities='[[entities]]'
config='[[entityConfig]]'>
</ha-entity-config>
</ha-config-section>
</template>
</dom-module>
<script>
class HaConfigSectionGroup extends Polymer.Element {
static get is() { return 'ha-config-section-group'; }
static get properties() {
return {
hass: {
type: Object,
},
isWide: {
type: Boolean,
value: false,
},
entities: {
type: Array,
computed: 'computeEntities(hass)',
},
entityConfig: {
type: Object,
value: {
component: 'ha-form-group',
computeSelectCaption: function (stateObj) {
return window.hassUtil.computeStateName(stateObj) +
(stateObj.attributes.view ? ' (view)' : '');
},
}
}
};
}
computeEntities(hass) {
return Object.keys(hass.states)
.map(function (key) { return hass.states[key]; })
.filter(function (entity) {
return (window.hassUtil.computeDomain(entity) === 'group' &&
!entity.attributes.auto);
})
.sort(window.hassUtil.sortByName);
}
}
customElements.define(HaConfigSectionGroup.is, HaConfigSectionGroup);
</script>

View File

@ -20,7 +20,7 @@
<paper-dropdown-menu label="[[localize('ui.panel.config.core.section.translation.language')]]" dynamic-align>
<paper-listbox slot="dropdown-content" on-selected-item-changed="handleLanguageSelect" attr-for-selected="language-tag" selected="[[language]]">
<template is='dom-repeat' items='[[languages]]'>
<paper-item language-tag="[[item.tag]]">[[item.nativeName]]</paper-item>
<paper-item language-tag$="[[item.tag]]">[[item.nativeName]]</paper-item>
</template>
</paper-listbox>
></paper-dropdown-menu>

View File

@ -1,195 +0,0 @@
<link rel="import" href="../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../../bower_components/paper-menu-button/paper-menu-button.html">
<link rel="import" href="../../../bower_components/paper-radio-group/paper-radio-group.html">
<link rel="import" href="../../../bower_components/paper-radio-button/paper-radio-button.html">
<link rel="import" href="../../../bower_components/polymer-sortablejs/polymer-sortablejs.html">
<link rel="import" href="../../../src/components/entity/state-info.html">
<link rel="import" href="../ha-form-style.html">
<dom-module id="ha-form-group">
<template>
<style include="iron-flex ha-style ha-form-style">
.entities-header {
@apply --layout-horizontal;
@apply --layout-justified;
@apply --layout-center;
width: 100%;
}
.drag-handle {
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
}
.sortable-chosen .drag-handle, .sortable-ghost {
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
sortable-js {
width: 100%;
}
.entity-row {
@apply --layout-horizontal;
@apply --layout-center;
padding: 4px 0;
border-top: 1px solid rgba(0, 0, 0, .12);
}
.entity-row:first-child {
border-top: 1px solid rgba(0, 0, 0, 0);
}
.entity-row.sortable-chosen {
background-color: var(--paper-grey-200);
/* invisible border so we don't change height. */
border-top: 1px solid rgba(0, 0, 0, 0);
}
.entity-row .unknown {
padding-left: 56px;
}
.entity-row paper-icon-button {
visibility: hidden;
}
.entity-row:not(.sortable-chosen):hover paper-icon-button {
visibility: visible;
}
</style>
<div class='form-group'>
<paper-input
class='form-control flex'
label='Name'
value='{{entityName}}'>
</paper-input>
</div>
<div class='form-group'>
<label>Type</label>
<paper-radio-group
selected='{{entityType}}'
class='form-control'
>
<paper-radio-button name='group'>Group</paper-radio-button>
<paper-radio-button name='view'>View</paper-radio-button>
</paper-radio-group>
</div>
<div class='form-group vertical entities'>
<div class='entities-header'>
<label>Entities (drag to reorder):</label>
<!-- To be done
<paper-menu-button
dynamic-align
class='form-control'
>
<paper-icon-button
icon='mdi:plus'
slot="dropdown-trigger"
></paper-icon-button>
<paper-listbox
slot="dropdown-content"
selected='{{entityPollingIntensity}}'
>
<paper-item>Do not poll (0)</paper-item>
<paper-item>Poll every time (1)</paper-item>
<paper-item>Poll every other time (2)</paper-item>
</paper-listbox>
</paper-menu-button>
-->
</div>
<sortable-js
class='form-control'
on-choose='handleRowChosen'
handle='.drag-handle'
>
<template is="dom-repeat" items='{{entityChildren}}'>
<div class='entity-row'>
<iron-icon icon='mdi:drag-vertical' class='drag-handle'></iron-icon>
<template is='dom-if' if='[[!item.state]]'>
<div class='unknown flex'>Unknown entity [[item.entity_id]]</div>
</template>
<template is='dom-if' if='[[item.state]]' restamp>
<state-info state-obj='[[item]]' class='flex'></state-info>
</template>
<!-- <paper-icon-button icon='mdi:delete'></paper-icon-button> -->
</div>
</template>
</sortable-js>
</div>
</template>
</dom-module>
<script>
class HaFormGroup extends Polymer.Element {
static get is() { return 'ha-form-group'; }
static get properties() {
return {
hass: {
type: Object,
},
entity: {
type: Object,
},
entityName: {
type: String,
value: '',
},
entityType: {
type: String,
},
entityChildren: {
type: Object,
},
};
}
handleRowChosen(ev) {
// Polymer element and sortablejs both fire the same events, filter one out
if (!ev.detail || !window.navigator.vibrate) return;
// Tell the user that moving his finger now will start dragging.
window.navigator.vibrate(50);
}
loadEntity(entity) {
var states = this.hass.states;
this.entity = entity;
this.entityName = entity.attributes.friendly_name || '';
this.entityType = entity.attributes.view ? 'view' : 'group';
this.entityChildren = entity.attributes.entity_id
.map(function (ent) {
return states[ent] || { state: false, entity_id: ent, attributes: {} };
});
return Promise.resolve();
}
saveEntity() {
var data = {
name: this.entityName,
view: this.entityType === 'view',
entities: this.entityChildren.map(function (ent) { return ent.entity_id; }),
};
var objectId = this.entity.entity_id.split('.')[1];
return this.hass.callApi('POST', 'config/group/config/' + objectId, data);
}
}
customElements.define(HaFormGroup.is, HaFormGroup);
</script>

View File

@ -1,4 +1,11 @@
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../bower_components/paper-spinner/paper-spinner.html">
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../../bower_components/paper-card/paper-card.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<dom-module id="ha-entity-config">
<template>
<style include="iron-flex ha-style">

View File

@ -94,6 +94,7 @@
<ha-config-entries
page-name='integrations'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-entries>
</template>
</template>

View File

@ -1,6 +1,8 @@
<link rel="import" href="../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../../bower_components/paper-card/paper-card.html">
<link rel="import" href="../../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../../bower_components/paper-checkbox/paper-checkbox.html">
<link rel="import" href="../../../bower_components/paper-input/paper-input.html">
<link rel="import" href="../ha-config-section.html">

View File

@ -1,5 +1,6 @@
<link rel="import" href="../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../../bower_components/paper-card/paper-card.html">
<link rel="import" href="../../../bower_components/paper-button/paper-button.html">
<dom-module id='zwave-node-information'>
<template>

View File

@ -53,7 +53,10 @@
<script>
{
const UPDATE_INTERVAL = 10000; // ms
/*
* @appliesMixin window.hassMixins.LocalizeMixin
* @appliesMixin window.hassMixins.EventsMixin
*/
class HaCameraCard extends
window.hassMixins.LocalizeMixin(window.hassMixins.EventsMixin(Polymer.Element)) {
static get is() { return 'ha-camera-card'; }

View File

@ -206,6 +206,10 @@
</dom-module>
<script>
/*
* @appliesMixin window.hassMixins.LocalizeMixin
* @appliesMixin window.hassMixins.EventsMixin
*/
class HaMediaPlayerCard extends
window.hassMixins.LocalizeMixin(window.hassMixins.EventsMixin(Polymer.Element)) {
static get is() { return 'ha-media_player-card'; }

View File

@ -45,6 +45,9 @@
</dom-module>
<script>
/*
* @appliesMixin window.hassMixins.LocalizeMixin
*/
class HaPersistentNotificationCard extends window.hassMixins.LocalizeMixin(Polymer.Element) {
static get is() { return 'ha-persistent_notification-card'; }
static get properties() {

View File

@ -95,7 +95,9 @@
'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE',
'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'
];
/*
* @appliesMixin window.hassMixins.LocalizeMixin
*/
class HaWeatherCard extends window.hassMixins.LocalizeMixin(Polymer.Element) {
static get is() { return 'ha-weather-card'; }
static get properties() {
@ -105,6 +107,9 @@
type: Object,
observer: 'checkRequirements'
},
attr: Object,
windBearing: Object,
nowCond: Object,
};
}

View File

@ -151,6 +151,21 @@
value: false,
readOnly: true,
},
metas: {
type: Array,
value: () => [],
},
tooltip: {
type: Object,
value: () => ({
opacity: '0',
left: '0',
top: '0',
xPadding: '0',
yPadding: '0'
})
},
unit: Object,
};
}
@ -161,13 +176,6 @@
connectedCallback() {
super.connectedCallback();
this._isAttached = true;
this.set('tooltip', {
opacity: '0',
left: '0',
top: '0',
xPadding: '0',
yPadding: '0'
});
this.onPropsChange();
this._resizeListener = () => {
this._debouncer = Polymer.Debouncer.debounce(
@ -275,11 +283,11 @@
}
positionX += this._chart.canvas.offsetLeft;
// Display, position, and set styles for font
this.set(['tooltip', 'opacity'], 1);
this.set(['tooltip', 'left'], positionX + 'px');
this.set(['tooltip', 'top'], positionY + 'px');
this.set(['tooltip', 'yPadding'], tooltip.yPadding);
this.set(['tooltip', 'xPadding'], tooltip.xPadding);
this.tooltip = Object.assign({}, this.tooltip, {
opacity: 1,
left: `${positionX}px`,
top: `${positionY}px`,
});
}
_legendClick(event) {
@ -320,7 +328,7 @@
if (updateNeeded) {
chart.update();
}
this.set('unit', this.data.unit);
this.unit = this.data.unit;
}
_formatTickValue(value, index, values) {
if (values.length === 0) {

View File

@ -2,6 +2,8 @@
<link rel="import" href="../../../bower_components/vaadin-combo-box/vaadin-combo-box-light.html">
<link rel="import" href="../../../bower_components/paper-item/paper-icon-item.html">
<link rel="import" href="../../../bower_components/paper-item/paper-item-body.html">
<link rel="import" href="../../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../../bower_components/paper-input/paper-input.html">
<link rel='import' href='../../../src/util/hass-mixins.html'>

View File

@ -67,8 +67,7 @@
<template is='dom-repeat' items='[[cards.columns]]' as='column'>
<div class='column flex-1'>
<template is='dom-repeat' items='[[column]]' as='card'>
<ha-card-chooser card-data='[[card]]' hass='[[hass]]'
></ha-card-chooser>
<ha-card-chooser card-data='[[card]]'></ha-card-chooser>
</template>
</div>
</template>

View File

@ -1,6 +1,8 @@
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/vaadin-combo-box/vaadin-combo-box-light.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../bower_components/paper-input/paper-input.html">
<dom-module id="ha-combo-box">
<template>

View File

@ -1,9 +1,23 @@
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel='import' href='../util/hass-mixins.html'>
<script>
class HaMarkdown extends window.hassMixins.EventsMixin(HTMLElement) {
/*
* @appliesMixin window.hassMixins.EventsMixin
*/
class HaMarkdown extends window.hassMixins.EventsMixin(Polymer.Element) {
static get is() { return 'ha-markdown'; }
static get properties() {
return {
content: {
type: String,
observer: '_render',
}
};
}
connectedCallback() {
// 0 = not loaded, 1 = success, 2 = error
this._scriptLoaded = 0;
@ -17,11 +31,6 @@ class HaMarkdown extends window.hassMixins.EventsMixin(HTMLElement) {
);
}
set content(value) {
this._content = value;
this._render();
}
_render() {
if (this._scriptLoaded === 0 || this._renderScheduled) return;

View File

@ -26,6 +26,7 @@ class StateHistoryChartLine extends Polymer.Element {
static get is() { return 'state-history-chart-line'; }
static get properties() {
return {
chartData: Object,
data: Object,
unit: String,
identifier: String,

View File

@ -31,6 +31,7 @@ class StateHistoryChartTimeline extends Polymer.Element {
hass: {
type: Object,
},
chartData: Object,
data: {
type: Object,
observer: 'dataChanged',

View File

@ -90,7 +90,7 @@ class HaMoreInfoDialog extends window.hassMixins.DialogMixin(Polymer.Element) {
large: {
type: Boolean,
reflectToAttribute: true,
observer: 'notifyResize',
observer: '_largeChanged',
},
_dialogElement: Object,
@ -160,6 +160,10 @@ class HaMoreInfoDialog extends window.hassMixins.DialogMixin(Polymer.Element) {
_equals(a, b) {
return a === b;
}
_largeChanged() {
this.notifyResize();
}
}
customElements.define(HaMoreInfoDialog.is, HaMoreInfoDialog);
</script>

View File

@ -5,6 +5,7 @@
<link rel='import' href='../../../../bower_components/paper-slider/paper-slider.html'>
<link rel='import' href='../../../util/cover-model.html'>
<link rel='import' href='../../../components/ha-cover-tilt-controls.html'>
<dom-module id='more-info-cover'>
<template>

View File

@ -39,6 +39,7 @@ class MoreInfoLock extends Polymer.Element {
type: String,
value: '',
},
isLocked: Boolean,
};
}

View File

@ -2,6 +2,7 @@
<link rel="import" href="../../../bower_components/app-layout/app-toolbar/app-toolbar.html">
<link rel="import" href="../../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../../bower_components/paper-input/paper-input.html">
<link rel="import" href="../../../bower_components/paper-button/paper-button.html">
<link rel='import' href='../../util/hass-mixins.html'>

View File

@ -5,6 +5,8 @@
<link rel="import" href="../../bower_components/app-layout/app-toolbar/app-toolbar.html">
<link rel="import" href="../components/ha-menu-button.html">
<dom-module id='hass-loading-screen'>
<template>
<style include='iron-flex ha-style'>

View File

@ -34,6 +34,9 @@
</dom-module>
<script>
/*
* @appliesMixin window.hassMixins.LocalizeMixin
*/
class StateCardDisplay extends window.hassMixins.LocalizeMixin(Polymer.Element) {
static get is() { return 'state-card-display'; }

View File

@ -3,6 +3,7 @@
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../components/entity/state-info.html">
<link rel="import" href="../util/hass-mixins.html">
<dom-module id="state-card-media_player">
<template>
@ -46,6 +47,9 @@
</dom-module>
<script>
/*
* @appliesMixin window.hassMixins.LocalizeMixin
*/
class StateCardMediaPlayer extends window.hassMixins.LocalizeMixin(Polymer.Element) {
static get is() { return 'state-card-media_player'; }

View File

@ -42,6 +42,7 @@ class StateCardScript extends Polymer.Element {
static get properties() {
return {
hass: Object,
stateObj: Object,
inDialog: {
type: Boolean,

View File

@ -19,7 +19,7 @@
}
</style>
<state-badge state-obj='[[stateObj]]' in-dialog='[[inDialog]]'></state-badge>
<state-badge state-obj='[[stateObj]]'></state-badge>
<a href$='[[stateObj.state]]' target='_blank' class='name' id='link'>[[computeStateName(stateObj)]]</a>
</template>
</dom-module>