Linting upgrade

This commit is contained in:
Paulus Schoutsen 2015-10-16 00:12:29 -07:00
parent c91fcccf29
commit b72f3836cf
15 changed files with 56 additions and 50 deletions

View File

@ -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"
}
}

View File

@ -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,
};
},

View File

@ -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');
}
}
},

View File

@ -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));

View File

@ -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' });

View File

@ -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,
});

View File

@ -1,3 +1,4 @@
import Polymer from '../polymer';
import {
navigationActions,
navigationGetters,

View File

@ -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,
});

View File

@ -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,
});

View File

@ -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;

View File

@ -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)`);

View File

@ -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() : [];
},
});

View File

@ -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) {

View File

@ -1,3 +1,4 @@
import Polymer from '../polymer';
import { serviceActions } from '../util/home-assistant-js-instance';
export default new Polymer({

View File

@ -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 */