Releases: runtime-studio-au/tailwind-sort-php
Release list
v0.4.0
Fixed
- Single-pass convergence with
tailwindPhpSources. A sortable PHP string inside a PHP island in aclassattribute (e.g.class="p-4 <?= $on ? 'flex z-10' : '' ?>") was overwritten by the enclosing attribute rewrite, so the transform only converged on a second run — and the pre-commit--checkhook could block the same file twice. String edits are now folded into the attribute rewrite and everything sorts in one pass. - Ignored directories match whole path segments only. Files like
distribution.phporvendors-page.phpwere silently skipped because their names share a prefix withdist/vendor. Only actualnode_modules/vendor/dist/.gitdirectories are skipped now.
Added
-h/--helpprints a full usage reference (also works astailwind-sort-php init --help).--versionprints the package version.- Unknown options now print usage after the error; a flag missing its value exits with a clean
Missing value for --attrinstead of crashing.
Performance
- On Node, ignored directories are pruned during glob traversal instead of walked and filtered afterwards.
- The HTML scanner no longer re-lowercases the whole document for every
<script>/<style>/<textarea>/<title>tag.
Internal
- The PHP string/comment/heredoc boundary rules now live in one shared lexer module (
php-lexer.ts) instead of two hand-mirrored copies. - Test suite grew from 74 to 84, including regression coverage for all of the above.
- Dev dependencies updated: Prettier ^3.9, Tailwind CSS ^4.3.
Full Changelog: v0.3.0...v0.4.0
v0.3.0
Sort Tailwind Classes in PHP String Declarations
The tool previously sorted classes only inside HTML class="..." attributes. 0.3.0 adds an opt-in pass that also sorts class strings declared in PHP — constants, static properties, config arrays — using the same engine and order as the HTML side.
What's New
Opt in per file via the new tailwindPhpSources key in your Prettier config (or the repeatable --php-source <glob> flag):
export default {
plugins: ['prettier-plugin-tailwindcss'],
tailwindStylesheet: './resources/css/main.css',
tailwindPhpSources: ['src/classes/*.php'],
};// before → after
'primary' => 'text-white px-4 bg-blue-600 rounded py-2',
'primary' => 'rounded bg-blue-600 px-4 py-2 text-white',Works for scalar declarations and nested/list-style arrays. In key => value arrays only the value is sorted — keys are never touched. The opt-in lives in formatter config only; your PHP stays vanilla.
Safety
Point tailwindPhpSources only at files whose string values are all class lists — within a matched file, every eligible string value is sorted (the tool doesn't guess what "looks like" classes). Concatenated, interpolated, heredoc/nowdoc, and escaped strings are skipped automatically.
Backward Compatible
Without tailwindPhpSources / --php-source, behavior is identical to 0.2.x — the new pass is off by default.
Install
npm install -D @runtimestudio/tailwind-sort-php prettier prettier-plugin-tailwindcssRequires Node ≥ 22.18 or Bun · prettier ≥ 3 · prettier-plugin-tailwindcss ≥ 0.8
Full Changelog: v0.2.1...v0.3.0
v0.2.1
Documentation and comment polish; no functional changes.
Changed
- README: examples now lead with npm/npx (Bun remains the documented alternative); Setup clarifies that any Prettier config format works (
.prettierrc,prettier.config.js,package.json"prettier"key, shareable configs) — the CLI reads the resolved config via Prettier's own resolver. - Hook templates: the partial-staging note now backticks
git add -p, consistent with the README. - Doc-comment cleanups across
src/andtest/(grammar fix inhtml.ts, redundant inline comment removed incli.ts, consistent file references in test headers).
Note for existing installs
The hook text changed (comment only). A future init re-run will report hooks installed by 0.2.0 as "a custom hook" — re-run with --force to refresh, or leave them; behaviour is identical.
Full Changelog: v0.2.0...v0.2.1
v0.2.0
New
init subcommand
One command installs the pre-commit gate — writes .githooks/pre-commit and points core.hooksPath at it:
npx tailwind-sort-php init # check-and-fail: blocks the commit, names the files
npx tailwind-sort-php init --fix # auto-fix: sorts staged files in place, then blocks for review- No-clobber by default — refuses to overwrite a differing hook, repoint a
core.hooksPathset elsewhere (husky etc.), or disable hooks already living in.git/hooks;--forceoverrides,--dry-runpreviews. - Hook hardening over the previously documented snippet: NUL-delimited file handling (
-z/xargs -0) so paths with spaces are safe,--diff-filter=ACMRso renamed-and-edited files are caught, and a self-disable guard whennode_modulesisn't installed. - 8 new tests run
initagainst throwaway git repositories (54 total).
Documentation
- README: searchable title, npm badges, VS Code run-on-save setup, rewritten pre-commit section, corrected CI guidance.
- LICENSE copyright holder updated to the full legal entity.
Full Changelog: v0.1.1...v0.2.0
v0.1.1
First Working Release
0.1.0 shipped TypeScript source as its entry points, which Node refuses to run when the package is installed as a dependency (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).
0.1.1 ships compiled JavaScript (dist/), so it runs under both Node ≥ 22.18 and Bun — as a dependency or standalone.
Changes
- Ship compiled JS via
tsc(rewriteRelativeImportExtensions);main/bin/typesnow point atdist/. - Add gated integration tests that run the real
prettier-plugin-tailwindcsssorter (skip cleanly without the toolchain). prepublishOnlyruns the test suite before building.
0.1.0 (deprecated).