| Index: lib/filterValidation.js |
| diff --git a/lib/filterValidation.js b/lib/filterValidation.js |
| index c280fcceba42d50b1b00ba55a1b5f0b091ba8a40..b47fc3f859af37fff250507e277548514e950c28 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 |
| @@ -106,8 +114,8 @@ 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 {FilterParsingError} [error] |
| + * See {@link module:filterValidation~FilterParsingError FilterParsingError} |
|
Wladimir Palant
2017/03/14 13:03:28
Please indent this line.
kzar
2017/03/15 04:57:49
Done.
|
| */ |
| let parseFilter = |
| @@ -130,19 +138,25 @@ 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 {FilterParsingError[]} errors |
| + * See {@link module:filterValidation~FilterParsingError FilterParsingError} |
|
Wladimir Palant
2017/03/14 13:03:27
Please indent this line.
kzar
2017/03/15 04:57:48
Done.
|
| */ |
| /** |
| @@ -171,5 +185,5 @@ exports.parseFilters = text => |
| } |
| } |
| - return {filters: filters, errors: errors}; |
| + return {filters, errors}; |
| }; |