Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-react-pug-classnames

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-react-pug-classnames - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

11

index.js
var DEFAULT_CLASSNAMES_FUNCTION = 'babel-plugin-react-pug-classnames/classnames'
function isTargetAttr (attribute, targetName = 'className') {
return attribute.name.name === targetName
function isTargetAttr (attribute, classAttribute) {
if (!classAttribute) classAttribute = 'className'
return attribute.name.name === classAttribute
}

@@ -36,3 +37,3 @@

if (!isTargetAttr(JSXAttribute.node, opts.attribute)) return
if (!isTargetAttr(JSXAttribute.node, opts.classAttribute)) return

@@ -116,6 +117,6 @@ if (t.isStringLiteral(JSXAttribute.node.value)) {

visitor: {
JSXElement (JSXElement, { opts }) {
JSXElement (JSXElement, params) {
JSXElement.traverse({
JSXOpeningElement (JSXOpeningElement) {
processClass(JSXOpeningElement, opts)
processClass(JSXOpeningElement, params.opts)
}

@@ -122,0 +123,0 @@ })

{
"name": "babel-plugin-react-pug-classnames",
"version": "0.1.0",
"version": "0.2.0",
"description": "[react-pug] Transform className property using BEM classnames-like function",

@@ -5,0 +5,0 @@ "keywords": [

@@ -9,5 +9,25 @@ # babel-plugin-react-pug-classnames

## Install
It must be installed into the actual dependencies, NOT the devDependencies.
The reason is that it does classnames processing through a dynamic runtime function which is `require()`'d from the package itself.
```bash
npm i babel-plugin-react-pug-classnames
```
Add plugin to your babel config right after the `transform-react-pug`:
```json
['transform-react-pug', {
classAttribute: 'styleName'
}],
['react-pug-classnames', {
classAttribute: 'styleName'
}]
```
## Options
`attribute` -- name of the attribute to use (for example `styleName`). Default: `className`
`classAttribute` -- name of the attribute to use (for example `styleName`). Default: `className`

@@ -14,0 +34,0 @@ `classnamesFunction` -- classnames function to use to transform the className's object/array value. Default: `babel-plugin-react-pug-classnames/classnames`

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