| Index: lib/filterValidation.js |
| diff --git a/lib/filterValidation.js b/lib/filterValidation.js |
| index df74a831cec1695432a30bd1b7c424e99e0772e4..02188e916aad237514e7b9b6d2f7cfa2c39d84f9 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}; |
| }; |