Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@unocss/transformer-attributify-jsx
Advanced tools
Support valueless attributify in JSX/TSX.
export function Component() {
return (
<div text-red text-center text-5xl animate-bounce>
unocss
</div>
)
}
Will be transformed to:
export function Component() {
return (
<div text-red="" text-center="" text-5xl="" animate-bounce="">
unocss
</div>
)
}
JSX by default will treat valueless attributes as boolean attributes.
export function Component() {
return (
<div text-red={true} text-center={true} text-5xl={true} animate-bounce={true}>
unocss
</div>
)
}
npm i -D @unocss/transformer-attributify-jsx
import transformerAttributifyJsx from '@unocss/transformer-attributify-jsx'
// uno.config.ts
import { defineConfig, presetAttributify } from 'unocss'
export default defineConfig({
// ...
presets: [
// ...
presetAttributify()
],
transformers: [
transformerAttributifyJsx(), // <--
],
})
If you encounter any issues with this package, there is @unocss/transformer-attributify-jsx-babel package that uses Babel to transform JSX.
⚠️ The rules are almost the same as those of
preset-attributify
, but there are several precautions
<div translate-x-100% /> <!-- cannot end with `%` -->
<div translate-x-[100px] /> <!-- cannot contain `[` or `]` -->
Instead, you may want to use valued attributes instead:
<div translate="x-100%" />
<div translate="x-[100px]" />
This transformer will only transform attributes that are valid UnoCSS utilities.
You can also blocklist
bypass some attributes from been transformed.
transformerAttributifyJsx({
blocklist: [/text-[a-zA-Z]*/, 'text-5xl']
})
<div text-red text-center text-5xl animate-bounce>
unocss
</div>
Will be compiled to:
<div text-red text-center text-5xl animate-bounce="">
unocss
</div>
MIT License © 2022-PRESENT Anthony Fu
FAQs
Support valueless attributify in JSX/TSX.
We found that @unocss/transformer-attributify-jsx demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.