Sha256: cf34bfeb536f83f643be728feeb5165f1a863d32c83a52b8bdc7678ae5ff3f02

Contents?: true

Size: 691 Bytes

Versions: 9

Compression:

Stored size: 691 Bytes

Contents

// 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}`))
            }
          },
        })
      },
    },
  }
}

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
disco_app-0.18.2 test/dummy/node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
jester-data-8.0.0 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
ezii-os-5.2.1 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
ezii-os-2.0.1 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
ezii-os-1.1.0 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
ezii-os-1.0.0 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
ezii-os-0.0.0.1.0 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js
ezii-os-0.0.0.0.1 node_modules/babel-plugin-macros/dist/__tests__/fixtures/jsx-id-prefix.plugin.js