mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Linting upgrade
This commit is contained in:
parent
c91fcccf29
commit
b72f3836cf
10
package.json
10
package.json
@ -2,6 +2,10 @@
|
|||||||
"name": "home-assistant-polymer",
|
"name": "home-assistant-polymer",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A frontend for Home Assistant using the Polymer framework",
|
"description": "A frontend for Home Assistant using the Polymer framework",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/balloob/home-assistant-polymer"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"js_dev": "webpack --colors --progress -d --watch",
|
"js_dev": "webpack --colors --progress -d --watch",
|
||||||
"js_dev_demo": "BUILD_DEMO=1 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-eslint": "^4.1.3",
|
||||||
"babel-loader": "^5.3.2",
|
"babel-loader": "^5.3.2",
|
||||||
"bower": "^1.5.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",
|
"html-minifier": "^0.7.2",
|
||||||
"vulcanize": "^1.10.4",
|
"vulcanize": "^1.10.4",
|
||||||
|
"eslint": "^1.6.0",
|
||||||
|
"eslint-config-airbnb": "0.1.0",
|
||||||
|
"eslint-plugin-react": "^3.5.1",
|
||||||
"webpack": "^1.12.2"
|
"webpack": "^1.12.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import Polymer from '../polymer';
|
|||||||
* given red, green, blue values, return the equivalent hexidecimal value
|
* given red, green, blue values, return the equivalent hexidecimal value
|
||||||
* base source: http://stackoverflow.com/a/5624139
|
* base source: http://stackoverflow.com/a/5624139
|
||||||
*/
|
*/
|
||||||
function componentToHex(c) {
|
function componentToHex(comp) {
|
||||||
const hex = c.toString(16);
|
const hex = comp.toString(16);
|
||||||
return hex.length === 1 ? '0' + hex : hex;
|
return hex.length === 1 ? '0' + hex : hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +46,8 @@ export default new Polymer({
|
|||||||
'tap': 'onTap',
|
'tap': 'onTap',
|
||||||
},
|
},
|
||||||
|
|
||||||
onMouseDown(e) {
|
onMouseDown(ev) {
|
||||||
this.onMouseMove(e);
|
this.onMouseMove(ev);
|
||||||
this.addEventListener('mousemove', this.onMouseMove);
|
this.addEventListener('mousemove', this.onMouseMove);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ export default new Polymer({
|
|||||||
this.removeEventListener('mousemove', this.onMouseMove);
|
this.removeEventListener('mousemove', this.onMouseMove);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTouchStart(e) {
|
onTouchStart(ev) {
|
||||||
this.onTouchMove(e);
|
this.onTouchMove(ev);
|
||||||
this.addEventListener('touchmove', this.onTouchMove);
|
this.addEventListener('touchmove', this.onTouchMove);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -64,27 +64,27 @@ export default new Polymer({
|
|||||||
this.removeEventListener('touchmove', this.onTouchMove);
|
this.removeEventListener('touchmove', this.onTouchMove);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTap(e) {
|
onTap(ev) {
|
||||||
e.stopPropagation();
|
ev.stopPropagation();
|
||||||
},
|
},
|
||||||
|
|
||||||
onTouchMove(e) {
|
onTouchMove(ev) {
|
||||||
const touch = e.touches[0];
|
const touch = ev.touches[0];
|
||||||
this.onColorSelect(e, {x: touch.clientX, y: touch.clientY});
|
this.onColorSelect(ev, {x: touch.clientX, y: touch.clientY});
|
||||||
},
|
},
|
||||||
|
|
||||||
onMouseMove(e) {
|
onMouseMove(ev) {
|
||||||
e.preventDefault();
|
ev.preventDefault();
|
||||||
if (this.mouseMoveIsThrottled) {
|
if (this.mouseMoveIsThrottled) {
|
||||||
this.mouseMoveIsThrottled = false;
|
this.mouseMoveIsThrottled = false;
|
||||||
this.onColorSelect(e);
|
this.onColorSelect(ev);
|
||||||
this.async(() => this.mouseMoveIsThrottled = true, 100);
|
this.async(() => this.mouseMoveIsThrottled = true, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onColorSelect(e, coords) {
|
onColorSelect(ev, coords) {
|
||||||
if (this.context) {
|
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;
|
const data = this.context.getImageData(colorCoords.x, colorCoords.y, 1, 1).data;
|
||||||
|
|
||||||
this.setColor({r: data[0], g: data[1], b: data[2]});
|
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
|
* given a mouse click event, return x,y coordinates relative to the clicked target
|
||||||
* @returns object with x, y values
|
* @returns object with x, y values
|
||||||
*/
|
*/
|
||||||
relativeMouseCoordinates(e) {
|
relativeMouseCoordinates(ev) {
|
||||||
let x = 0;
|
let xCoord = 0;
|
||||||
let y = 0;
|
let yCoord = 0;
|
||||||
|
|
||||||
if (this.canvas) {
|
if (this.canvas) {
|
||||||
const rect = this.canvas.getBoundingClientRect();
|
const rect = this.canvas.getBoundingClientRect();
|
||||||
x = e.clientX - rect.left;
|
xCoord = ev.clientX - rect.left;
|
||||||
y = e.clientY - rect.top;
|
yCoord = ev.clientY - rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: x,
|
x: xCoord,
|
||||||
y: y,
|
y: yCoord,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -44,11 +44,11 @@ export default new Polymer({
|
|||||||
selectedChanged(newVal) {
|
selectedChanged(newVal) {
|
||||||
const menuItems = this.querySelectorAll('.menu [data-panel]');
|
const menuItems = this.querySelectorAll('.menu [data-panel]');
|
||||||
|
|
||||||
for (let i = 0; i < menuItems.length; i++) {
|
for (let idx = 0; idx < menuItems.length; idx++) {
|
||||||
if (menuItems[i].getAttribute('data-panel') === newVal) {
|
if (menuItems[idx].getAttribute('data-panel') === newVal) {
|
||||||
menuItems[i].classList.add('selected');
|
menuItems[idx].classList.add('selected');
|
||||||
} else {
|
} else {
|
||||||
menuItems[i].classList.remove('selected');
|
menuItems[idx].classList.remove('selected');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -62,7 +62,7 @@ export default new Polymer({
|
|||||||
_badges: [],
|
_badges: [],
|
||||||
_columns: [],
|
_columns: [],
|
||||||
};
|
};
|
||||||
for (let i = 0; i < columns; i++) { cards._columns[i] = []; }
|
for (let idx = 0; idx < columns; idx++) { cards._columns[idx] = []; }
|
||||||
|
|
||||||
function filterGrouped(entities) {
|
function filterGrouped(entities) {
|
||||||
return entities.filter(entity => !(entity.entityId in hasGroup));
|
return entities.filter(entity => !(entity.entityId in hasGroup));
|
||||||
|
@ -39,8 +39,8 @@ export default new Polymer({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chart = new google.visualization.Timeline(this);
|
const chart = new window.google.visualization.Timeline(this);
|
||||||
const dataTable = new google.visualization.DataTable();
|
const dataTable = new window.google.visualization.DataTable();
|
||||||
|
|
||||||
dataTable.addColumn({ type: 'string', id: 'Entity' });
|
dataTable.addColumn({ type: 'string', id: 'Entity' });
|
||||||
dataTable.addColumn({ type: 'string', id: 'State' });
|
dataTable.addColumn({ type: 'string', id: 'State' });
|
||||||
|
@ -79,7 +79,7 @@ export default new Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
googleApiLoaded() {
|
googleApiLoaded() {
|
||||||
google.load('visualization', '1', {
|
window.google.load('visualization', '1', {
|
||||||
packages: ['timeline', 'corechart'],
|
packages: ['timeline', 'corechart'],
|
||||||
callback: () => this.apiLoaded = true,
|
callback: () => this.apiLoaded = true,
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Polymer from '../polymer';
|
||||||
import {
|
import {
|
||||||
navigationActions,
|
navigationActions,
|
||||||
navigationGetters,
|
navigationGetters,
|
||||||
|
@ -62,7 +62,7 @@ export default new Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
attached() {
|
attached() {
|
||||||
this.datePicker = new Pikaday({
|
this.datePicker = new window.Pikaday({
|
||||||
field: this.$.datePicker.inputElement,
|
field: this.$.datePicker.inputElement,
|
||||||
onSelect: entityHistoryActions.changeCurrentDate,
|
onSelect: entityHistoryActions.changeCurrentDate,
|
||||||
});
|
});
|
||||||
|
@ -67,7 +67,7 @@ export default new Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
attached() {
|
attached() {
|
||||||
this.datePicker = new Pikaday({
|
this.datePicker = new window.Pikaday({
|
||||||
field: this.$.datePicker.inputElement,
|
field: this.$.datePicker.inputElement,
|
||||||
onSelect: logbookActions.changeCurrentDate,
|
onSelect: logbookActions.changeCurrentDate,
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ import nuclearObserver from '../util/bound-nuclear-behavior';
|
|||||||
|
|
||||||
require('../components/entity/ha-entity-marker');
|
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({
|
export default new Polymer({
|
||||||
is: 'partial-map',
|
is: 'partial-map',
|
||||||
@ -58,7 +58,7 @@ export default new Polymer({
|
|||||||
attached() {
|
attached() {
|
||||||
// On iPhone 5, 5s and some 6 I have observed that the user would be
|
// On iPhone 5, 5s and some 6 I have observed that the user would be
|
||||||
// unable to pan on initial load. This fixes it.
|
// unable to pan on initial load. This fixes it.
|
||||||
if (L.Browser.mobileWebkit) {
|
if (window.L.Browser.mobileWebkit) {
|
||||||
this.async(() => {
|
this.async(() => {
|
||||||
const map = this.$.map;
|
const map = this.$.map;
|
||||||
const prev = map.style.display;
|
const prev = map.style.display;
|
||||||
|
@ -88,8 +88,8 @@ export default new Polymer({
|
|||||||
created() {
|
created() {
|
||||||
this.windowChange = this.windowChange.bind(this);
|
this.windowChange = this.windowChange.bind(this);
|
||||||
const sizes = [];
|
const sizes = [];
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let col = 0; col < 5; col++) {
|
||||||
sizes.push(278 + i * 278);
|
sizes.push(278 + col * 278);
|
||||||
}
|
}
|
||||||
this.mqls = sizes.map(width => {
|
this.mqls = sizes.map(width => {
|
||||||
const mql = window.matchMedia(`(min-width: ${width}px)`);
|
const mql = window.matchMedia(`(min-width: ${width}px)`);
|
||||||
|
@ -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() : [];
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Polymer from '../polymer';
|
||||||
import { util } from '../util/home-assistant-js-instance';
|
import { util } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import formatTime from '../util/format-time';
|
import formatTime from '../util/format-time';
|
||||||
@ -32,7 +33,7 @@ export default new Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
computeOrder(risingDate, settingDate) {
|
computeOrder(risingDate, settingDate) {
|
||||||
return risingDate > settingDate ? ['set', 'ris'] : ['ris', 'set'];
|
return risingDate > settingDate ? ['set', 'ris'] : ['ris', 'set'];
|
||||||
},
|
},
|
||||||
|
|
||||||
itemCaption(type) {
|
itemCaption(type) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Polymer from '../polymer';
|
||||||
import { serviceActions } from '../util/home-assistant-js-instance';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
export default new Polymer({
|
export default new Polymer({
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// from http://stackoverflow.com/questions/22894498/philips-hue-convert-xy-from-api-to-hex-or-rgb
|
// 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) {
|
export default function xyBriToRgb(x, y, bri) {
|
||||||
const z = 1.0 - x - y;
|
const z = 1.0 - x - y;
|
||||||
const Y = bri / 255.0; // Brightness of lamp
|
const Y = bri / 255.0; // Brightness of lamp
|
||||||
@ -14,8 +15,12 @@ export default function xyBriToRgb(x, y, bri) {
|
|||||||
r /= maxValue;
|
r /= maxValue;
|
||||||
g /= maxValue;
|
g /= maxValue;
|
||||||
b /= maxValue;
|
b /= maxValue;
|
||||||
r = r * 255; if (r < 0) { r = 255; }
|
r = r * 255;
|
||||||
g = g * 255; if (g < 0) { g = 255; }
|
if (r < 0) { r = 255; }
|
||||||
b = b * 255; if (b < 0) { b = 255; }
|
g = g * 255;
|
||||||
|
if (g < 0) { g = 255; }
|
||||||
|
b = b * 255;
|
||||||
|
if (b < 0) { b = 255; }
|
||||||
return [r, g, b];
|
return [r, g, b];
|
||||||
}
|
}
|
||||||
|
/* eslint-enable id-length */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user