tslint-clean-code
Version:
TSLint rules for enforcing Clean Code
22 lines (15 loc) • 620 B
text/typescript
import * as ts from 'typescript';
import { getJsxAttributesFromJsxElement, getStringLiteral } from '../JsxAttribute';
const typeString: string = 'type';
/**
* @Returns the implicit role for a menu tag.
*/
function getImplicitRoleForMenu(node: ts.Node): string {
const typeAttribute: ts.JsxAttribute = getJsxAttributesFromJsxElement(node)[typeString];
if (typeAttribute) {
const value: string = getStringLiteral(typeAttribute) || undefined;
return value && value.toUpperCase() === 'TOOLBAR' ? 'toolbar' : undefined;
}
return undefined;
}
export { getImplicitRoleForMenu as menu };