|
|
@ -245,18 +245,22 @@ Ruler.prototype.push = function (ruleName, fn, options) { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Ruler.enable(list [, ignoreInvalid]) |
|
|
|
* Ruler.enable(list [, ignoreInvalid]) -> Array |
|
|
|
* - list (String|Array): list of rule names to enable. |
|
|
|
* - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. |
|
|
|
* |
|
|
|
* Enable rules with given names. If any rule name not found - throw Error. |
|
|
|
* Errors can be disabled by second param. |
|
|
|
* |
|
|
|
* Returns list of found rule names (if no exception happened). |
|
|
|
* |
|
|
|
* See also [[Ruler.disable]], [[Ruler.enableOnly]]. |
|
|
|
**/ |
|
|
|
Ruler.prototype.enable = function (list, ignoreInvalid) { |
|
|
|
if (!Array.isArray(list)) { list = [ list ]; } |
|
|
|
|
|
|
|
var result = []; |
|
|
|
|
|
|
|
// Search by name and enable
|
|
|
|
list.forEach(function (name) { |
|
|
|
var idx = this.__find__(name); |
|
|
@ -266,9 +270,11 @@ Ruler.prototype.enable = function (list, ignoreInvalid) { |
|
|
|
throw new Error('Rules manager: invalid rule name ' + name); |
|
|
|
} |
|
|
|
this.__rules__[idx].enabled = true; |
|
|
|
result.push(name); |
|
|
|
}, this); |
|
|
|
|
|
|
|
this.__cache__ = null; |
|
|
|
return result; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -292,19 +298,21 @@ Ruler.prototype.enableOnly = function (list, ignoreInvalid) { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Ruler.disable(list [, ignoreInvalid]) |
|
|
|
* Ruler.disable(list [, ignoreInvalid]) -> Array |
|
|
|
* - list (String|Array): list of rule names to disable. |
|
|
|
* - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. |
|
|
|
* |
|
|
|
* Disable rules with given names. If any rule name not found - throw Error. |
|
|
|
* Errors can be disabled by second param. |
|
|
|
* |
|
|
|
* Returns list of found rule names (if no exception happened). |
|
|
|
* |
|
|
|
* See also [[Ruler.enable]], [[Ruler.enableOnly]]. |
|
|
|
**/ |
|
|
|
Ruler.prototype.disable = function (list, ignoreInvalid) { |
|
|
|
if (!Array.isArray(list)) { |
|
|
|
list = [ list ]; |
|
|
|
} |
|
|
|
if (!Array.isArray(list)) { list = [ list ]; } |
|
|
|
|
|
|
|
var result = []; |
|
|
|
|
|
|
|
// Search by name and disable
|
|
|
|
list.forEach(function (name) { |
|
|
@ -315,9 +323,11 @@ Ruler.prototype.disable = function (list, ignoreInvalid) { |
|
|
|
throw new Error('Rules manager: invalid rule name ' + name); |
|
|
|
} |
|
|
|
this.__rules__[idx].enabled = false; |
|
|
|
result.push(name); |
|
|
|
}, this); |
|
|
|
|
|
|
|
this.__cache__ = null; |
|
|
|
return result; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|