diff --git a/package.json b/package.json index 4e9d3ce9f2..72bc2b6ae8 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,10 @@ "name": "home-assistant-polymer", "version": "1.0.0", "description": "A frontend for Home Assistant using the Polymer framework", + "repository": { + "type": "git", + "url": "https://github.com/balloob/home-assistant-polymer" + }, "scripts": { "js_dev": "webpack --colors --progress -d --watch", "js_dev_demo": "BUILD_DEMO=1 webpack --colors --progress -d --watch", @@ -25,11 +29,11 @@ "babel-eslint": "^4.1.3", "babel-loader": "^5.3.2", "bower": "^1.5.2", - "eslint": "^1.5.0", - "eslint-config-airbnb": "0.0.8", - "eslint-plugin-react": "^3.4.2", "html-minifier": "^0.7.2", "vulcanize": "^1.10.4", + "eslint": "^1.6.0", + "eslint-config-airbnb": "0.1.0", + "eslint-plugin-react": "^3.5.1", "webpack": "^1.12.2" } } diff --git a/src/components/ha-color-picker.js b/src/components/ha-color-picker.js index 3a87d8fa99..9ca85da3fc 100644 --- a/src/components/ha-color-picker.js +++ b/src/components/ha-color-picker.js @@ -11,8 +11,8 @@ import Polymer from '../polymer'; * given red, green, blue values, return the equivalent hexidecimal value * base source: http://stackoverflow.com/a/5624139 */ -function componentToHex(c) { - const hex = c.toString(16); +function componentToHex(comp) { + const hex = comp.toString(16); return hex.length === 1 ? '0' + hex : hex; } @@ -46,8 +46,8 @@ export default new Polymer({ 'tap': 'onTap', }, - onMouseDown(e) { - this.onMouseMove(e); + onMouseDown(ev) { + this.onMouseMove(ev); this.addEventListener('mousemove', this.onMouseMove); }, @@ -55,8 +55,8 @@ export default new Polymer({ this.removeEventListener('mousemove', this.onMouseMove); }, - onTouchStart(e) { - this.onTouchMove(e); + onTouchStart(ev) { + this.onTouchMove(ev); this.addEventListener('touchmove', this.onTouchMove); }, @@ -64,27 +64,27 @@ export default new Polymer({ this.removeEventListener('touchmove', this.onTouchMove); }, - onTap(e) { - e.stopPropagation(); + onTap(ev) { + ev.stopPropagation(); }, - onTouchMove(e) { - const touch = e.touches[0]; - this.onColorSelect(e, {x: touch.clientX, y: touch.clientY}); + onTouchMove(ev) { + const touch = ev.touches[0]; + this.onColorSelect(ev, {x: touch.clientX, y: touch.clientY}); }, - onMouseMove(e) { - e.preventDefault(); + onMouseMove(ev) { + ev.preventDefault(); if (this.mouseMoveIsThrottled) { this.mouseMoveIsThrottled = false; - this.onColorSelect(e); + this.onColorSelect(ev); this.async(() => this.mouseMoveIsThrottled = true, 100); } }, - onColorSelect(e, coords) { + onColorSelect(ev, coords) { if (this.context) { - const colorCoords = coords || this.relativeMouseCoordinates(e); + const colorCoords = coords || this.relativeMouseCoordinates(ev); const data = this.context.getImageData(colorCoords.x, colorCoords.y, 1, 1).data; this.setColor({r: data[0], g: data[1], b: data[2]}); @@ -105,19 +105,19 @@ export default new Polymer({ * given a mouse click event, return x,y coordinates relative to the clicked target * @returns object with x, y values */ - relativeMouseCoordinates(e) { - let x = 0; - let y = 0; + relativeMouseCoordinates(ev) { + let xCoord = 0; + let yCoord = 0; if (this.canvas) { const rect = this.canvas.getBoundingClientRect(); - x = e.clientX - rect.left; - y = e.clientY - rect.top; + xCoord = ev.clientX - rect.left; + yCoord = ev.clientY - rect.top; } return { - x: x, - y: y, + x: xCoord, + y: yCoord, }; }, diff --git a/src/components/ha-sidebar.js b/src/components/ha-sidebar.js index 6f2bf9b050..3a4ae05865 100644 --- a/src/components/ha-sidebar.js +++ b/src/components/ha-sidebar.js @@ -44,11 +44,11 @@ export default new Polymer({ selectedChanged(newVal) { const menuItems = this.querySelectorAll('.menu [data-panel]'); - for (let i = 0; i < menuItems.length; i++) { - if (menuItems[i].getAttribute('data-panel') === newVal) { - menuItems[i].classList.add('selected'); + for (let idx = 0; idx < menuItems.length; idx++) { + if (menuItems[idx].getAttribute('data-panel') === newVal) { + menuItems[idx].classList.add('selected'); } else { - menuItems[i].classList.remove('selected'); + menuItems[idx].classList.remove('selected'); } } }, diff --git a/src/components/ha-zone-cards.js b/src/components/ha-zone-cards.js index 75814fa7c8..6bbf28a3a6 100644 --- a/src/components/ha-zone-cards.js +++ b/src/components/ha-zone-cards.js @@ -62,7 +62,7 @@ export default new Polymer({ _badges: [], _columns: [], }; - for (let i = 0; i < columns; i++) { cards._columns[i] = []; } + for (let idx = 0; idx < columns; idx++) { cards._columns[idx] = []; } function filterGrouped(entities) { return entities.filter(entity => !(entity.entityId in hasGroup)); diff --git a/src/components/state-history-chart-timeline.js b/src/components/state-history-chart-timeline.js index d2c5755b1a..4c7aff9195 100644 --- a/src/components/state-history-chart-timeline.js +++ b/src/components/state-history-chart-timeline.js @@ -39,8 +39,8 @@ export default new Polymer({ return; } - const chart = new google.visualization.Timeline(this); - const dataTable = new google.visualization.DataTable(); + const chart = new window.google.visualization.Timeline(this); + const dataTable = new window.google.visualization.DataTable(); dataTable.addColumn({ type: 'string', id: 'Entity' }); dataTable.addColumn({ type: 'string', id: 'State' }); diff --git a/src/components/state-history-charts.js b/src/components/state-history-charts.js index 11de04ed27..73f4424838 100644 --- a/src/components/state-history-charts.js +++ b/src/components/state-history-charts.js @@ -79,7 +79,7 @@ export default new Polymer({ }, googleApiLoaded() { - google.load('visualization', '1', { + window.google.load('visualization', '1', { packages: ['timeline', 'corechart'], callback: () => this.apiLoaded = true, }); diff --git a/src/layouts/home-assistant-main.js b/src/layouts/home-assistant-main.js index 6b1546502e..27a5d1c3ae 100644 --- a/src/layouts/home-assistant-main.js +++ b/src/layouts/home-assistant-main.js @@ -1,3 +1,4 @@ +import Polymer from '../polymer'; import { navigationActions, navigationGetters, diff --git a/src/layouts/partial-history.js b/src/layouts/partial-history.js index aedd698ed5..7b2b5e7e72 100644 --- a/src/layouts/partial-history.js +++ b/src/layouts/partial-history.js @@ -62,7 +62,7 @@ export default new Polymer({ }, attached() { - this.datePicker = new Pikaday({ + this.datePicker = new window.Pikaday({ field: this.$.datePicker.inputElement, onSelect: entityHistoryActions.changeCurrentDate, }); diff --git a/src/layouts/partial-logbook.js b/src/layouts/partial-logbook.js index 04214290f4..f85588649a 100644 --- a/src/layouts/partial-logbook.js +++ b/src/layouts/partial-logbook.js @@ -67,7 +67,7 @@ export default new Polymer({ }, attached() { - this.datePicker = new Pikaday({ + this.datePicker = new window.Pikaday({ field: this.$.datePicker.inputElement, onSelect: logbookActions.changeCurrentDate, }); diff --git a/src/layouts/partial-map.js b/src/layouts/partial-map.js index 26ad6acf6e..918aee308d 100644 --- a/src/layouts/partial-map.js +++ b/src/layouts/partial-map.js @@ -8,7 +8,7 @@ import nuclearObserver from '../util/bound-nuclear-behavior'; require('../components/entity/ha-entity-marker'); -L.Icon.Default.imagePath = '/static/images/leaflet'; +window.L.Icon.Default.imagePath = '/static/images/leaflet'; export default new Polymer({ is: 'partial-map', @@ -58,7 +58,7 @@ export default new Polymer({ attached() { // On iPhone 5, 5s and some 6 I have observed that the user would be // unable to pan on initial load. This fixes it. - if (L.Browser.mobileWebkit) { + if (window.L.Browser.mobileWebkit) { this.async(() => { const map = this.$.map; const prev = map.style.display; diff --git a/src/layouts/partial-zone.js b/src/layouts/partial-zone.js index 2d0adcb6a9..90dc73ab10 100644 --- a/src/layouts/partial-zone.js +++ b/src/layouts/partial-zone.js @@ -88,8 +88,8 @@ export default new Polymer({ created() { this.windowChange = this.windowChange.bind(this); const sizes = []; - for (let i = 0; i < 5; i++) { - sizes.push(278 + i * 278); + for (let col = 0; col < 5; col++) { + sizes.push(278 + col * 278); } this.mqls = sizes.map(width => { const mql = window.matchMedia(`(min-width: ${width}px)`); diff --git a/src/more-infos/more-info-group.js b/src/more-infos/more-info-group.js index 9a3ad00162..853a996c71 100644 --- a/src/more-infos/more-info-group.js +++ b/src/more-infos/more-info-group.js @@ -34,10 +34,4 @@ export default new Polymer({ ], }, }, - - - updateStates() { - this.states = this.stateObj && this.stateObj.attributes.entity_id ? - stateStore.gets(this.stateObj.attributes.entity_id).toArray() : []; - }, }); diff --git a/src/more-infos/more-info-sun.js b/src/more-infos/more-info-sun.js index 2053bf7cd0..b733d3c107 100644 --- a/src/more-infos/more-info-sun.js +++ b/src/more-infos/more-info-sun.js @@ -1,3 +1,4 @@ +import Polymer from '../polymer'; import { util } from '../util/home-assistant-js-instance'; import formatTime from '../util/format-time'; @@ -32,7 +33,7 @@ export default new Polymer({ }, computeOrder(risingDate, settingDate) { - return risingDate > settingDate ? ['set', 'ris'] : ['ris', 'set']; + return risingDate > settingDate ? ['set', 'ris'] : ['ris', 'set']; }, itemCaption(type) { diff --git a/src/more-infos/more-info-updater.js b/src/more-infos/more-info-updater.js index c5dc2d6492..bbcac147f0 100644 --- a/src/more-infos/more-info-updater.js +++ b/src/more-infos/more-info-updater.js @@ -1,3 +1,4 @@ +import Polymer from '../polymer'; import { serviceActions } from '../util/home-assistant-js-instance'; export default new Polymer({ diff --git a/src/util/xybri-to-rgb.js b/src/util/xybri-to-rgb.js index 92baba082f..272d6283ee 100644 --- a/src/util/xybri-to-rgb.js +++ b/src/util/xybri-to-rgb.js @@ -1,4 +1,5 @@ // from http://stackoverflow.com/questions/22894498/philips-hue-convert-xy-from-api-to-hex-or-rgb +/* eslint-disable id-length */ export default function xyBriToRgb(x, y, bri) { const z = 1.0 - x - y; const Y = bri / 255.0; // Brightness of lamp @@ -14,8 +15,12 @@ export default function xyBriToRgb(x, y, bri) { r /= maxValue; g /= maxValue; b /= maxValue; - r = r * 255; if (r < 0) { r = 255; } - g = g * 255; if (g < 0) { g = 255; } - b = b * 255; if (b < 0) { b = 255; } + r = r * 255; + if (r < 0) { r = 255; } + g = g * 255; + if (g < 0) { g = 255; } + b = b * 255; + if (b < 0) { b = 255; } return [r, g, b]; } +/* eslint-enable id-length */