
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
babel-plugin-transform-react-styled-components-qa
Advanced tools
Add data-qa property to styled-components via .attrs using the component name
This plugin adds data-qa props to styled-component using .attrs.
This plugin can be used with babel-plugin-transform-react-qa-classes to provide support for both styled-components and React components.
In
const Component = styled.p`
color: red;
`
Out
const Component = styled.p.attrs({
"data-qa": "Component"
})`
color: red;
`
In
const tagName = 'h1'
const Component = styled[tagName]`
background: 'pink';
`
Out
const tagName = 'h1'
const Component = styled[tagName].attrs({
"data-qa": "Component"
})`
background: 'pink';
`
data-qa is append after other attributes defined by usersIn
const PasswordInput = styled.input.attrs({
type: 'password'
})`
font-size: 14px;
line-height: 2em;
`
Out
const PasswordInput = styled.input.attrs({
type: 'password',
"data-qa": "PasswordInput"
})`
font-size: 14px;
line-height: 2em;
`
This plugin is intended to be use in pre-production environment.
Using this plugin with SSR could result in larger payload due to the extra attribute.
{
"env": {
"dev": {
plugins: [
["transform-react-styled-components-qa", {
"attribute": "data-qa",
"format": "kebab"
}]
]
}
}
}
The attribute name to be used instead of data-qa.
Support values: kebab, camel, snake, pascal
Default value: kebab
FAQs
Add data-qa property to styled-components via .attrs using the component name
The npm package babel-plugin-transform-react-styled-components-qa receives a total of 2,196 weekly downloads. As such, babel-plugin-transform-react-styled-components-qa popularity was classified as popular.
We found that babel-plugin-transform-react-styled-components-qa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.