UNPKG

@dr.pogodin/babel-plugin-react-css-modules

Version:

Transforms styleName to className using compile time CSS module resolution.

28 lines 776 B
import { NodePath } from '@babel/traverse'; import optionsDefaults from "./schemas/optionsDefaults.js"; const attributeNameExists = (programPath, stats) => { let exists = false; let { attributeNames } = optionsDefaults; if (stats.opts && stats.opts.attributeNames) { attributeNames = { ...attributeNames, ...stats.opts.attributeNames }; } programPath.traverse({ JSXAttribute(attributePath) { if (exists) { return; } const attribute = attributePath.node; if (typeof attribute.name !== 'undefined' && typeof attributeNames[attribute.name.name] === 'string') { exists = true; } } }); return exists; }; export default attributeNameExists; //# sourceMappingURL=attributeNameExists.js.map