@yasanchezz/eslint-plugin-vue-data-testid
Version:
An `eslint` plugin for checking accessibility rules from within `.vue` files. Add `data-testid` to use better behavior testing
14 lines (13 loc) • 567 B
JavaScript
export default function getAttributeValue(node, attributeName) {
const values = node.startTag.attributes
.filter(attribute => attribute.key.type === 'VDirectiveKey'
? attribute.key.argument?.type === 'VIdentifier'
? attribute.key.argument.name === attributeName
: false
: attribute.key.name === attributeName)
.map(attribute => attribute.value?.type === 'VLiteral'
? attribute.value.value
: undefined)
.filter(attributeValue => attributeValue != null);
return new Set(values);
}