
Product
Introducing Custom Pull Request Alert Comment Headers
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
@ttskch/prettier-plugin-tailwindcss-anywhere
Advanced tools
A Prettier plugin for sorting TailwindCSS classes in any HTML-like language, like Twig etc.
A Prettier plugin for sorting TailwindCSS classes in any HTML-like language, like Twig etc⚡
>= 20.9 < 24
npm install -D prettier \
prettier-plugin-tailwindcss \
@ttskch/prettier-plugin-tailwindcss-anywhere
This plugin is intended to be used in conjunction with prettier-plugin-tailwindcss.
For example, by setting .prettierrc
as follows, you can sort classes even in files of template engines such as Twig that cannot be processed by prettier-plugin-tailwindcss.
// .prettierrc
{
"plugins": ["prettier-plugin-tailwindcss", "@ttskch/prettier-plugin-tailwindcss-anywhere"],
"overrides": [
{
"files": "*.html.twig",
"options": {
"parser": "anywhere",
}
}
]
}
{% extends 'base.html.twig %}
{% block content %}
<div class="space-y-4 flex-col flex">
<div class="p-4 rounded-lg bg-blue-500 text-white rounded-lg p-4">
Hello, {{ name }}!
</div>
</div>
{% endblock %}
{% endblock %}
{% extends 'base.html.twig %}
{% block content %}
- <div class="space-y-4 flex-col flex">
+ <div class="flex flex-col space-y-4">
- <div class="p-4 rounded-lg bg-blue-500 text-white rounded-lg p-4">
+ <div class="rounded-lg bg-blue-500 p-4 text-white">
Hello, {{ name }}!
</div>
</div>
{% endblock %}
{% endblock %}
regex
default: class="([^"]*)"
The regex
option allows you to specify the part that corresponds to the value of the class attribute using a regular expression.
For example, if you have the following text:
<div class="space-y-4 flex-col flex {% if foo %}is-foo{% endif %}">
In this case, you can specify the following regex
to sort only the part before {% if foo %}
.
{
"options": {
"parser": "anywhere",
"regex": "class=\"([^{}\"]*)(?:\"| {)", // <-- here
}
}
- <div class="space-y-4 flex-col flex {% if foo %}is-foo{% endif %}">
+ <div class="flex flex-col space-y-4 {% if foo %}is-foo{% endif %}">
[!NOTE] Note that you need to surround the part you want to see as the class attribute value with
()
so that the plugin can backreference it.
pnpm install
# Develop...
pnpm check
pnpm test
pnpm build
Thanks! 🎉
FAQs
A Prettier plugin for sorting TailwindCSS classes in any HTML-like language, like Twig etc.
The npm package @ttskch/prettier-plugin-tailwindcss-anywhere receives a total of 295 weekly downloads. As such, @ttskch/prettier-plugin-tailwindcss-anywhere popularity was classified as not popular.
We found that @ttskch/prettier-plugin-tailwindcss-anywhere demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.