Fix a whole bunch of eslint errors

These apparently were silent until 92c532d mass-upgraded deps.
Apparently eslint returned status 0 despite errors before and now
returns 1.

Most of these were handled by its "--fix" option; I manually took care
of the remaining two:

/Users/slamb/git/moonfire-nvr/ui-src/lib/views/RecordingsView.js
  140:1  error  This line has a length of 82. Maximum allowed is 80  max-len

/Users/slamb/git/moonfire-nvr/ui-src/lib/views/StreamSelectorView.js
  72:1  error  This line has a length of 82. Maximum allowed is 80  max-len
This commit is contained in:
Scott Lamb 2020-03-01 22:26:26 -08:00
parent 92c532db3e
commit aa25a85477
15 changed files with 154 additions and 152 deletions

View File

@ -72,7 +72,7 @@ let loginDialog = null;
* *
* @type {String} * @type {String}
*/ */
let timeFmt = 'YYYY-MM-DD HH:mm:ss'; const timeFmt = 'YYYY-MM-DD HH:mm:ss';
/** /**
* Currently active time formatter. * Currently active time formatter.
@ -164,8 +164,8 @@ function fetch(selectedRange, videoLength) {
' to ' + ' to ' +
selectedRange.formatTimeStamp90k(selectedRange.endTime90k) selectedRange.formatTimeStamp90k(selectedRange.endTime90k)
); );
for (let streamView of streamViews) { for (const streamView of streamViews) {
let url = api.recordingsUrl( const url = api.recordingsUrl(
streamView.camera.uuid, streamView.camera.uuid,
streamView.streamType, streamView.streamType,
selectedRange.startTime90k, selectedRange.startTime90k,
@ -181,7 +181,7 @@ function fetch(selectedRange, videoLength) {
streamView.recordingsReq.abort(); streamView.recordingsReq.abort();
} }
streamView.delayedShowLoading(500); streamView.delayedShowLoading(500);
let r = api.request(url); const r = api.request(url);
streamView.recordingsUrl = url; streamView.recordingsUrl = url;
streamView.recordingsReq = r; streamView.recordingsReq = r;
streamView.recordingsRange = selectedRange.range90k(); streamView.recordingsRange = selectedRange.range90k();
@ -213,14 +213,14 @@ function fetch(selectedRange, videoLength) {
* or null. * or null.
*/ */
function updateSession(session) { function updateSession(session) {
let sessionBar = $('#session'); const sessionBar = $('#session');
sessionBar.empty(); sessionBar.empty();
if (session === null || session === undefined) { if (session === null || session === undefined) {
sessionBar.hide(); sessionBar.hide();
return; return;
} }
sessionBar.append($('<span id="session-username" />').text(session.username)); sessionBar.append($('<span id="session-username" />').text(session.username));
let logout = $('<a>logout</a>'); const logout = $('<a>logout</a>');
logout.click(() => { logout.click(() => {
api api
.logout(session.csrf) .logout(session.csrf)
@ -274,10 +274,10 @@ function onReceivedTopLevel(data) {
videos.empty(); videos.empty();
streamViews = []; streamViews = [];
let streamSelectorCameras = []; const streamSelectorCameras = [];
for (const cameraJson of data.cameras) { for (const cameraJson of data.cameras) {
const camera = new Camera(cameraJson); const camera = new Camera(cameraJson);
let cameraStreams = {}; const cameraStreams = {};
Object.keys(camera.streams).forEach((streamType) => { Object.keys(camera.streams).forEach((streamType) => {
const sv = new StreamView( const sv = new StreamView(
camera, camera,
@ -321,10 +321,10 @@ function sendLoginRequest() {
return; return;
} }
let username = $('#login-username').val(); const username = $('#login-username').val();
let password = $('#login-password').val(); const password = $('#login-password').val();
let submit = $('#login-submit'); const submit = $('#login-submit');
let error = $('#login-error'); const error = $('#login-error');
error.empty(); error.empty();
error.removeClass('ui-state-highlight'); error.removeClass('ui-state-highlight');

View File

@ -138,9 +138,9 @@ export default class CalendarTSRange {
* @return {Range90k} Range object or null if don't have start and end * @return {Range90k} Range object or null if don't have start and end
*/ */
range90k() { range90k() {
return this.hasRange() return this.hasRange() ?
? new Range90k(this.startTime90k, this.endTime90k) new Range90k(this.startTime90k, this.endTime90k) :
: null; null;
} }
/** /**

View File

@ -37,7 +37,7 @@ import Range from './Range';
* *
* @type {WeakMap} * @type {WeakMap}
*/ */
let _range = new WeakMap(); const _range = new WeakMap();
/** /**
* Class like Range to represent ranges over timestamps in 90k format. * Class like Range to represent ranges over timestamps in 90k format.

View File

@ -102,7 +102,7 @@ export default class Recording {
* @return {Range90k} Resulting range * @return {Range90k} Resulting range
*/ */
range90k(trimmedAgainst = null) { range90k(trimmedAgainst = null) {
let result = new Range90k(this.startTime90k, this.endTime90k); const result = new Range90k(this.startTime90k, this.endTime90k);
return trimmedAgainst ? result.trimmed(trimmedAgainst) : result; return trimmedAgainst ? result.trimmed(trimmedAgainst) : result;
} }
/** /**

View File

@ -106,7 +106,7 @@ export default class TimeFormatter {
let format = this._formatStr; let format = this._formatStr;
const ms = ts90k / 90.0; const ms = ts90k / 90.0;
const fracFmt = 'FFFFF'; const fracFmt = 'FFFFF';
let fracLoc = format.indexOf(fracFmt); const fracLoc = format.indexOf(fracFmt);
if (fracLoc != -1) { if (fracLoc != -1) {
const frac = ts90k % 90000; const frac = ts90k % 90000;
format = format =

View File

@ -70,7 +70,7 @@ export default class TimeStamp90kFormatter {
formatSameDayShortened(ts1, ts2) { formatSameDayShortened(ts1, ts2) {
let ts1Formatted = this.formatTimeStamp90k(ts1); let ts1Formatted = this.formatTimeStamp90k(ts1);
let ts2Formatted = this.formatTimeStamp90k(ts2); let ts2Formatted = this.formatTimeStamp90k(ts2);
let timePos = this._formatter.formatStr.indexOf('T'); const timePos = this._formatter.formatStr.indexOf('T');
if (timePos != -1) { if (timePos != -1) {
const datePortion = ts1Formatted.substr(0, timePos); const datePortion = ts1Formatted.substr(0, timePos);
ts1Formatted = datePortion + ' ' + ts1Formatted.substr(timePos + 1); ts1Formatted = datePortion + ' ' + ts1Formatted.substr(timePos + 1);

View File

@ -161,7 +161,7 @@ export default class CalendarView {
const fromPickerView = this._fromPickerView; const fromPickerView = this._fromPickerView;
const toPickerView = this._toPickerView; const toPickerView = this._toPickerView;
const beforeShowDay = function(date) { const beforeShowDay = function(date) {
let dateStr = date.toISOString().substr(0, 10); const dateStr = date.toISOString().substr(0, 10);
return [dateSet.has(dateStr), '', '']; return [dateSet.has(dateStr), '', ''];
}; };
@ -226,9 +226,9 @@ export default class CalendarView {
const pickerElement = event.currentTarget; const pickerElement = event.currentTarget;
const newTimeStr = pickerElement.value; const newTimeStr = pickerElement.value;
const selectedRange = this._selectedRange; const selectedRange = this._selectedRange;
const parsedTS = isEnd const parsedTS = isEnd ?
? selectedRange.setEndTime(newTimeStr) selectedRange.setEndTime(newTimeStr) :
: selectedRange.setStartTime(newTimeStr); selectedRange.setStartTime(newTimeStr);
if (parsedTS === null) { if (parsedTS === null) {
console.warn('bad time change'); console.warn('bad time change');
$(pickerElement).addClass('ui-state-error'); $(pickerElement).addClass('ui-state-error');
@ -261,9 +261,9 @@ export default class CalendarView {
* changes. We need to determine a new selected range and activiate it. * changes. We need to determine a new selected range and activiate it.
* Doing so will then also inform the change listener. * Doing so will then also inform the change listener.
*/ */
const endDate = isSameDay const endDate = isSameDay ?
? this.selectedRange.start.dateStr this.selectedRange.start.dateStr :
: this.selectedRange.end.dateStr; this.selectedRange.end.dateStr;
this._updateRangeDates(this.selectedRange.start.dateStr, endDate); this._updateRangeDates(this.selectedRange.start.dateStr, endDate);
this._sameDay = isSameDay; this._sameDay = isSameDay;

View File

@ -83,9 +83,9 @@ export default class DatePickerView {
_initWithOptions(options = null) { _initWithOptions(options = null) {
this._alive = true; this._alive = true;
options = options =
options !== null options !== null ?
? options options :
: { {
disabled: true, disabled: true,
}; };
this._pickerElement.datepicker(options); this._pickerElement.datepicker(options);

View File

@ -137,7 +137,7 @@ export default class RecordingsView {
const values = this._formatter.format(recordings[rowIndex], trimRange); const values = this._formatter.format(recordings[rowIndex], trimRange);
$(row) $(row)
.children('td') .children('td')
.each((index, element) => $(element).text(values[_columnOrder[index]])); .each((i, e) => $(e).text(values[_columnOrder[i]]));
}); });
} }
@ -269,7 +269,7 @@ export default class RecordingsView {
// Remove existing rows, replace with new ones // Remove existing rows, replace with new ones
$('tr.r', tbody).remove(); $('tr.r', tbody).remove();
this._recordings.forEach((r) => { this._recordings.forEach((r) => {
let row = $('<tr class="r" />'); const row = $('<tr class="r" />');
row.append(_columnOrder.map(() => $('<td/>'))); row.append(_columnOrder.map(() => $('<td/>')));
row.on('click', () => { row.on('click', () => {
console.log('Video clicked'); console.log('Video clicked');

View File

@ -53,7 +53,7 @@ export default class StreamSelectorView {
if (cameras.length !== 0) { if (cameras.length !== 0) {
// Add a header row. // Add a header row.
let hdr = $('<tr/>').append($('<th/>')); const hdr = $('<tr/>').append($('<th/>'));
for (const streamType of allStreamTypes) { for (const streamType of allStreamTypes) {
hdr.append($('<th/>').text(streamType)); hdr.append($('<th/>').text(streamType));
} }
@ -61,7 +61,7 @@ export default class StreamSelectorView {
} }
this._cameras.forEach((c) => { this._cameras.forEach((c) => {
let row = $('<tr/>').append($('<td>').text(c.camera.shortName)); const row = $('<tr/>').append($('<td>').text(c.camera.shortName));
let firstStreamType = true; let firstStreamType = true;
for (const streamType of allStreamTypes) { for (const streamType of allStreamTypes) {
const streamView = c.streamViews[streamType]; const streamView = c.streamViews[streamType];
@ -69,7 +69,9 @@ export default class StreamSelectorView {
row.append('<td/>'); row.append('<td/>');
} else { } else {
const id = 'cam-' + c.camera.uuid + '-' + streamType; const id = 'cam-' + c.camera.uuid + '-' + streamType;
let cb = $('<input type="checkbox">').attr('name', id).attr('id', id); const cb = $('<input type="checkbox">')
.attr('name', id)
.attr('id', id);
// Only the first stream type for each camera should be checked // Only the first stream type for each camera should be checked
// initially. // initially.