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

Unified Diff: lib/filterValidation.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Addressed Wladimir's feedback Created March 15, 2017, 4:51 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/filterComposer.js ('k') | lib/icon.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterValidation.js
diff --git a/lib/filterValidation.js b/lib/filterValidation.js
index c280fcceba42d50b1b00ba55a1b5f0b091ba8a40..545a6b69919dcdda308ecddc38b235bafc84d396 100644
--- a/lib/filterValidation.js
+++ b/lib/filterValidation.js
@@ -29,6 +29,9 @@ const {Utils} = require("utils");
* indicating that a given filter cannot be parsed,
* contains an invalid CSS selector or is a filter list header.
*
+ * @param {string} type See documentation in the constructor below.
+ * @param {Object} [details] Contains the "reason" and / or "selector"
+ * properties.
* @constructor
*/
function FilterParsingError(type, details)
@@ -71,14 +74,19 @@ FilterParsingError.prototype = {
if (this.reason)
message = Utils.getString(this.reason);
else
+ {
message = ext.i18n.getMessage(
this.type.replace(/-/g, "_"),
"selector" in this ? "'" + this.selector + "'" : null
);
+ }
if (this.lineno)
- message = ext.i18n.getMessage("line", this.lineno.toLocaleString()) + ": " + message;
-
+ {
+ message = ext.i18n.getMessage(
+ "line", this.lineno.toLocaleString()
+ ) + ": " + message;
+ }
return message;
}
};
@@ -87,7 +95,7 @@ function isValidCSSSelector(selector)
{
let style = document.createElement("style");
document.documentElement.appendChild(style);
- let sheet = style.sheet;
+ let {sheet} = style;
document.documentElement.removeChild(style);
try
@@ -104,10 +112,10 @@ function isValidCSSSelector(selector)
/**
* @typedef ParsedFilter
- * @property {?Filter} [filter] The parsed filter if it is valid.
- * Or null if the given string is empty.
- * @property {FilterParsingError} [error] See {@link module:filterValidation~FilterParsingError FilterParsingError}
- *
+ * @property {?Filter} [filter]
+ * The parsed filter if it is valid. Or null if the given string is empty.
+ * @property {FilterParsingError} [error]
+ * See {@link module:filterValidation~FilterParsingError FilterParsingError}
*/
let parseFilter =
@@ -130,19 +138,26 @@ exports.parseFilter = text =>
filter = Filter.fromText(text);
if (filter instanceof InvalidFilter)
- return {error: new FilterParsingError("invalid-filter", {reason: filter.reason})};
-
+ {
+ return {error: new FilterParsingError("invalid-filter",
+ {reason: filter.reason})};
+ }
if (filter instanceof ElemHideBase && !isValidCSSSelector(filter.selector))
- return {error: new FilterParsingError("invalid-css-selector", {selector: filter.selector})};
+ {
+ return {error: new FilterParsingError("invalid-css-selector",
+ {selector: filter.selector})};
+ }
}
- return {filter: filter};
+ return {filter};
};
/**
* @typedef ParsedFilters
- * @property {Filter[]} filters The parsed result without invalid filters.
- * @property {FilterParsingError[]} errors See {@link module:filterValidation~FilterParsingError FilterParsingError}
+ * @property {Filter[]} filters
+ * The parsed result without invalid filters.
+ * @property {FilterParsingError[]} errors
+ * See {@link module:filterValidation~FilterParsingError FilterParsingError}
*/
/**
@@ -171,5 +186,5 @@ exports.parseFilters = text =>
}
}
- return {filters: filters, errors: errors};
+ return {filters, errors};
};
« no previous file with comments | « lib/filterComposer.js ('k') | lib/icon.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld