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

@@ -57,11 +57,11 @@ function minMaxDates(streamViews) {
* have at least one recording available (allDates).
*/
const allDates = new Set(
[].concat(
...streamViews
.filter((v) => v.enabled)
.map((v) => Array.from(v.stream.days.keys()))
)
[].concat(
...streamViews
.filter((v) => v.enabled)
.map((v) => Array.from(v.stream.days.keys()))
)
);
return [
allDates,
@@ -161,7 +161,7 @@ export default class CalendarView {
const fromPickerView = this._fromPickerView;
const toPickerView = this._toPickerView;
const beforeShowDay = function(date) {
let dateStr = date.toISOString().substr(0, 10);
const dateStr = date.toISOString().substr(0, 10);
return [dateSet.has(dateStr), '', ''];
};
@@ -226,9 +226,9 @@ export default class CalendarView {
const pickerElement = event.currentTarget;
const newTimeStr = pickerElement.value;
const selectedRange = this._selectedRange;
const parsedTS = isEnd
? selectedRange.setEndTime(newTimeStr)
: selectedRange.setStartTime(newTimeStr);
const parsedTS = isEnd ?
selectedRange.setEndTime(newTimeStr) :
selectedRange.setStartTime(newTimeStr);
if (parsedTS === null) {
console.warn('bad time change');
$(pickerElement).addClass('ui-state-error');
@@ -236,7 +236,7 @@ export default class CalendarView {
}
$(pickerElement).removeClass('ui-state-error');
console.log(
(isEnd ? 'End' : 'Start') +
(isEnd ? 'End' : 'Start') +
' time changed to: ' +
parsedTS +
' (' +
@@ -261,9 +261,9 @@ export default class CalendarView {
* changes. We need to determine a new selected range and activiate it.
* Doing so will then also inform the change listener.
*/
const endDate = isSameDay
? this.selectedRange.start.dateStr
: this.selectedRange.end.dateStr;
const endDate = isSameDay ?
this.selectedRange.start.dateStr :
this.selectedRange.end.dateStr;
this._updateRangeDates(this.selectedRange.start.dateStr, endDate);
this._sameDay = isSameDay;
@@ -334,7 +334,7 @@ export default class CalendarView {
initializeWith(streamViews) {
this._streamViews = streamViews;
[this._availableDates, this._minDateStr, this._maxDateStr] = minMaxDates(
streamViews
streamViews
);
this._configureDatePickers();

View File

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

View File

@@ -79,7 +79,7 @@ export default class RecordingsView {
* @param {jQuery} parent Parent to which new DOM is attached, or null
*/
constructor(camera, streamType, recordingFormatter, trimmed = false,
parent = null) {
parent = null) {
this._cameraName = camera.shortName;
this._cameraRange = camera.range90k;
this._formatter = recordingFormatter;
@@ -107,17 +107,17 @@ export default class RecordingsView {
_createElement(id, cameraName, streamType) {
const tab = $('<tbody>').attr('id', id);
tab.append(
$('<tr class="name">').append($('<th colspan=6/>')
.text(cameraName + ' ' + streamType)),
$('<tr class="hdr">').append(
$(
_columnOrder
.map((name) => '<th>' + _columnLabels[name] + '</th>')
.join('')
)
),
$('</tr>'),
$('<tr class="loading"><td colspan=6>loading...</td></tr>').hide()
$('<tr class="name">').append($('<th colspan=6/>')
.text(cameraName + ' ' + streamType)),
$('<tr class="hdr">').append(
$(
_columnOrder
.map((name) => '<th>' + _columnLabels[name] + '</th>')
.join('')
)
),
$('</tr>'),
$('<tr class="loading"><td colspan=6>loading...</td></tr>').hide()
);
return tab;
}
@@ -136,8 +136,8 @@ export default class RecordingsView {
this._element.children('tr.r').each((rowIndex, row) => {
const values = this._formatter.format(recordings[rowIndex], trimRange);
$(row)
.children('td')
.each((index, element) => $(element).text(values[_columnOrder[index]]));
.children('td')
.each((i, e) => $(e).text(values[_columnOrder[i]]));
});
}
@@ -269,7 +269,7 @@ export default class RecordingsView {
// Remove existing rows, replace with new ones
$('tr.r', tbody).remove();
this._recordings.forEach((r) => {
let row = $('<tr class="r" />');
const row = $('<tr class="r" />');
row.append(_columnOrder.map(() => $('<td/>')));
row.on('click', () => {
console.log('Video clicked');

View File

@@ -53,7 +53,7 @@ export default class StreamSelectorView {
if (cameras.length !== 0) {
// Add a header row.
let hdr = $('<tr/>').append($('<th/>'));
const hdr = $('<tr/>').append($('<th/>'));
for (const streamType of allStreamTypes) {
hdr.append($('<th/>').text(streamType));
}
@@ -61,7 +61,7 @@ export default class StreamSelectorView {
}
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;
for (const streamType of allStreamTypes) {
const streamView = c.streamViews[streamType];
@@ -69,7 +69,9 @@ export default class StreamSelectorView {
row.append('<td/>');
} else {
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
// initially.

View File

@@ -44,21 +44,21 @@ export default class StreamView {
* @param {[type]} recordingsParent Parent element to attach to or null)
*/
constructor(
cameraModel,
streamType,
recordingFormatter,
trimmed,
recordingsParent = null
cameraModel,
streamType,
recordingFormatter,
trimmed,
recordingsParent = null
) {
this.camera = cameraModel;
this.streamType = streamType;
this.stream = cameraModel.streams[streamType];
this.recordingsView = new RecordingsView(
this.camera,
this.streamType,
recordingFormatter,
trimmed,
recordingsParent
this.camera,
this.streamType,
recordingFormatter,
trimmed,
recordingsParent
);
this._enabled = true;
this.recordingsUrl = null;

View File

@@ -65,7 +65,7 @@ export default class VideoDialogView {
attach(domElement) {
this._videoElement = $('<video controls preload="auto" autoplay="true" />');
this._dialogElement = $('<div class="playdialog" />').append(
this._videoElement
this._videoElement
);
$(domElement).append(this._dialogElement);
return this;