tslint-microsoft-contrib
Advanced tools
Comparing version 2.0.12 to 2.0.13
{ | ||
"name": "tslint-microsoft-contrib", | ||
"version": "2.0.12", | ||
"version": "2.0.13", | ||
"description": "TSLint Rules for Microsoft", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -58,3 +58,4 @@ "use strict"; | ||
this_1.anchorInfoList.forEach(function (anchorInfo) { | ||
if (current.href === anchorInfo.href && | ||
if (current.href && | ||
current.href === anchorInfo.href && | ||
current.text !== anchorInfo.text && | ||
@@ -103,3 +104,3 @@ !Utils_1.Utils.contains(sameHrefDifferentTexts, anchorInfo)) { | ||
} | ||
if (!anchorInfo.text || anchorInfo.text.length <= 4) { | ||
if (!anchorInfo.text || anchorInfo.text.length < 4) { | ||
this.addFailure(this.createFailure(anchorInfo.start, anchorInfo.width, LINK_TEXT_TOO_SHORT_FAILURE_STRING)); | ||
@@ -106,0 +107,0 @@ } |
@@ -69,3 +69,3 @@ "use strict"; | ||
var permittedValues = aria[propName].values; | ||
var propValue = JsxAttribute_1.getStringLiteral(node); | ||
var propValue = JsxAttribute_1.getStringLiteral(node) || String(JsxAttribute_1.getBooleanLiteral(node)); | ||
if (this.isUndefined(node.initializer)) { | ||
@@ -92,5 +92,6 @@ if (!allowUndefined) { | ||
case 'token': | ||
return this.isString(propValueExpression) && permittedValues.indexOf(propValue.toLowerCase()) > -1; | ||
return (this.isString(propValueExpression) || this.isBoolean(propValueExpression)) && | ||
permittedValues.indexOf(propValue.toLowerCase()) > -1; | ||
case 'tokenlist': | ||
return this.isString(propValueExpression) && | ||
return (this.isString(propValueExpression) || this.isBoolean(propValueExpression)) && | ||
propValue.split(' ').every(function (token) { return permittedValues.indexOf(token.toLowerCase()) > -1; }); | ||
@@ -97,0 +98,0 @@ default: |
@@ -40,3 +40,4 @@ "use strict"; | ||
type: 'maintainability', | ||
description: 'Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.', | ||
description: 'Enforce that elements with explicit or implicit roles defined contain ' + | ||
'only `aria-*` properties supported by that `role`.', | ||
options: null, | ||
@@ -68,3 +69,12 @@ issueClass: 'Non-SDL', | ||
var roleProp = attributesInElement[ROLE_STRING]; | ||
var roleValue = roleProp ? JsxAttribute_1.getStringLiteral(roleProp) : getImplicitRole_1.getImplicitRole(node); | ||
var roleValue; | ||
if (roleProp != null) { | ||
roleValue = JsxAttribute_1.getStringLiteral(roleProp); | ||
if (!JsxAttribute_1.isEmpty(roleProp) && roleValue == null) { | ||
return; | ||
} | ||
} | ||
else { | ||
roleValue = getImplicitRole_1.getImplicitRole(node); | ||
} | ||
var isImplicitRole = !roleProp && !!roleValue; | ||
@@ -71,0 +81,0 @@ var normalizedRoles = (roleValue || '').toLowerCase().split(' ') |
@@ -11,3 +11,3 @@ [![npm version](https://badge.fury.io/js/tslint-microsoft-contrib.svg)](https://badge.fury.io/js/tslint-microsoft-contrib) | ||
Version 2.0.12 (Stable) | ||
Version 2.0.13 (Stable) | ||
------------- | ||
@@ -18,3 +18,3 @@ The project has been in use for over a year on multiple projects. Please report any bugs or false positives you might find! | ||
Version 2.0.13 (In-Development) | ||
Version 2.0.14 (In-Development) | ||
------------- | ||
@@ -21,0 +21,0 @@ The [Latest Development Version](https://github.com/Microsoft/tslint-microsoft-contrib/tree/releases) is available online. |
@@ -232,3 +232,4 @@ { | ||
"no-unused-imports": false | ||
} | ||
}, | ||
"rulesDirectory": "./" | ||
} |
@@ -36,2 +36,41 @@ "use strict"; | ||
exports.getStringLiteral = getStringLiteral; | ||
function getBooleanLiteral(node) { | ||
if (!TypeGuard_1.isJsxAttribute(node)) { | ||
throw new Error('The node must be a JsxAttribute collected by the AST parser.'); | ||
} | ||
var initializer = node == null ? null : node.initializer; | ||
var getBooleanFromString = function (value) { | ||
if (value.toLowerCase() === 'true') { | ||
return true; | ||
} | ||
else if (value.toLowerCase() === 'false') { | ||
return false; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
}; | ||
if (TypeGuard_1.isStringLiteral(initializer)) { | ||
return getBooleanFromString(initializer.text); | ||
} | ||
else if (TypeGuard_1.isJsxExpression(initializer)) { | ||
var expression = initializer.expression; | ||
if (TypeGuard_1.isStringLiteral(expression)) { | ||
return getBooleanFromString(expression.text); | ||
} | ||
else { | ||
if (TypeGuard_1.isTrueKeyword(expression)) { | ||
return true; | ||
} | ||
else if (TypeGuard_1.isFalseKeyword(expression)) { | ||
return false; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
exports.getBooleanLiteral = getBooleanLiteral; | ||
function isEmpty(node) { | ||
@@ -38,0 +77,0 @@ var initializer = node == null ? null : node.initializer; |
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
531673
12030