UNPKG

react-kiwi-dropdown

Version:

A minimal, easy-to-use and highly adjustable dropdown component made with ReactJS.

24 lines (22 loc) 691 B
// babel-plugin adding `plugin-` prefix to each "id" JSX attribute module.exports = main function main({types: t}) { return { visitor: { // intentionally traversing from Program, // if it matches JSXAttribute here the issue won't be reproduced Program(progPath) { progPath.traverse({ JSXAttribute(path) { const name = path.get('name') if (t.isJSXIdentifier(name) && name.node.name === 'id') { const value = path.get('value') if (t.isStringLiteral(value)) value.replaceWith(t.stringLiteral(`plugin-${value.node.value}`)) } }, }) }, }, } }