Comparing version 0.0.25 to 0.0.26
@@ -9,7 +9,10 @@ "use strict"; | ||
var selectorValidator_1 = require('./util/selectorValidator'); | ||
var FAILURE_STRING = 'The selector of the component "%s" should have prefix "%s" (https://goo.gl/cix8BY)'; | ||
var FAILURE_SINGLE = 'The selector of the component "%s" should have prefix "%s" (https://goo.gl/cix8BY)'; | ||
var FAILURE_MANY = 'The selector of the component "%s" should have one of the prefixes: %s (https://goo.gl/cix8BY)'; | ||
var Rule = (function (_super) { | ||
__extends(Rule, _super); | ||
function Rule(ruleName, value, disabledIntervals) { | ||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator.prefix(value[1]), FAILURE_STRING, selectorNameBase_1.COMPONENT_TYPE.COMPONENT); | ||
var prefixExpression = (value.slice(1) || []).join('|'); | ||
var FAIL_MESSAGE = value.length > 2 ? FAILURE_MANY : FAILURE_SINGLE; | ||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator.multiPrefix(prefixExpression), FAIL_MESSAGE, selectorNameBase_1.COMPONENT_TYPE.COMPONENT); | ||
} | ||
@@ -16,0 +19,0 @@ return Rule; |
@@ -9,7 +9,10 @@ "use strict"; | ||
var selectorValidator_1 = require('./util/selectorValidator'); | ||
var FAILURE_STRING = 'The selector of the directive "%s" should have prefix "%s" (https://goo.gl/uacjKR)'; | ||
var FAILURE_SINGLE = 'The selector of the directive "%s" should have prefix "%s" (https://goo.gl/uacjKR)'; | ||
var FAILURE_MANY = 'The selector of the directive "%s" should have one of the prefixes: %s (https://goo.gl/uacjKR)'; | ||
var Rule = (function (_super) { | ||
__extends(Rule, _super); | ||
function Rule(ruleName, value, disabledIntervals) { | ||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator.prefix(value[1]), FAILURE_STRING, selectorNameBase_1.COMPONENT_TYPE.DIRECTIVE); | ||
var prefixExpression = (value.slice(1) || []).join('|'); | ||
var FAIL_MESSAGE = value.length > 2 ? FAILURE_MANY : FAILURE_SINGLE; | ||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator.multiPrefix(prefixExpression), FAIL_MESSAGE, selectorNameBase_1.COMPONENT_TYPE.DIRECTIVE); | ||
} | ||
@@ -16,0 +19,0 @@ return Rule; |
{ | ||
"name": "codelyzer", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "A set of linters for Angular 2 applications, following https:/angular.io/styleguide.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,6 +18,7 @@ "use strict"; | ||
} | ||
if (value[2]) { | ||
if (value.length > 2) { | ||
this.hasPrefix = true; | ||
this.prefix = value[2]; | ||
this.prefixChecker = selectorValidator_1.SelectorValidator.prefix(value[2]); | ||
var prefixExpression = (value.slice(2) || []).join('|'); | ||
this.prefix = (value.slice(2) || []).join(','); | ||
this.prefixChecker = selectorValidator_1.SelectorValidator.multiPrefix(prefixExpression); | ||
} | ||
@@ -24,0 +25,0 @@ } |
@@ -34,3 +34,3 @@ "use strict"; | ||
SelectorRule.prototype.getFailureString = function (failureConfig) { | ||
return sprintf_js_1.sprintf(this.failureString, failureConfig.className, this.getOptions().ruleArguments[0], failureConfig.selector); | ||
return sprintf_js_1.sprintf(this.failureString, failureConfig.className, this.getOptions().ruleArguments, failureConfig.selector); | ||
}; | ||
@@ -37,0 +37,0 @@ SelectorRule.prototype.validate = function (selector) { |
@@ -58,3 +58,3 @@ "use strict"; | ||
.map(function (m) { return m.name.text; }) | ||
.filter(function (n) { return n.substr(0, 2) === Rule.HOOKS_PREFIX; }) | ||
.filter(function (n) { return (n && n.substr(0, 2) === Rule.HOOKS_PREFIX); }) | ||
.map(function (n) { return n.substr(2, n.lenght); }) | ||
@@ -61,0 +61,0 @@ .filter(function (n) { return Rule.LIFE_CYCLE_HOOKS_NAMES.indexOf(n) !== -1; }); |
@@ -19,3 +19,8 @@ "use strict"; | ||
}; | ||
}, | ||
multiPrefix: function (prefixes) { | ||
return function (selector) { | ||
return new RegExp("^\\[?(" + prefixes + ")").test(selector); | ||
}; | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104828
2822