From 9e4e4943f376db6fbc9cf0d1a93ce3de7fcf005a Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 27 Aug 2015 14:29:35 -0400 Subject: [PATCH] this fixes many strictness warning in browser console --- platform/firefox/vapi-background.js | 6 +++--- platform/firefox/vapi-client.js | 8 ++++---- src/js/assets.js | 16 ++++++++++------ src/js/contentscript-end.js | 4 ++-- src/js/logger-ui.js | 3 +-- src/js/messaging.js | 4 +++- src/js/storage.js | 7 +++---- src/js/udom.js | 4 ++-- 8 files changed, 28 insertions(+), 24 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 855d20a..8f26c6a 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uMatrix */ -/* jshint bitwise: false, boss: true, esnext: true */ +/* jshint bitwise: false, esnext: true */ /* global self, Components, punycode, µBlock */ // For background page @@ -355,7 +355,7 @@ vAPI.storage = (function() { var row; - while ( row = rows.getNextRow() ) { + while ( (row = rows.getNextRow()) ) { // we assume that there will be two columns, since we're // using it only for preferences result[row.getResultByIndex(0)] = row.getResultByIndex(1); @@ -713,7 +713,7 @@ vAPI.tabs.open = function(details) { var tabBrowser = getTabBrowser(win); // Open in a standalone window - if ( details.popup === true ) { + if ( details.popup ) { Services.ww.openWindow( self, details.url, diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index 471bf74..26a1fd7 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -19,7 +19,7 @@ Home: https://github.com/gorhill/uMatrix */ -/* jshint boss: true, esnext: true */ +/* jshint esnext: true */ /* global addMessageListener, removeMessageListener, sendAsyncMessage */ // For non background pages @@ -55,7 +55,7 @@ vAPI.shutdown = (function() { var exec = function() { //console.debug('Shutting down...'); var job; - while ( job = jobs.pop() ) { + while ( (job = jobs.pop()) ) { job(); } }; @@ -76,7 +76,7 @@ var messagingConnector = function(response) { var channels = vAPI.messaging.channels; var channel, listener; - if ( response.broadcast === true && !response.channelName ) { + if ( response.broadcast && !response.channelName ) { for ( channel in channels ) { if ( channels.hasOwnProperty(channel) === false ) { continue; @@ -121,7 +121,7 @@ vAPI.messaging = { this.channels.vAPI = { listener: function(msg) { - if ( msg.cmd === 'injectScript' ) { + if ( typeof msg.cmd === 'string' && msg.cmd === 'injectScript' ) { var details = msg.details; if ( !details.allFrames && window !== window.top ) { return; diff --git a/src/js/assets.js b/src/js/assets.js index 60f518c..362c1d2 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -20,7 +20,6 @@ */ /* global vAPI, µMatrix, YaMD5 */ -/* jshint boss: true */ /******************************************************************************* @@ -449,14 +448,14 @@ var getRepoMetadata = function(callback) { }; var onLocalChecksumsLoaded = function(details) { - if ( localChecksums = validateChecksums(details) ) { + if ( (localChecksums = validateChecksums(details)) ) { parseChecksums(localChecksums, 'local'); } checksumsReceived(); }; var onRepoChecksumsLoaded = function(details) { - if ( repoChecksums = validateChecksums(details) ) { + if ( (repoChecksums = validateChecksums(details)) ) { parseChecksums(repoChecksums, 'repo'); } checksumsReceived(); @@ -1011,7 +1010,10 @@ exports.get = function(path, callback) { } // Asset is repo copy of external content - if ( stringIsNotEmpty(homeURLs[path]) ) { + if ( + homeURLs.hasOwnProperty(path) && + stringIsNotEmpty(homeURLs[path]) + ) { readRepoCopyAsset(path, callback); return; } @@ -1056,8 +1058,10 @@ exports.metadata = function(callback) { continue; } entry = out[path]; - entry.cacheObsolete = stringIsNotEmpty(homeURLs[path]) && - cacheIsObsolete(entry.lastModified); + entry.cacheObsolete = + homeURLs.hasOwnProperty(path) && + stringIsNotEmpty(homeURLs[path]) && + cacheIsObsolete(entry.lastModified || 0); } callback(out); }; diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index d0c92b4..d533379 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -20,7 +20,7 @@ */ /* global vAPI */ -/* jshint multistr: true, boss: true */ +/* jshint multistr: true */ /******************************************************************************/ /******************************************************************************/ @@ -344,7 +344,7 @@ var collapser = (function() { var hasInlineScript = function(nodeList, summary) { var i = 0; var node, text; - while ( node = nodeList.item(i++) ) { + while ( (node = nodeList.item(i++)) ) { if ( node.nodeType !== 1 ) { continue; } diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index bd0b044..97773ca 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -19,7 +19,6 @@ Home: https://github.com/gorhill/sessbench */ -/* jshint boss: true */ /* global vAPI, uDom */ /******************************************************************************/ @@ -205,7 +204,7 @@ var createRow = function(layout) { td.setAttribute('colspan', span); } index += 1; - while ( td = tr.cells[index] ) { + while ( (td = tr.cells[index]) ) { tdJunkyard.push(tr.removeChild(td)); } return tr; diff --git a/src/js/messaging.js b/src/js/messaging.js index 3679492..c1dc615 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -20,7 +20,6 @@ */ /* global µMatrix, vAPI */ -/* jshint boss: true */ /******************************************************************************/ /******************************************************************************/ @@ -88,6 +87,9 @@ function onMessage(request, sender, callback) { break; case 'userSettings': + if ( request.hasOwnProperty('value') === false ) { + request.value = undefined; + } response = µm.changeUserSettings(request.name, request.value); break; diff --git a/src/js/storage.js b/src/js/storage.js index 74db014..7fac8b7 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -19,7 +19,6 @@ Home: https://github.com/gorhill/uMatrix */ -/* jshint boss: true */ /* global chrome, µMatrix, punycode, publicSuffixList */ /******************************************************************************/ @@ -111,7 +110,7 @@ var oldLocation, newLocation; var availableEntry, storedEntry; - while ( oldLocation = locations.pop() ) { + while ( (oldLocation = locations.pop()) ) { newLocation = redirections[oldLocation] || oldLocation; availableEntry = availableHostsFiles[newLocation]; if ( availableEntry === undefined ) { @@ -119,7 +118,7 @@ } storedEntry = lists[oldLocation] || {}; availableEntry.off = storedEntry.off || false; - µm.assets.setHomeURL(newLocation, availableEntry.homeURL); + µm.assets.setHomeURL(newLocation, availableEntry.homeURL || ''); if ( storedEntry.entryCount !== undefined ) { availableEntry.entryCount = storedEntry.entryCount; } @@ -225,7 +224,7 @@ // Load all hosts file which are not disabled. var location; - while ( location = locations.pop() ) { + while ( (location = locations.pop()) ) { if ( hostsFiles[location].off ) { hostsFileLoadCount -= 1; continue; diff --git a/src/js/udom.js b/src/js/udom.js index 30bc60d..f9e1165 100644 --- a/src/js/udom.js +++ b/src/js/udom.js @@ -336,7 +336,7 @@ DOMList.prototype.remove = function() { var i = this.nodes.length; while ( i-- ) { cn = this.nodes[i]; - if ( p = cn.parentNode ) { + if ( (p = cn.parentNode) ) { p.removeChild(cn); } } @@ -713,7 +713,7 @@ DOMList.prototype.trigger = function(etype) { var onBeforeUnload = function() { var entry; - while ( entry = listenerEntries.pop() ) { + while ( (entry = listenerEntries.pop()) ) { entry.dispose(); } window.removeEventListener('beforeunload', onBeforeUnload);