Update eslint config

This commit is contained in:
Paulus Schoutsen 2016-04-28 16:19:27 +02:00
parent 11311809c1
commit 3af16b2650
8 changed files with 40 additions and 46 deletions

View File

@ -1,5 +1,5 @@
{ {
"extends": "airbnb/base", "extends": "airbnb-base",
"globals": { "globals": {
"__DEV__": false, "__DEV__": false,
"__DEMO__": false "__DEMO__": false

View File

@ -31,8 +31,9 @@
"bower": "^1.7.9", "bower": "^1.7.9",
"classnames": "^2.2.3", "classnames": "^2.2.3",
"eslint": "^2.8.0", "eslint": "^2.8.0",
"eslint-config-airbnb": "^7.0.0",
"html-minifier": "^1.5.0", "html-minifier": "^1.5.0",
"eslint-config-airbnb-base": "^1.0.4",
"eslint-plugin-import": "^1.6.1",
"vulcanize": "^1.14.8", "vulcanize": "^1.14.8",
"webpack": "^1.13" "webpack": "^1.13"
} }

View File

@ -41,9 +41,9 @@ export default new Polymer({
const newVal = ev.target.checked; const newVal = ev.target.checked;
if (newVal && !this.isOn) { if (newVal && !this.isOn) {
this._call_service(true); this.callService(true);
} else if (!newVal && this.isOn) { } else if (!newVal && this.isOn) {
this._call_service(false); this.callService(false);
} }
}, },
@ -59,11 +59,11 @@ export default new Polymer({
}, },
turnOn() { turnOn() {
this._call_service(true); this.callService(true);
}, },
turnOff() { turnOff() {
this._call_service(false); this.callService(false);
}, },
computeIsOn(stateObj) { computeIsOn(stateObj) {
@ -74,7 +74,7 @@ export default new Polymer({
// with the state. It will be out of sync if our service call did not // with the state. It will be out of sync if our service call did not
// result in the entity to be turned on. Since the state is not changing, // result in the entity to be turned on. Since the state is not changing,
// the resync is not called automatic. // the resync is not called automatic.
_call_service(turnOn) { callService(turnOn) {
let domain; let domain;
let service; let service;

View File

@ -53,25 +53,25 @@
<template> <template>
<div class='main'> <div class='main'>
<template is='dom-if' if='[[cards._badges]]'> <template is='dom-if' if='[[cards.badges]]'>
<div class='badges'> <div class='badges'>
<template is='dom-if' if='[[cards._demo]]'> <template is='dom-if' if='[[cards.demo]]'>
<ha-demo-badge></ha-demo-badge> <ha-demo-badge></ha-demo-badge>
</template> </template>
<ha-badges-card states='[[cards._badges]]'></ha-badges-card> <ha-badges-card states='[[cards.badges]]'></ha-badges-card>
</div> </div>
</template> </template>
<template is='dom-if' if='[[!cards._badges]]'> <template is='dom-if' if='[[!cards.badges]]'>
<div class='no-badges'> </div> <div class='no-badges'> </div>
</template> </template>
<div class='horizontal layout center-justified'> <div class='horizontal layout center-justified'>
<template is='dom-repeat' items='[[cards._columns]]' as='column'> <template is='dom-repeat' items='[[cards.columns]]' as='column'>
<div class='column flex-1'> <div class='column flex-1'>
<template is='dom-repeat' items='[[column]]' as='card'> <template is='dom-repeat' items='[[column]]' as='card'>
<div class='zone-card'> <div class='zone-card'>
<ha-card-chooser card-data='[[computeCardDataOfCard(cards, card)]]' <ha-card-chooser card-data='[[card]]'
></ha-card-chooser> ></ha-card-chooser>
</div> </div>
</template> </template>

View File

@ -76,13 +76,13 @@ export default new Polymer({
const hasGroup = {}; const hasGroup = {};
const cards = { const cards = {
_demo: false, demo: false,
_badges: [], badges: [],
_columns: [], columns: [],
}; };
const entityCount = []; const entityCount = [];
for (let idx = 0; idx < columns; idx++) { for (let idx = 0; idx < columns; idx++) {
cards._columns.push([]); cards.columns.push([]);
entityCount.push(0); entityCount.push(0);
} }
@ -108,11 +108,10 @@ export default new Polymer({
return minIndex; return minIndex;
} }
if (showIntroduction) { if (showIntroduction) {
cards._columns[getIndex(5)].push('ha-introduction'); cards.columns[getIndex(5)].push({
cards['ha-introduction'] = {
cardType: 'introduction', cardType: 'introduction',
showHideInstruction: states.size > 0 && !__DEMO__, showHideInstruction: states.size > 0 && !__DEMO__,
}; });
} }
function addEntitiesCard(name, entities, groupEntity = false) { function addEntitiesCard(name, entities, groupEntity = false) {
@ -139,35 +138,33 @@ export default new Polymer({
const curIndex = getIndex(size); const curIndex = getIndex(size);
if (other.length > 0) { if (other.length > 0) {
cards._columns[curIndex].push(name); cards.columns[curIndex].push({
cards[name] = {
cardType: 'entities', cardType: 'entities',
states: other, states: other,
groupEntity, groupEntity,
}; });
} }
owncard.forEach(entity => { owncard.forEach(entity => {
cards._columns[curIndex].push(entity.entityId); cards.columns[curIndex].push({
cards[entity.entityId] = {
cardType: entity.domain, cardType: entity.domain,
stateObj: entity, stateObj: entity,
}; });
}); });
} }
byDomain.keySeq().sortBy(domain => getPriority(domain)) byDomain.keySeq().sortBy(domain => getPriority(domain))
.forEach(domain => { .forEach(domain => {
if (domain === 'a') { if (domain === 'a') {
cards._demo = true; cards.demo = true;
return; return;
} }
const priority = getPriority(domain); const priority = getPriority(domain);
if (priority >= 0 && priority < 10) { if (priority >= 0 && priority < 10) {
cards._badges.push.apply( cards.badges.push.apply(
cards._badges, filterGrouped(byDomain.get(domain)).sortBy( cards.badges, filterGrouped(byDomain.get(domain)).sortBy(
entitySortBy).toArray()); entitySortBy).toArray());
} else if (domain === 'group') { } else if (domain === 'group') {
byDomain.get(domain).sortBy(entitySortBy) byDomain.get(domain).sortBy(entitySortBy)
@ -185,12 +182,8 @@ export default new Polymer({
); );
// Remove empty columns // Remove empty columns
cards._columns = cards._columns.filter(val => val.length > 0); cards.columns = cards.columns.filter(val => val.length > 0);
return cards; return cards;
}, },
computeCardDataOfCard(cards, card) {
return cards[card];
},
}); });

View File

@ -35,11 +35,11 @@ export default new Polymer({
}, },
attached() { attached() {
this._interval = setInterval(this.updateRelative, UPDATE_INTERVAL); this.updateInterval = setInterval(this.updateRelative, UPDATE_INTERVAL);
}, },
detached() { detached() {
clearInterval(this._interval); clearInterval(this.updateInterval);
}, },
datetimeChanged(newVal) { datetimeChanged(newVal) {

View File

@ -39,10 +39,10 @@ export default new Polymer({
isLoadingHistoryData: { isLoadingHistoryData: {
type: Boolean, type: Boolean,
computed: 'computeIsLoadingHistoryData(_delayedDialogOpen, _isLoadingHistoryData)', computed: 'computeIsLoadingHistoryData(delayedDialogOpen, isLoadingEntityHistoryData)',
}, },
_isLoadingHistoryData: { isLoadingEntityHistoryData: {
type: Boolean, type: Boolean,
bindNuclear: entityHistoryGetters.isLoadingEntityHistory, bindNuclear: entityHistoryGetters.isLoadingEntityHistory,
}, },
@ -71,7 +71,7 @@ export default new Polymer({
observer: 'dialogOpenChanged', observer: 'dialogOpenChanged',
}, },
_delayedDialogOpen: { delayedDialogOpen: {
type: Boolean, type: Boolean,
value: false, value: false,
}, },
@ -83,8 +83,8 @@ export default new Polymer({
* before the dialog is attached to the screen and is unable to determine * before the dialog is attached to the screen and is unable to determine
* graph size resulting in scroll bars. * graph size resulting in scroll bars.
*/ */
computeIsLoadingHistoryData(_delayedDialogOpen, _isLoadingHistoryData) { computeIsLoadingHistoryData(delayedDialogOpen, isLoadingEntityHistoryData) {
return !_delayedDialogOpen || _isLoadingHistoryData; return !delayedDialogOpen || isLoadingEntityHistoryData;
}, },
computeShowHistoryComponent(hasHistoryComponent, stateObj) { computeShowHistoryComponent(hasHistoryComponent, stateObj) {
@ -116,10 +116,10 @@ export default new Polymer({
dialogOpenChanged(newVal) { dialogOpenChanged(newVal) {
if (newVal) { if (newVal) {
this.async(() => { this._delayedDialogOpen = true; }, 10); this.async(() => { this.delayedDialogOpen = true; }, 10);
} else if (!newVal && this.stateObj) { } else if (!newVal && this.stateObj) {
this.async(() => moreInfoActions.deselectEntity(), 10); this.async(() => moreInfoActions.deselectEntity(), 10);
this._delayedDialogOpen = false; this.delayedDialogOpen = false;
} }
}, },
}); });

View File

@ -2,7 +2,7 @@ export default function NuclearObserver(reactor) {
return { return {
attached() { attached() {
this.__unwatchFns = Object.keys(this.properties).reduce( this.nuclearUnwatchFns = Object.keys(this.properties).reduce(
(unwatchFns, key) => { (unwatchFns, key) => {
if (!('bindNuclear' in this.properties[key])) { if (!('bindNuclear' in this.properties[key])) {
return unwatchFns; return unwatchFns;
@ -20,8 +20,8 @@ export default function NuclearObserver(reactor) {
}, },
detached() { detached() {
while (this.__unwatchFns.length) { while (this.nuclearUnwatchFns.length) {
this.__unwatchFns.shift()(); this.nuclearUnwatchFns.shift()();
} }
}, },