Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filterListener.js

Issue 29375915: Issue 4878 - Start using ESLint for adblockpluscore (Closed)
Patch Set: Rebased Created March 10, 2017, 7:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/filterClasses.js ('k') | lib/filterNotifier.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterListener.js
diff --git a/lib/filterListener.js b/lib/filterListener.js
index d56e82545b8fa0562ffa1681a5273c51e737837d..15f7053191caf04dad43a106e2547f2ac5b01425 100644
--- a/lib/filterListener.js
+++ b/lib/filterListener.js
@@ -15,27 +15,28 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
+"use strict";
+
/**
- * @fileOverview Component synchronizing filter storage with Matcher instances and ElemHide.
+ * @fileOverview Component synchronizing filter storage with Matcher
+ * instances and ElemHide.
*/
-"use strict";
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
+const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
-let {FilterStorage} = require("filterStorage");
-let {FilterNotifier} = require("filterNotifier");
-let {ElemHide} = require("elemHide");
-let {ElemHideEmulation} = require("elemHideEmulation");
-let {defaultMatcher} = require("matcher");
-let {ActiveFilter, RegExpFilter, ElemHideBase, ElemHideEmulationFilter} =
- require("filterClasses");
-let {Prefs} = require("prefs");
+const {FilterStorage} = require("filterStorage");
+const {FilterNotifier} = require("filterNotifier");
+const {ElemHide} = require("elemHide");
+const {ElemHideEmulation} = require("elemHideEmulation");
+const {defaultMatcher} = require("matcher");
+const {ActiveFilter, RegExpFilter,
+ ElemHideBase, ElemHideEmulationFilter} = require("filterClasses");
+const {Prefs} = require("prefs");
/**
* Increases on filter changes, filters will be saved if it exceeds 1.
- * @type Integer
+ * @type {number}
*/
let isDirty = 0;
@@ -43,15 +44,16 @@ let isDirty = 0;
* This object can be used to change properties of the filter change listeners.
* @class
*/
-let FilterListener =
-{
+let FilterListener = {
/**
- * Increases "dirty factor" of the filters and calls FilterStorage.saveToDisk()
- * if it becomes 1 or more. Save is executed delayed to prevent multiple
- * subsequent calls. If the parameter is 0 it forces saving filters if any
- * changes were recorded after the previous save.
+ * Increases "dirty factor" of the filters and calls
+ * FilterStorage.saveToDisk() if it becomes 1 or more. Save is
+ * executed delayed to prevent multiple subsequent calls. If the
+ * parameter is 0 it forces saving filters if any changes were
+ * recorded after the previous save.
+ * @param {number} factor
*/
- setDirty: function(/**Integer*/ factor)
+ setDirty(factor)
{
if (factor == 0 && isDirty > 0)
isDirty = 1;
@@ -69,11 +71,11 @@ let FilterListener =
* Observer listening to history purge actions.
* @class
*/
-let HistoryPurgeObserver =
-{
- observe: function(subject, topic, data)
+let HistoryPurgeObserver = {
+ observe(subject, topic, data)
{
- if (topic == "browser:purge-session-history" && Prefs.clearStatsOnHistoryPurge)
+ if (topic == "browser:purge-session-history" &&
+ Prefs.clearStatsOnHistoryPurge)
{
FilterStorage.resetHitCounts();
FilterListener.setDirty(0); // Force saving to disk
@@ -81,7 +83,9 @@ let HistoryPurgeObserver =
Prefs.recentReports = [];
}
},
- QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObserver])
+ QueryInterface: XPCOMUtils.generateQI(
+ [Ci.nsISupportsWeakReference, Ci.nsIObserver]
+ )
};
/**
@@ -113,10 +117,12 @@ function init()
FilterStorage.loadFromDisk();
- Services.obs.addObserver(HistoryPurgeObserver, "browser:purge-session-history", true);
- onShutdown.add(function()
+ Services.obs.addObserver(HistoryPurgeObserver,
+ "browser:purge-session-history", true);
+ onShutdown.add(() =>
{
- Services.obs.removeObserver(HistoryPurgeObserver, "browser:purge-session-history");
+ Services.obs.removeObserver(HistoryPurgeObserver,
+ "browser:purge-session-history");
});
}
init();
@@ -133,8 +139,10 @@ function addFilter(filter)
let hasEnabled = false;
for (let i = 0; i < filter.subscriptions.length; i++)
+ {
if (!filter.subscriptions[i].disabled)
hasEnabled = true;
+ }
if (!hasEnabled)
return;
@@ -163,8 +171,10 @@ function removeFilter(filter)
{
let hasEnabled = false;
for (let i = 0; i < filter.subscriptions.length; i++)
+ {
if (!filter.subscriptions[i].disabled)
hasEnabled = true;
+ }
if (hasEnabled)
return;
}
@@ -298,8 +308,10 @@ function onLoad()
ElemHide.clear();
ElemHideEmulation.clear();
for (let subscription of FilterStorage.subscriptions)
+ {
if (!subscription.disabled)
addFilters(subscription.filters);
+ }
}
function onSave()
« no previous file with comments | « lib/filterClasses.js ('k') | lib/filterNotifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld