New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-jsx-classname-components

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-jsx-classname-components

It allows you to specify inner components via class names

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
increased by10.7%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-jsx-classname-components

:sunglasses: Long name, right...

npm version CI Status Greenkeeper badge

What

It takes your first class name (if it starts with up-case) and use it as property for component.

<Component className="Inner" />

Will be transformed into this:

<Component.Inner />

Why

You don't need this plugin unless you use Pug with react. Pug consider everything after dot as class names, so it converts code like:

pug`Component.Inner Hello`

Into this:

<Component className="Inner">Hello</Component>

This plugin was created to change the result to this one:

<Component.Inner>Hello</Component.Inner>

How

yarn add --dev babel-plugin-transform-jsx-classname-components

In .babelrc:

{
  "plugins": [
    "transform-jsx-classname-components"
  ]
}

Note: It should be placed after transforming Pug into Jsx.

Options

NameTypeDefaultDescription
objectsArray<string>nullIt specifies what objects should be processed
attributeStringclassNameIt specifies attribute name which should be processed

objects

If you set it to ['Icons'] it will handle only <Icons ... />:

<Component className="Inner" />
<Icons className="Inner" />

Will be transformed into:

<Component className="Inner" />
<Icons.Inner  />

attribute

If you set it to styleName it will process styleName attribute instead of default one:

<Component styleName="Inner" />
<Icons className="JustClass" styleName="Inner" />

Will be transformed into:

<Component.Inner />
<Icons.Inner className="JustClass"  />

FAQs

Package last updated on 23 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc