Add eslint configuration files extending Google's rules

This commit is contained in:
Matthew Noorenberghe 2017-03-18 00:00:51 -07:00
parent c24853ad11
commit c7955cd1b6
20 changed files with 128 additions and 102 deletions

4
.eslintignore Normal file
View File

@ -0,0 +1,4 @@
web/api/lib
web/skins/classic/js/jquery-1.11.3.js
web/skins/classic/js/jquery.js
web/tools/mootools

29
.eslintrc.js Normal file
View File

@ -0,0 +1,29 @@
"use strict";
module.exports = {
"env": {
"browser": true,
},
"extends": ["google"],
"rules": {
"brace-style": "off",
"camelcase": "off",
"comma-dangle": "off",
"key-spacing": "off",
"max-len": "off",
"new-cap": ["error", {
capIsNewExceptions: ["Error", "Warning", "Debug", "Polygon_calcArea", "Play", "Stop"],
newIsCapExceptionPattern: "^Asset\.."
}],
"no-array-constructor": "off",
"no-caller": "off",
"no-new-object": "off",
"no-unused-vars": "off",
"no-var": "off",
"object-curly-spacing": "off",
"prefer-rest-params": "off",
"quotes": "off",
"require-jsdoc": "off",
"spaced-comment": "off",
},
};

View File

@ -115,4 +115,4 @@ window.onerror =
function( message, url, line )
{
logReport( "ERR", message, url, line );
}
};

View File

@ -116,7 +116,7 @@ function setupOverlays()
overlay.getElements('.overlayCloser').each(
function( closer )
{
closer.addEvent( 'click', function() { overlay.element.hide(); } )
closer.addEvent( 'click', function() { overlay.element.hide(); } );
}
);
overlay.overlayShow = function() { overlay.element.show(); };

View File

@ -33,7 +33,7 @@ var popupSizes = {
'device': { 'width': 260, 'height': 150 },
'devices': { 'width': 400, 'height': 240 },
'donate': { 'width': 500, 'height': 280 },
'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, minHeight: 540 },
'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540 },
'eventdetail': { 'width': 600, 'height': 220 },
'events': { 'width': 960, 'height': 780 },
'export': { 'width': 400, 'height': 340 },

View File

@ -33,7 +33,7 @@ var popupSizes = {
'device': { 'width': 260, 'height': 150 },
'devices': { 'width': 400, 'height': 240 },
'donate': { 'width': 500, 'height': 280 },
'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, minHeight: 540 },
'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540 },
'eventdetail': { 'width': 600, 'height': 220 },
'events': { 'width': 960, 'height': 780 },
'export': { 'width': 400, 'height': 340 },

View File

@ -33,7 +33,7 @@ var popupSizes = {
'device': { 'width': 260, 'height': 150 },
'devices': { 'width': 400, 'height': 240 },
'donate': { 'width': 500, 'height': 280 },
'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, minHeight: 540 },
'event': { 'addWidth': 108, 'minWidth': 496, 'addHeight': 230, 'minHeight': 540 },
'eventdetail': { 'width': 600, 'height': 220 },
'events': { 'width': 1080, 'height': 780 },
'export': { 'width': 400, 'height': 340 },

View File

@ -25,7 +25,6 @@ function setButtonStates( element )
function addMonitor( element)
{
var form = element.form;
var dupParam;
var monitorId=-1;

View File

@ -19,6 +19,5 @@ function validateForm( form ) {
return( false );
}
return( true );
}

View File

@ -25,7 +25,7 @@ function changeReplayMode()
{
var replayMode = $('replayMode').get('value');
Cookie.write( 'replayMode', replayMode, { duration: 10*365 })
Cookie.write( 'replayMode', replayMode, { duration: 10*365 });
refreshWindow();
}
@ -477,7 +477,7 @@ function checkFrames( eventId, frameId, loadImage )
if ( !$('eventThumb'+fid) )
{
var img = new Element( 'img', { 'id': 'eventThumb'+fid, 'src': 'graphics/transparent.gif', 'alt': fid, 'class': 'placeholder' } );
img.addEvent( 'click', function () { eventData['frames'][fid] = null; checkFrames( eventId, fid ) } );
img.addEvent( 'click', function() { eventData['frames'][fid] = null; checkFrames( eventId, fid ); } );
frameQuery( eventId, fid, loadImage && (fid == frameId) );
var imgs = $('eventThumbs').getElements( 'img' );
var injected = false;

View File

@ -9,7 +9,6 @@ if ( refreshParent )
}
function configureButtons( element ) {
if ( canEditGroups ) {
var form = element.form;
form.saveBtn.disabled = (element.value == 0);

View File

@ -315,7 +315,7 @@ function initPage()
if ( sortReversed )
startIndex = displayLimit;
else
startIndex = 0;;
startIndex = 0;
for ( var i = startIndex; logCount > displayLimit; i++ )
{
rows[i].destroy();

View File

@ -15,7 +15,7 @@ function Monitor( index, monitorData )
this.start = function( delay )
{
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
}
};
this.setStateClass = function( element, stateClass )
{
@ -29,7 +29,7 @@ function Monitor( index, monitorData )
element.removeClass( 'idle' );
element.addClass( stateClass );
}
}
};
this.getStreamCmdResponse = function( respObj, respText )
{
@ -94,14 +94,13 @@ function Monitor( index, monitorData )
// Try to reload the image stream.
if ( stream )
stream.src = stream.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
}
var streamCmdTimeout = statusRefreshTimeout;
if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT )
streamCmdTimeout = streamCmdTimeout/5;
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this );
this.lastAlarmState = this.alarmState;
}
};
this.streamCmdQuery = function( resent )
{
@ -109,7 +108,7 @@ function Monitor( index, monitorData )
//console.log( this.connKey+": Resending" );
//this.streamCmdReq.cancel();
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
}
};
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );

View File

@ -1,6 +1,5 @@
function checkState( element )
{
var form = element.form;
var minIndex = running?2:1;
@ -25,7 +24,6 @@ function checkState( element )
form.saveBtn.disabled = false;
form.deleteBtn.disabled = true;
}
}
function saveState( element )

View File

@ -496,7 +496,7 @@ function getEventCmdResponse( respObj, respText )
link.set( 'text', event.AvgScore+'/'+event.MaxScore );
link.inject( row.getElement( 'td.colScore' ) );
link = new Element( 'a', { 'href': '#', 'title': deleteString, 'events': { 'click': function( e ) { deleteEvent( e, event.Id ); }.bind( link ), 'mouseover': highlightRow.pass( row ), 'mouseout': highlightRow.pass( row ) } });
link = new Element( 'a', { 'href': '#', 'title': deleteString, 'events': { 'click': function( e ) { deleteEvent( e, event.Id ); }, 'mouseover': highlightRow.pass( row ), 'mouseout': highlightRow.pass( row ) } });
link.set( 'text', 'X' );
link.inject( row.getElement( 'td.colDelete' ) );

View File

@ -384,7 +384,7 @@ function delPoint( index )
function limitPointValue( point, loVal, hiVal )
{
point.value = constrainValue(point.value, loVal, hiVal)
point.value = constrainValue(point.value, loVal, hiVal);
}
function updateArea( ) {
@ -393,7 +393,6 @@ function updateArea( ) {
var form = $('zoneForm');
form.elements['newZone[Area]'].value = area;
if ( form.elements['newZone[Units]'].value == 'Percent' ) {
form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea*100 );
} else if ( form.elements['newZone[Units]'].value == 'Pixels' ) {
form.elements['newZone[TempArea]'].value = area;