babel-plugin-component-name

0.1.3 • Public • Published

babel-plugin-component-name

Automatically detects functional React components, parses their names and adds data-component="ComponentName" attribute to component's leading JSX Opening Element.

Motivation

CSS-in-JS libraries generate many css class hashes. Unlike BEM-approach, generated classes are not human-readable. So it is very hard to debug css in devtools. This plugin is intended to improve development experience.

Example

without plugin:

before

with plugin:

after

Installation

yarn add --dev babel-plugin-component-name

or

npm  install --save-dev babel-plugin-component-name

Usage

Simply add component-name to your .babelrc file:

{
"plugins": ["component-name"]
}

/babel-plugin-component-name/

    Package Sidebar

    Install

    npm i babel-plugin-component-name

    Weekly Downloads

    1

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    101 kB

    Total Files

    10

    Last publish

    Collaborators

    • piboro