🆙 Add cms i using 🆙

This commit is contained in:
Remco
2025-11-25 22:42:56 +01:00
parent 94704e0925
commit d44196149e
35591 changed files with 3601123 additions and 0 deletions
@@ -0,0 +1,731 @@
# Changelog
## [1.8.12](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.11...v1.8.12) (2023-04-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.12 ([47f4366](https://github.com/shufo/prettier-plugin-blade/commit/47f43666e2c4a35086d5308faee8fa262551b6cc))
* **deps:** update actions/stale action to v8 ([b275361](https://github.com/shufo/prettier-plugin-blade/commit/b275361a63a82afa8e14c4c5c9d9e0b39c7d202d))
## [1.8.11](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.10...v1.8.11) (2023-03-22)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.10 ([5a4491e](https://github.com/shufo/prettier-plugin-blade/commit/5a4491ed8571dca25df8a6a830ca32f5dcf12479))
* **deps:** update dependency typescript to v5 ([33d36f5](https://github.com/shufo/prettier-plugin-blade/commit/33d36f59400ded3172c3c5086815a417f61fc6c6))
## [1.8.10](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.9...v1.8.10) (2023-02-25)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.9 ([ed9c628](https://github.com/shufo/prettier-plugin-blade/commit/ed9c628c65a3027099e13f509ab6d2adc64ac235))
## [1.8.9](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.8...v1.8.9) (2023-02-23)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.8 ([2ef11ba](https://github.com/shufo/prettier-plugin-blade/commit/2ef11bade4d1797e629943740735a732bbfd26f0))
## [1.8.8](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.7...v1.8.8) (2023-02-12)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.7 ([b647e2c](https://github.com/shufo/prettier-plugin-blade/commit/b647e2c20bf10e694e98c3442b1025eacf8c7676))
## [1.8.7](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.6...v1.8.7) (2023-02-05)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.6 ([93946eb](https://github.com/shufo/prettier-plugin-blade/commit/93946eb6b05a45215480b21aa0cbb94725143a5b))
* **deps:** bump synckit from 0.8.4 to 0.8.5 ([b59e641](https://github.com/shufo/prettier-plugin-blade/commit/b59e641619e233def9e2a379d7213ef524cb26ca))
## [1.8.6](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.5...v1.8.6) (2023-01-20)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.5 ([d8c9ea4](https://github.com/shufo/prettier-plugin-blade/commit/d8c9ea41599e67b771895fa20b067e53d89c94ae))
## [1.8.5](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.4...v1.8.5) (2023-01-14)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.4 ([97a17f4](https://github.com/shufo/prettier-plugin-blade/commit/97a17f49d83fe6d41c00a154824416ed426020db))
* **deps:** bump json5 from 2.2.0 to 2.2.3 ([ed3b9ba](https://github.com/shufo/prettier-plugin-blade/commit/ed3b9ba4629c1570f0600ae729717d56c142a9d4))
* **deps:** update dependency esbuild to ^0.17.0 ([2f88a14](https://github.com/shufo/prettier-plugin-blade/commit/2f88a1439d16375e98fddfcd00a952a304dc2be6))
## [1.8.4](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.3...v1.8.4) (2023-01-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.3 ([1cc5049](https://github.com/shufo/prettier-plugin-blade/commit/1cc504921fd55b5ab536110202bd5338803fb5ad))
## [1.8.3](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.2...v1.8.3) (2022-12-25)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.2 ([7900d40](https://github.com/shufo/prettier-plugin-blade/commit/7900d40f8874e38618b834206e42b4091ffaf92c))
* **deps:** update actions/stale action to v7 ([da64151](https://github.com/shufo/prettier-plugin-blade/commit/da6415129a0aa97f4e04715d32a8c87907d9cebd))
## [1.8.2](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.1...v1.8.2) (2022-12-18)
### Miscellaneous
* 🤖 bump blade-formatter to 1.32.0 ([e4e843a](https://github.com/shufo/prettier-plugin-blade/commit/e4e843a525f19023e3f66fa52cecfe6f1e8575c8))
* 🤖 bump blade-formatter to 1.32.1 ([efb2e1c](https://github.com/shufo/prettier-plugin-blade/commit/efb2e1cde2da721b03ad0fc47636e6428338951c))
* **deps:** update cirrus-actions/rebase action to v1.8 ([ab1549d](https://github.com/shufo/prettier-plugin-blade/commit/ab1549def434e1a5956337f42947a87e6ccac67e))
* **deps:** update dependency esbuild to ^0.16.0 ([6391e5e](https://github.com/shufo/prettier-plugin-blade/commit/6391e5edffd3fc8bea4ae5b27e2180aec4aa780c))
## [1.8.1](https://github.com/shufo/prettier-plugin-blade/compare/v1.8.0...v1.8.1) (2022-11-20)
### Miscellaneous
* 🤖 bump blade-formatter to 1.31.1 ([9d252db](https://github.com/shufo/prettier-plugin-blade/commit/9d252db53040d6e279a8ae5c7612dc806907453d))
## [1.8.0](https://github.com/shufo/prettier-plugin-blade/compare/v1.7.3...v1.8.0) (2022-10-30)
### Features
* 🎸 add option `--custom-html-attributes-order` ([97070f7](https://github.com/shufo/prettier-plugin-blade/commit/97070f7754ef102481446477440bdbf895e21375))
### Miscellaneous
* 🤖 bump blade-formatter to 1.31.0 ([32291f6](https://github.com/shufo/prettier-plugin-blade/commit/32291f6b3aafdc2b01fc994aa7bf26bc915ec426))
## [1.7.3](https://github.com/shufo/prettier-plugin-blade/compare/v1.7.2...v1.7.3) (2022-10-23)
### Miscellaneous
* 🤖 bump blade-formatter to 1.30.3 ([e6ce278](https://github.com/shufo/prettier-plugin-blade/commit/e6ce2786b20d3d3dc73978edd965824c4965bb62))
## [1.7.2](https://github.com/shufo/prettier-plugin-blade/compare/v1.7.1...v1.7.2) (2022-10-16)
### Miscellaneous
* 🤖 bump blade-formatter to 1.30.2 ([7bf0057](https://github.com/shufo/prettier-plugin-blade/commit/7bf00579df1531732d9cf5431f8fefb58e07a20e))
* **deps:** update pozil/auto-assign-issue action to v1.11.0 ([f483a27](https://github.com/shufo/prettier-plugin-blade/commit/f483a27fdc03b54c492f9d864c10720c3ba1fb89))
## [1.7.1](https://github.com/shufo/prettier-plugin-blade/compare/v1.7.0...v1.7.1) (2022-10-10)
### Miscellaneous
* 🤖 bump blade-formatter to 1.30.1 ([b0c96cd](https://github.com/shufo/prettier-plugin-blade/commit/b0c96cd1e6aa096cdb0cfc23187edb7735a6f28c))
## [1.7.0](https://github.com/shufo/prettier-plugin-blade/compare/v1.6.3...v1.7.0) (2022-10-09)
### Features
* 🎸 add option `--no-php-syntax-check` ([f710459](https://github.com/shufo/prettier-plugin-blade/commit/f7104593c4316d8ca7742b74c516fc3611e26536))
### Miscellaneous
* 🤖 bump blade-formatter to 1.30.0 ([6bf2b50](https://github.com/shufo/prettier-plugin-blade/commit/6bf2b50ec622574f378855a5826c48a670538275))
* **deps:** update pozil/auto-assign-issue action to v1.10.1 ([7775bdb](https://github.com/shufo/prettier-plugin-blade/commit/7775bdb0541d656ddd26b3932401d5e33ff5abc3))
## [1.6.3](https://github.com/shufo/prettier-plugin-blade/compare/v1.6.2...v1.6.3) (2022-10-01)
### Miscellaneous
* 🤖 bump blade-formatter to 1.29.8 ([1c9152e](https://github.com/shufo/prettier-plugin-blade/commit/1c9152e71cf3ac912c3dc3adc9e7dbe16a1e7539))
## [1.6.2](https://github.com/shufo/prettier-plugin-blade/compare/v1.6.1...v1.6.2) (2022-09-24)
### Miscellaneous
* 🤖 bump blade-formatter to 1.29.7 ([ac6d4c8](https://github.com/shufo/prettier-plugin-blade/commit/ac6d4c8eff19a7f1db59b785b42b1d2be337a936))
## [1.6.1](https://github.com/shufo/prettier-plugin-blade/compare/v1.6.0...v1.6.1) (2022-09-21)
### Miscellaneous
* 🤖 bump blade-formatter to 1.29.5 ([83e1e61](https://github.com/shufo/prettier-plugin-blade/commit/83e1e6163fcf10ea2c1cd9a5bb20d85b41427c92))
## [1.6.0](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.7...v1.6.0) (2022-09-19)
### Features
* 🎸 add option `--tailwindcss-config-path` ([d27adcc](https://github.com/shufo/prettier-plugin-blade/commit/d27adcc1d90c57461bfe3b12727613720aa364aa))
### Miscellaneous
* 🤖 add concat-stream to dev-dependencies ([b23cef4](https://github.com/shufo/prettier-plugin-blade/commit/b23cef4ec4849769298efb9c85fbe88fbeb6c68d))
* 🤖 bump blade-formatter to 1.29.0 ([27ccc95](https://github.com/shufo/prettier-plugin-blade/commit/27ccc9546ae1eb60d8bcebbd7aeeb9f565e54cb4))
* 🤖 bump blade-formatter to 1.29.2 ([9c713b2](https://github.com/shufo/prettier-plugin-blade/commit/9c713b2e84c50f716148bc1c4bf90ddeaafcf0f3))
### Fixes
* 🐛 config path is not calculated relative to .prettierrc ([0f7d959](https://github.com/shufo/prettier-plugin-blade/commit/0f7d959235ae5ef09eb9ddd3d5ff697165b8affa))
* 🐛 support for cases where prettierrc.json needs lookup ([84d2b66](https://github.com/shufo/prettier-plugin-blade/commit/84d2b66709cff9092d5abe0bffc01fbd50e51a32))
## [1.5.7](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.6...v1.5.7) (2022-09-11)
### Miscellaneous
* 🤖 bump blade-formatter to 1.28.0 ([1393f3f](https://github.com/shufo/prettier-plugin-blade/commit/1393f3f6dbf90c87586b4ee4343d6201afa1f53a))
* **deps:** update dependency ts-jest to v29 ([c5a9f99](https://github.com/shufo/prettier-plugin-blade/commit/c5a9f991ec10652145cef5eb20d0d164d663b12d))
## [1.5.6](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.5...v1.5.6) (2022-09-03)
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.7 ([993aed8](https://github.com/shufo/prettier-plugin-blade/commit/993aed84c339dbd92f253e4f92f4f135543f0d87))
* **deps:** bump synckit from 0.8.3 to 0.8.4 ([59974b2](https://github.com/shufo/prettier-plugin-blade/commit/59974b289d3c7941b9149067a986b12d126c424c))
## [1.5.5](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.4...v1.5.5) (2022-08-28)
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.6 ([59ecd46](https://github.com/shufo/prettier-plugin-blade/commit/59ecd46e83c3c19c3b101e277a12fa318cebcb70))
* **deps:** update dependency jest to v29 ([fa92c70](https://github.com/shufo/prettier-plugin-blade/commit/fa92c70f1d949e4e2ba7e9f2c9574981de1afc7d))
## [1.5.4](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.3...v1.5.4) (2022-08-22)
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.5 ([bae10a7](https://github.com/shufo/prettier-plugin-blade/commit/bae10a7b69f6f39aec3bc9c47d3bc12d019ce2d5))
* **deps:** bump synckit from 0.8.1 to 0.8.3 ([3659513](https://github.com/shufo/prettier-plugin-blade/commit/365951323cec9f6112ecb1ffcdc87cd248ab33f2))
* **deps:** update pozil/auto-assign-issue action to v1.10.0 ([40a5376](https://github.com/shufo/prettier-plugin-blade/commit/40a53762fcabcc5b2fa9b16ba22803e136946b5b))
## [1.5.3](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.2...v1.5.3) (2022-08-13)
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.4 ([ca2d496](https://github.com/shufo/prettier-plugin-blade/commit/ca2d496514ac16d8c35adf343cb3d1818ba345f0))
* **deps:** update dependency esbuild to ^0.15.0 ([2730657](https://github.com/shufo/prettier-plugin-blade/commit/2730657225e21ada594855bf830b0cb01fcf7e7b))
## [1.5.2](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.1...v1.5.2) (2022-08-09)
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.2 ([801858b](https://github.com/shufo/prettier-plugin-blade/commit/801858bea4c5194a094187b67ad5109d4f765ec1))
## [1.5.1](https://github.com/shufo/prettier-plugin-blade/compare/v1.5.0...v1.5.1) (2022-08-08)
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.1 ([1009ca0](https://github.com/shufo/prettier-plugin-blade/commit/1009ca0de2da88e870e7382aad1c24e38b09e05b))
## [1.5.0](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.22...v1.5.0) (2022-08-08)
### Features
* 🎸 sort html attributes option ([e43c6e2](https://github.com/shufo/prettier-plugin-blade/commit/e43c6e2f2e5dcb7ab431cb90c647ea18aae36168))
### Miscellaneous
* 🤖 bump blade-formatter to 1.27.0 ([c00a43e](https://github.com/shufo/prettier-plugin-blade/commit/c00a43e5a469659a0de035e5aa22e4da642f64ac))
* **deps:** update akhilmhdh/contributors-readme-action action to v2.3.5 ([4e713ad](https://github.com/shufo/prettier-plugin-blade/commit/4e713adf11e2f39b42c21a8b599a0adceda21a82))
* **deps:** update akhilmhdh/contributors-readme-action action to v2.3.6 ([8f4c5b1](https://github.com/shufo/prettier-plugin-blade/commit/8f4c5b11383b9a67c89cbf881d8fa82f530201a1))
* **deps:** update pozil/auto-assign-issue action to v1.9.0 ([e012784](https://github.com/shufo/prettier-plugin-blade/commit/e01278439a4f530217c2a40cd43897bf15b0b3f9))
### Fixes
* 🐛 support prettier's no multiple empty lines behaviour ([fb64b85](https://github.com/shufo/prettier-plugin-blade/commit/fb64b85f14eedeb4552929a3f70115c551b09b00))
## [1.4.22](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.21...v1.4.22) (2022-07-31)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.17 ([5108a3c](https://github.com/shufo/prettier-plugin-blade/commit/5108a3ce70733df1895da114a5baed2c47c446b4))
## [1.4.21](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.20...v1.4.21) (2022-07-28)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.16 ([c4b9d54](https://github.com/shufo/prettier-plugin-blade/commit/c4b9d54fe66f0bbd47cec56defa7fd3605f93e45))
## [1.4.20](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.19...v1.4.20) (2022-07-26)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.15 ([af175df](https://github.com/shufo/prettier-plugin-blade/commit/af175df773c662d98fe468ed1e205699e7de75c8))
## [1.4.19](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.18...v1.4.19) (2022-07-20)
### Fixes
* **deps:** update dependency synckit to ^0.8.0 ([bf488b0](https://github.com/shufo/prettier-plugin-blade/commit/bf488b088a625933e2021c1f151b3cb03e783d58))
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.14 ([bf6a34d](https://github.com/shufo/prettier-plugin-blade/commit/bf6a34d8b4e32ed0b54bcd2b745f6d17a9556d8c))
* **deps:** bump synckit from 0.8.0 to 0.8.1 ([b262b5b](https://github.com/shufo/prettier-plugin-blade/commit/b262b5bb0ba55c121c02568e0baabba9e9dc90c0))
* **deps:** update pozil/auto-assign-issue action to v1.8.0 ([f781f24](https://github.com/shufo/prettier-plugin-blade/commit/f781f24bec9588ed71c0952bdafc3394d2041adb))
## [1.4.18](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.17...v1.4.18) (2022-07-12)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.13 ([df90dc9](https://github.com/shufo/prettier-plugin-blade/commit/df90dc978899d1dc83a4c67314a58d2961652e9b))
## [1.4.17](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.16...v1.4.17) (2022-07-06)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.12 ([a4bb6b8](https://github.com/shufo/prettier-plugin-blade/commit/a4bb6b861c032ff7b32d5254248c5bdbcbced794))
* **deps:** bump synckit from 0.7.1 to 0.7.2 ([79fa3e1](https://github.com/shufo/prettier-plugin-blade/commit/79fa3e1d4e6e9f45411a1da448afab0ca894c9d4))
## [1.4.16](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.15...v1.4.16) (2022-07-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.11 ([042a75d](https://github.com/shufo/prettier-plugin-blade/commit/042a75dd530f80532a57e1c50753d32dad03278d))
* **deps-dev:** bump @typescript-eslint/parser from 5.10.1 to 5.11.0 ([4198cfc](https://github.com/shufo/prettier-plugin-blade/commit/4198cfc4902b21853ec362846bd4f53fc17f14fe))
* **deps:** update pozil/auto-assign-issue action to v1.7.3 ([8a4aabc](https://github.com/shufo/prettier-plugin-blade/commit/8a4aabc062a03cbbae2916923930748885d2c4d0))
## [1.4.15](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.14...v1.4.15) (2022-06-21)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.10 ([263a12c](https://github.com/shufo/prettier-plugin-blade/commit/263a12ca6a2ed573b4d909b4357fed042d2228d5))
## [1.4.14](https://github.com/shufo/prettier-plugin-blade/compare/v1.4.13...v1.4.14) (2022-06-19)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.9 ([2361324](https://github.com/shufo/prettier-plugin-blade/commit/236132443702b909d5a7aa0e085e434a45601fca))
* **deps:** update actions/cache action to v3 ([307d33e](https://github.com/shufo/prettier-plugin-blade/commit/307d33e28e49bc7fa318460537a33db5af0a0a8d))
* **deps:** update actions/checkout action to v3 ([6c69006](https://github.com/shufo/prettier-plugin-blade/commit/6c69006b8107a12f3483490295bc162e4a0f8101))
* **deps:** update actions/setup-node action to v3 ([12b6415](https://github.com/shufo/prettier-plugin-blade/commit/12b6415dcc7035ae8f8f6d5e39c8d54dd297835b))
* **deps:** update cirrus-actions/rebase action to v1.7 ([5da5d80](https://github.com/shufo/prettier-plugin-blade/commit/5da5d809816262cec9b6b7241ad4e5d1a78fcf3e))
* **deps:** update codecov/codecov-action action to v3 ([694f668](https://github.com/shufo/prettier-plugin-blade/commit/694f66861b4b1e5891317e3a25a79a1ebbf7e635))
* **deps:** update googlecloudplatform/release-please-action action to v3 ([4d2db4a](https://github.com/shufo/prettier-plugin-blade/commit/4d2db4a9c1286b3c5e4f18f269c595035f624465))
* **deps:** update jest monorepo to v28 ([edc4174](https://github.com/shufo/prettier-plugin-blade/commit/edc4174e3acb79a9cc94f3bfae7bf6522f850a83))
* **deps:** update pozil/auto-assign-issue action to v1.7.0 ([5bb7c0a](https://github.com/shufo/prettier-plugin-blade/commit/5bb7c0a795b934264d7ec1043e172f857d3764ad))
### [1.4.13](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.12...v1.4.13) (2022-06-18)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.8 ([8549777](https://www.github.com/shufo/prettier-plugin-blade/commit/8549777a1dbfa90ab8d46fd1c5a8d14473b0efd6))
### [1.4.12](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.11...v1.4.12) (2022-06-15)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.7 ([e197db9](https://www.github.com/shufo/prettier-plugin-blade/commit/e197db9a7d16a7055bf7792f7c87bea627b43fec))
### [1.4.11](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.10...v1.4.11) (2022-06-10)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.6 ([65c3d81](https://www.github.com/shufo/prettier-plugin-blade/commit/65c3d817323d270644b2f30974ed62c05b13c6c1))
### [1.4.10](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.9...v1.4.10) (2022-06-05)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.5 ([9a48202](https://www.github.com/shufo/prettier-plugin-blade/commit/9a48202d09f3ab476449f43a1e9d711b0fe985b3))
### [1.4.9](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.8...v1.4.9) (2022-06-05)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.4 ([df62766](https://www.github.com/shufo/prettier-plugin-blade/commit/df62766699c3b8db43a7482203afadffabb15921))
### [1.4.8](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.7...v1.4.8) (2022-06-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.3 ([b32ab07](https://www.github.com/shufo/prettier-plugin-blade/commit/b32ab070c3f5f47b45922c9d866255600581810c))
### [1.4.7](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.6...v1.4.7) (2022-06-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.2 ([8f7d75f](https://www.github.com/shufo/prettier-plugin-blade/commit/8f7d75f94076f9e720800677afd8f9be86264d6a))
### [1.4.6](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.5...v1.4.6) (2022-05-21)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.1 ([71c4d1c](https://www.github.com/shufo/prettier-plugin-blade/commit/71c4d1c47d01d891cec84eb3dfb52a217bd24085))
* **deps:** bump minimist from 1.2.5 to 1.2.6 ([fe3714f](https://www.github.com/shufo/prettier-plugin-blade/commit/fe3714ff45d27bb1e26d1ff0f55d71d35242481a))
### [1.4.5](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.4...v1.4.5) (2022-05-19)
### Miscellaneous
* 🤖 bump blade-formatter to 1.26.0 ([85a7784](https://www.github.com/shufo/prettier-plugin-blade/commit/85a77842246dd67c7bd02418530e83c557bc3782))
### [1.4.4](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.3...v1.4.4) (2022-05-17)
### Miscellaneous
* 🤖 bump blade-formatter to 1.25.4 ([b7ebc16](https://www.github.com/shufo/prettier-plugin-blade/commit/b7ebc1672b86474a53306104b030c30c02e6f478))
### [1.4.3](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.2...v1.4.3) (2022-05-15)
### Miscellaneous
* 🤖 bump blade-formatter to 1.25.3 ([2f613ef](https://www.github.com/shufo/prettier-plugin-blade/commit/2f613efde99e91a3ee0d9d0965a7cb81530ee5f6))
### [1.4.2](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.1...v1.4.2) (2022-05-14)
### Miscellaneous
* 🤖 bump blade-formatter to 1.25.2 ([3e2b965](https://www.github.com/shufo/prettier-plugin-blade/commit/3e2b965b05f0609a72e6ec51b38bad51e2f4364c))
### [1.4.1](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.4.0...v1.4.1) (2022-05-13)
### Miscellaneous
* 🤖 bump blade-formatter to 1.25.1 ([7e5367f](https://www.github.com/shufo/prettier-plugin-blade/commit/7e5367f01c979c2fc7753e922184a0f4d27187b3))
## [1.4.0](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.6...v1.4.0) (2022-05-12)
### Miscellaneous
* 🤖 bump blade-formatter to 1.25.0 ([8428d7e](https://www.github.com/shufo/prettier-plugin-blade/commit/8428d7ee7961bcafdab8547d522cb1c050fbd83f))
* **deps-dev:** bump eslint from 8.7.0 to 8.8.0 ([ad58451](https://www.github.com/shufo/prettier-plugin-blade/commit/ad58451204cd6730f689bc1d26c5e8b721292481))
* **deps:** bump synckit from 0.7.0 to 0.7.1 ([716fe36](https://www.github.com/shufo/prettier-plugin-blade/commit/716fe36de48aaba70dca692cf94ef519e682ce81))
* release 1.4.0 ([8626c24](https://www.github.com/shufo/prettier-plugin-blade/commit/8626c2414bf7da28fc8dff58dda2594d40276fde))
### [1.3.6](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.5...v1.3.6) (2022-05-07)
### Miscellaneous
* 🤖 bump blade-formatter to 1.24.0 ([15009f1](https://www.github.com/shufo/prettier-plugin-blade/commit/15009f1881182eecbac3f281394527b3c553c91a))
### [1.3.5](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.4...v1.3.5) (2022-05-03)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.8 ([d685346](https://www.github.com/shufo/prettier-plugin-blade/commit/d685346430a401df066508dc810cd23e011e1a03))
### [1.3.4](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.3...v1.3.4) (2022-05-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.7 ([824b514](https://www.github.com/shufo/prettier-plugin-blade/commit/824b514efe8d7230ff6a9d281369f66bf10311b7))
### [1.3.3](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.2...v1.3.3) (2022-05-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.6 ([6c64436](https://www.github.com/shufo/prettier-plugin-blade/commit/6c6443655510ac6a931b7966e7905ee5fe0efb8a))
### [1.3.2](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.1...v1.3.2) (2022-04-27)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.5 ([49c0940](https://www.github.com/shufo/prettier-plugin-blade/commit/49c09401ce86957cddeb345b8a9c1f76b47b25c4))
### [1.3.1](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.3.0...v1.3.1) (2022-04-25)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.3 ([abd2961](https://www.github.com/shufo/prettier-plugin-blade/commit/abd29612e9e26c3922a043376e18369ee92e9cd5))
## [1.3.0](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.6...v1.3.0) (2022-04-24)
### Features
* 🎸 bracketSameLine option ([6b89032](https://www.github.com/shufo/prettier-plugin-blade/commit/6b89032f18641785547d9c74b36d5e0bdde4f535))
### [1.2.6](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.5...v1.2.6) (2022-04-17)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.2 ([8984d04](https://www.github.com/shufo/prettier-plugin-blade/commit/8984d049c67a80c4a8a491669604313032279c94))
* **deps:** bump prettier from 2.6.1 to 2.6.2 ([55a7f08](https://www.github.com/shufo/prettier-plugin-blade/commit/55a7f088dedc6f9bfd120232465c2654c5950ad3))
### [1.2.5](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.4...v1.2.5) (2022-04-15)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.1 ([197a226](https://www.github.com/shufo/prettier-plugin-blade/commit/197a22675444c577542abdb9425b42cc66ac2043))
* **deps:** bump synckit from 0.6.0 to 0.7.0 ([ea8407f](https://www.github.com/shufo/prettier-plugin-blade/commit/ea8407f3e5c2f5c21272959bd403ae5c262a43e5))
### [1.2.4](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.3...v1.2.4) (2022-04-03)
### Miscellaneous
* 🤖 bump blade-formatter to 1.23.0 ([34768aa](https://www.github.com/shufo/prettier-plugin-blade/commit/34768aa6716d1d3a399dcbc478b6203734091cb2))
### [1.2.3](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.2...v1.2.3) (2022-04-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.22.3 ([79304a0](https://www.github.com/shufo/prettier-plugin-blade/commit/79304a0e4c59b6b0f13f96d86ff36bf29ba8e28d))
### [1.2.2](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.1...v1.2.2) (2022-03-29)
### Miscellaneous
* 🤖 bump blade-formatter to 1.22.2 ([6ce7e41](https://www.github.com/shufo/prettier-plugin-blade/commit/6ce7e41f10c58f0eec027968ea4c38539c8daf12))
* **deps:** bump prettier from 2.6.0 to 2.6.1 ([6788dad](https://www.github.com/shufo/prettier-plugin-blade/commit/6788dad7bb22de016557abb7c379b5ac5265476e))
### [1.2.1](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.2.0...v1.2.1) (2022-03-25)
### Miscellaneous
* 🤖 bump blade-formatter to 1.22.1 ([02efc64](https://www.github.com/shufo/prettier-plugin-blade/commit/02efc64fef77624c26620f567c2145438a516556))
## [1.2.0](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.11...v1.2.0) (2022-03-25)
### Features
* 🎸 singleAttributePerLine option ([993cf77](https://www.github.com/shufo/prettier-plugin-blade/commit/993cf777e07cc5bfedf48137100b3aaa87961a37))
### Miscellaneous
* 🤖 bump @types/prettier to 2.4.4 ([d214534](https://www.github.com/shufo/prettier-plugin-blade/commit/d21453485aaae1222b67a53e40e5e98411bfaac2))
### [1.1.11](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.10...v1.1.11) (2022-03-23)
### Miscellaneous
* 🤖 bump blade-formatter to 1.22.0 ([ef7e258](https://www.github.com/shufo/prettier-plugin-blade/commit/ef7e258a17cf166c82e5b49df27905d24cf76e15))
### [1.1.10](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.9...v1.1.10) (2022-03-19)
### Miscellaneous
* 🤖 bump blade-formatter to 1.21.5 ([9b5e230](https://www.github.com/shufo/prettier-plugin-blade/commit/9b5e230b39b9293e128466b7c5884595f58e4f70))
### [1.1.9](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.8...v1.1.9) (2022-03-18)
### Miscellaneous
* 🤖 bump blade-formatter to 1.21.4 ([ee04321](https://www.github.com/shufo/prettier-plugin-blade/commit/ee0432116da6c68cf12534d00ed44e5fd00ae531))
### [1.1.8](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.7...v1.1.8) (2022-03-14)
### Miscellaneous
* 🤖 bump blade-formatter to 1.21.3 ([ed62c2c](https://www.github.com/shufo/prettier-plugin-blade/commit/ed62c2c26796307d7fdbca294901843c4ee89845))
### [1.1.7](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.6...v1.1.7) (2022-03-13)
### Miscellaneous
* 🤖 bump blade-formatter to 1.21.2 ([5a518e1](https://www.github.com/shufo/prettier-plugin-blade/commit/5a518e11fd705baae30e7aca736d7d7e4d320bac))
### [1.1.6](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.5...v1.1.6) (2022-03-12)
### Miscellaneous
* 🤖 bump blade-formatter to 1.21.1 ([4aa52ab](https://www.github.com/shufo/prettier-plugin-blade/commit/4aa52ab514ab50cf24ad2c9520a1908f1dee691a))
### [1.1.5](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.4...v1.1.5) (2022-03-09)
### Miscellaneous
* 🤖 bump blade-formatter to 1.21.0 ([dcd4fd0](https://www.github.com/shufo/prettier-plugin-blade/commit/dcd4fd0a180134f964f7de95f139a1179de9b136))
### [1.1.4](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.3...v1.1.4) (2022-03-05)
### Miscellaneous
* 🤖 bump blade-formatter to 1.20.5 ([c44cd9e](https://www.github.com/shufo/prettier-plugin-blade/commit/c44cd9e60dc6de52c9e008ad4ec0e4cb14ae0861))
### [1.1.3](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.2...v1.1.3) (2022-03-03)
### Miscellaneous
* 🤖 bump blade-formatter to 1.20.4 ([0817eab](https://www.github.com/shufo/prettier-plugin-blade/commit/0817eab5afd18329e4afea4cac6d2879ce4077d3))
### [1.1.2](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.1...v1.1.2) (2022-03-03)
### Miscellaneous
* 🤖 bump blade-formatter to 1.20.3 ([a1012c3](https://www.github.com/shufo/prettier-plugin-blade/commit/a1012c3bfb87fd503d5fd22e93b96973a094c0d7))
### [1.1.1](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.1.0...v1.1.1) (2022-03-02)
### Miscellaneous
* 🤖 bump blade-formatter to 1.20.2 ([49230ee](https://www.github.com/shufo/prettier-plugin-blade/commit/49230ee37ecc806afe9391c52a8a93870af1d642))
## [1.1.0](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.11...v1.1.0) (2022-02-27)
### Features
* 🎸 add automatic Tailwind Css class sorting option ([87a2a1f](https://www.github.com/shufo/prettier-plugin-blade/commit/87a2a1f3a6bd363c37ebbc91dedccbb9e12628e0))
### Miscellaneous
* 🤖 bump blade-formatter to 1.20.1 ([f02df0b](https://www.github.com/shufo/prettier-plugin-blade/commit/f02df0bb1181a0bda96970c6501a2ffd23c331d2))
* 🤖 enable tailwindcss class sort behaviour by default ([6608c9e](https://www.github.com/shufo/prettier-plugin-blade/commit/6608c9eed713ab4b73e811de734d7d56942808ca))
### [1.0.11](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.10...v1.0.11) (2022-02-23)
### Miscellaneous
* 🤖 bump blade-formatter to 1.19.0 ([505da42](https://www.github.com/shufo/prettier-plugin-blade/commit/505da42362e952ce40c63f93311cac7110fa125f))
### [1.0.10](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.9...v1.0.10) (2022-02-21)
### Miscellaneous
* 🤖 bump blade-formatter to 1.18.6 ([6db527d](https://www.github.com/shufo/prettier-plugin-blade/commit/6db527d3b19f78a42009b502370f773282286937))
### [1.0.9](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.8...v1.0.9) (2022-02-20)
### Miscellaneous
* 🤖 bump blade-formatter to 1.18.5 ([d90be2f](https://www.github.com/shufo/prettier-plugin-blade/commit/d90be2f37d0aa06aac89cfc61a132f2135b201f8))
### [1.0.8](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.7...v1.0.8) (2022-02-13)
### Miscellaneous
* 🤖 bump blade-formatter to 1.18.4 ([0482f97](https://www.github.com/shufo/prettier-plugin-blade/commit/0482f9798ace408db600fca315c51079351252b8))
### [1.0.7](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.6...v1.0.7) (2022-02-13)
### Miscellaneous
* 🤖 bump blade-formatter to 1.18.3 ([0dd52fd](https://www.github.com/shufo/prettier-plugin-blade/commit/0dd52fd31846d13dc6c3aa0a63eda8dc46ab0e0b))
### [1.0.6](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.5...v1.0.6) (2022-02-09)
### Miscellaneous
* 🤖 bump blade-formatter to 1.17.5 ([363e74d](https://www.github.com/shufo/prettier-plugin-blade/commit/363e74dc2617f3fa6f2214d4885935e65b9d1eff))
### [1.0.5](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.4...v1.0.5) (2022-02-08)
### Miscellaneous
* 🤖 bump blade-formatter to 1.17.4 ([8343867](https://www.github.com/shufo/prettier-plugin-blade/commit/83438670be7c7faa68c227442eb6ae67e74d7473))
### [1.0.4](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.3...v1.0.4) (2022-02-06)
### Miscellaneous
* 🤖 add codecov to dev-dependencies ([9c247ed](https://www.github.com/shufo/prettier-plugin-blade/commit/9c247edfe8569a842d7bc1e5769f02acde40fbad))
* 🤖 add ignore pattern ([982483b](https://www.github.com/shufo/prettier-plugin-blade/commit/982483bdfca20eec56e6476767458151e89691b9))
* 🤖 bump blade-formatter to 1.17.3 ([e82c73e](https://www.github.com/shufo/prettier-plugin-blade/commit/e82c73e6395a50c714e1b5e1114a7d049573eff0))
### [1.0.3](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.2...v1.0.3) (2022-01-29)
### Miscellaneous
* 🤖 bump blade-formatter to 1.17.2 ([cd6522e](https://www.github.com/shufo/prettier-plugin-blade/commit/cd6522e33051cbf51743b1836e77c0a0f75f0f29))
### [1.0.2](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.1...v1.0.2) (2022-01-27)
### Miscellaneous
* 🤖 add synckit to dependencies ([9515a19](https://www.github.com/shufo/prettier-plugin-blade/commit/9515a19265313158fdc37fb15c6be38e0b26635f))
* 🤖 drop execa from dependencies ([ed39de9](https://www.github.com/shufo/prettier-plugin-blade/commit/ed39de90d5c4b5b343bd1a48fc00bef0a5a153b2))
### Performance
* ⚡️ use synckit worker to gain throuhput on format ([c9c0839](https://www.github.com/shufo/prettier-plugin-blade/commit/c9c0839bfb3ed46a0e2f4ecfc7e683e3c87a8872))
### [1.0.1](https://www.github.com/shufo/prettier-plugin-blade/compare/v1.0.0...v1.0.1) (2022-01-27)
### Miscellaneous
* release 1.0.1 ([7f6c7c2](https://www.github.com/shufo/prettier-plugin-blade/commit/7f6c7c270e734557e82d36b55729f3d1e47f290d))
## 1.0.0 (2022-01-27)
### Miscellaneous
* 🤖 add .gitattributes ([b0b24c9](https://www.github.com/shufo/prettier-plugin-blade/commit/b0b24c99548734575c4ba693c9fea7377256c6dc))
* 🤖 add cross-env to dependencies ([6daea74](https://www.github.com/shufo/prettier-plugin-blade/commit/6daea749403f2d019c258ffef679c06e03527904))
* 🤖 drop support for node under 14.x ([3e8a6cf](https://www.github.com/shufo/prettier-plugin-blade/commit/3e8a6cfaec8e3da7c78299ef3c46860311324e24))
* Initialize ([dab21bb](https://www.github.com/shufo/prettier-plugin-blade/commit/dab21bbe47fbf5fe16147f4ff8895e0ccb116a35))
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Shuhei Hayashibara
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,346 @@
<div align="center">
<img alt="Prettier"
src="https://raw.githubusercontent.com/prettier/prettier-logo/master/images/prettier-icon-light.png">
<img alt="PHP" height="180" hspace="25" vspace="15"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Laravel.svg/500px-Laravel.svg.png">
</div>
<h2 align="center">Prettier Blade Plugin</h2>
<p align="center">
<a href="https://github.com/shufo/prettier-plugin-blade/actions">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/shufo/prettier-plugin-blade/node.yml?style=flat-square">
</a>
<a href="https://www.npmjs.com/package/@prettier/plugin-php">
<img alt="npm version" src="https://img.shields.io/npm/v/@shufo/prettier-plugin-blade.svg?style=flat-square">
</a>
</p>
Format your blade template using Prettier
## Features
- Automatically indent markup inside directives
- Automatically add spacing to blade template markers
- PHP 8 syntax support (null safe operator, named arguments)
- Compliant to PSR-2 coding standard (PHP code inside directives)
- Automatically sort Tailwind CSS classes with respect of `tailwind.config.js`
## Installation
```bash
$ npm install --save-dev @shufo/prettier-plugin-blade prettier
# yarn
$ yarn add -D @shufo/prettier-plugin-blade prettier
# pnpm
$ pnpm add -D @shufo/prettier-plugin-blade prettier
```
then, add in your [Prettier configuration](https://prettier.io/docs/en/configuration.html):
```json
{
"plugins": [
"@shufo/prettier-plugin-blade",
],
"overrides": [
{
"files": ["*.blade.php"],
"options": {
"parser": "blade"
"tabWidth": 4,
}
}
]
}
```
## Usage (CLI)
```bash
$ ./node_modules/.bin/prettier --write resources/**/*.blade.php
```
https://user-images.githubusercontent.com/1641039/151354641-6305805e-8e0c-4226-8331-64195f85160e.mp4
## Example
### Input
```blade
@extends('frontend.layouts.app')
@section('title') foo
@endsection
@section('content')
<section id="content">
<div class="container mod-users-pd-h">
<div class="pf-user-header">
<div></div>
<p>@lang('users.index')</p>
</div>
<div class="pf-users-branch">
<ul class="pf-users-branch__list">
@foreach ($users as $user)
<li>
<img src="{{ asset('img/frontend/icon/branch-arrow.svg') }}" alt="branch_arrow">
{{ link_to_route('frontend.users.user.show', $users['name'], $users['_id']) }}
</li>
@endforeach
</ul>
<div class="pf-users-branch__btn">
@can('create', App\Models\User::class)
{!! link_to_route('frontend.users.user.create', __('users.create'), [1, 2, 3], ['class' => 'btn']) !!}
@endcan
</div>
</div>
</div>
</section>
@endsection
@section('footer')
@stop
```
### Output
```blade
@extends('frontend.layouts.app')
@section('title') foo
@endsection
@section('content')
<section id="content">
<div class="container mod-users-pd-h">
<div class="pf-user-header">
<div></div>
<p>@lang('users.index')</p>
</div>
<div class="pf-users-branch">
<ul class="pf-users-branch__list">
@foreach ($users as $user)
<li>
<img src="{{ asset('img/frontend/icon/branch-arrow.svg') }}" alt="branch_arrow">
{{ link_to_route('frontend.users.user.show', $users['name'], $users['_id']) }}
</li>
@endforeach
</ul>
<div class="pf-users-branch__btn">
@can('create', App\Models\User::class)
{!! link_to_route('frontend.users.user.create', __('users.create'), [1, 2, 3], ['class' => 'btn']) !!}
@endcan
</div>
</div>
</div>
</section>
@endsection
@section('footer')
@stop
```
## Options
You can use these options for prettier blade plugin in prettier CLI.
| key | description |
| ---------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--tab-width` | Number of spaces per indentation level. default: `4` |
| `--print-width` | The line length where Prettier will try wrap. default: `120` |
| `--wrap-attributes` | The way to wrap attributes. [`auto`\|`force`\|`force-aligned`\|`force-expand-multiline`\|`aligned-multiple`\|`preserve`\|`preserve-aligned`]. default: `auto` |
| `--end-with-new-line` | End output with newline. default: `true` |
| `--sort-tailwindcss-classes` | Sort Tailwind CSS classes. It will automatically look for and respect `tailwind.config.js` if it exists. default: `false` |
| `--tailwindcss-config-path` | Path to your custom Tailwind configuration file. This option is only available if `--sort-tailwindcss-classes` is present. default: `''` |
| `--sort-html-attributes` | Sort HTML Attributes in the specified order. [`none` \| `alphabetical` \| [`code-guide`](https://codeguide.co/) \| [`idiomatic`](https://github.com/necolas/idiomatic-html#attribute-order) \| [`vuejs`](https://eslint.vuejs.org/rules/attributes-order.html)] default: `none` |
| `--no-php-syntax-check` | Disable PHP syntax checking. default: `false` |
### `.prettierrc` example
```json
{
"printWidth": 120,
"tabWidth": 4,
"wrapAttributes": "auto",
"sortTailwindcssClasses": true,
"sortHtmlAttributes": "none",
"noPhpSyntaxCheck": false
}
```
## Disabling format in file
To disable formatting in your file, you can use blade/html comments in the following format:
```blade
{{-- prettier-ignore-start --}}
{{ $foo }}
{{ $bar }}
{{-- prettier-ignore-end --}}
or
<!-- prettier-ignore-start -->
{{ $foo }}
{{ $bar }}
<!-- prettier-ignore-end -->
```
To disable formatting on a specific line, you can use comment in the following format:
```blade
{{-- prettier-ignore --}}
{{ $foo }}
or
<!-- prettier-ignore -->
{{ $foo }}
```
## Editor Integration
The editors below are confirmed to work with this plugin.
### VSCode
You can use [Prettier extension for VSCode](https://github.com/prettier/prettier-vscode) to format blade in VSCode. You need to install this plugin as a local dependency. see https://github.com/prettier/prettier-vscode#prettier-resolution
If you want to use a formatter without Prettier, please consider to use the [vscode-blade-formatter](https://github.com/shufo/vscode-blade-formatter) instead.
### Vim
You can use [coc-prettier](https://github.com/neoclide/coc-prettier) plugin on [coc.nvim](https://github.com/neoclide/coc.nvim)
If you want to use formater without Prettier, please consider to using [coc-blade](https://github.com/yaegassy/coc-blade)
### JetBrains WebStorm, PHPStorm, PyCharm...
You can use the [Prettier Plugin](https://plugins.jetbrains.com/plugin/10456-prettier) for JetBrains IDE.
Add extension setting `blade.php` to `File | Settings | Languages & Frameworks | JavaScript | Prettier | Run for files`:
e.g.
`{**/*,*}.{js,ts,jsx,tsx,blade.php}`
and turn on checkbox `On 'Reformat Code' action`
Restart your IDE if you get the error: 'Prettier: File \*.php has unsupported type'
## Limitation
This plugin is based on [blade-formatter](https://github.com/shufo/blade-formatter) which does not generate ASTs with lexer, so it might break indentation on complex blade.
Like:
- The mix of open/closed HTML tag and directives
❌ Example of **unexpected** code
```blade
@if ($user)
<div>
@else
</div>
@endif
```
⭕ Example of **expected** code
```blade
@if ($user)
<div>foo</div>
@else
<div>bar</div>
@endif
```
Please keep the blade template as simple as possible for better formatting.
## API
You can format the blade file programmatically using Prettier's API
```js
const prettier = require("prettier");
const input = `
<div>
@if ($user)
{{ $foo }}
@else
{{ $bar }}
@endif
</div>
`;
const res = prettier.format(input, { parser: "blade" });
console.log(res);
// =>
//<div>
// @if ($user)
// {{ $foo }}
// @else
// {{ $bar }}
// @endif
//</div>
```
## Development
```bash
$ yarn install
$ yarn run watch # watch changes
```
## Testing
```bash
$ yarn install
$ yarn run test
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Contributors
<!-- readme: collaborators,contributors -start -->
<table>
<tr>
<td align="center">
<a href="https://github.com/shufo">
<img src="https://avatars.githubusercontent.com/u/1641039?v=4" width="100;" alt="shufo"/>
<br />
<sub><b>Shuhei Hayashibara</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/howdu">
<img src="https://avatars.githubusercontent.com/u/533658?v=4" width="100;" alt="howdu"/>
<br />
<sub><b>Beej</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/ianjamieson">
<img src="https://avatars.githubusercontent.com/u/2786904?v=4" width="100;" alt="ianjamieson"/>
<br />
<sub><b>Ian Jamieson</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/mortenscheel">
<img src="https://avatars.githubusercontent.com/u/6514342?v=4" width="100;" alt="mortenscheel"/>
<br />
<sub><b>Morten Scheel</b></sub>
</a>
</td></tr>
</table>
<!-- readme: collaborators,contributors -end -->
## LICENSE
MIT
@@ -0,0 +1,2 @@
"use strict";var f=Object.create;var n=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var t in r)n(e,t,{get:r[t],enumerable:!0})},o=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of y(r))!w.call(e,s)&&s!==t&&n(e,s,{get:()=>r[s],enumerable:!(i=b(r,s))||i.enumerable});return e};var l=(e,r,t)=>(t=e!=null?f(h(e)):{},o(r||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),x=e=>o(n({},"__esModule",{value:!0}),e);var S={};P(S,{defaultOptions:()=>m,languages:()=>A,options:()=>g,parsers:()=>C,printers:()=>L});module.exports=x(S);var c=require("prettier"),d=require("synckit"),a=l(require("path")),p=(e,r,t)=>{let i={indentSize:t.tabWidth,wrapLineLength:t.printWidth,wrapAttributes:t.singleAttributePerLine?"force-expand-multiline":t.bracketSameLine?"force-aligned":t.wrapAttributes,endWithNewline:t.endWithNewline,useTabs:t.useTabs,sortTailwindcssClasses:t.sortTailwindcssClasses,tailwindcssConfigPath:T(t.filepath,t.tailwindcssConfigPath),sortHtmlAttributes:t.sortHtmlAttributes,noMultipleEmptyLines:!0,noPhpSyntaxCheck:t.noPhpSyntaxCheck,customHtmlAttributesOrder:t.customHtmlAttributesOrder};return{type:"blade-formatter",body:(0,d.createSyncFn)(require.resolve("../src/worker"))(e,i),end:e.length,source:e,start:0}};function T(e,r){if(!r)return;if(a.default.isAbsolute(r??""))return r;let t=c.resolveConfigFile.sync(e);return a.default.resolve(a.default.dirname(t??""),r??"")}var u=e=>{let r=e.getValue();switch(r.type){case"blade-formatter":return r.body}throw new Error(`Unknown node type: ${r.type}`)};var m={tabWidth:4,printWidth:120},g={wrapAttributes:{type:"string",category:"Blade",default:"auto",description:"The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]",since:"1.0.0"},endWithNewLine:{type:"boolean",category:"Blade",default:!0,description:"End output with newline.",since:"1.0.0"},sortTailwindcssClasses:{type:"boolean",category:"Blade",default:!1,description:"Sort Tailwindcss classes automatically. This option respects `tailwind.config.js`.",since:"1.0.0"},tailwindcssConfigPath:{type:"string",category:"Blade",default:"",description:"Path to custom Tailwindcss config. This option is available only when `sortTailwindcssClasses` is present.",since:"1.5.7"},sortHtmlAttributes:{type:"string",category:"Blade",default:"none",description:"Sort HTML Attributes. [none|alphabetical|code-guide|idiomatic|vuejs|custom]",since:"1.5.0"},customHtmlAttributesOrder:{type:"string",category:"Blade",default:"",description:'Comma separated custom HTML attributes order. e.g. "id, aria-.+, class, src". To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names.',since:"1.8.0"},noPhpSyntaxCheck:{type:"boolean",category:"Blade",default:!1,description:"Disable PHP syntax checking",since:"1.7.0"}};var A=[{name:"Blade",parsers:["blade"],since:"1.0.0",extensions:[".blade.php"],tmScope:"source.blade.php",aceMode:"text",linguistLanguageId:33,vscodeLanguageIds:["blade"]}],C={blade:{parse:p,astFormat:"blade-format",locStart(e){return e.start},locEnd(e){return e.end}}},L={"blade-format":{print:u}};0&&(module.exports={defaultOptions,languages,options,parsers,printers});
//# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../src/index.ts", "../src/parser.ts", "../src/printer.ts", "../src/options.ts"],
"sourcesContent": ["import { parse } from \"./parser\";\nimport { print } from \"./printer\";\nimport { options, defaultOptions } from \"./options\";\nimport { Parser, Printer, SupportLanguage } from \"prettier\";\n\nexport const languages: SupportLanguage[] = [\n {\n name: \"Blade\",\n parsers: [\"blade\"],\n since: \"1.0.0\",\n extensions: [\".blade.php\"],\n tmScope: \"source.blade.php\",\n aceMode: \"text\",\n linguistLanguageId: 33,\n vscodeLanguageIds: [\"blade\"],\n },\n];\n\nexport const parsers: { [k: string]: Parser } = {\n blade: {\n parse,\n astFormat: \"blade-format\",\n locStart(node: any) {\n return node.start;\n },\n locEnd(node: any) {\n return node.end;\n },\n },\n};\n\nexport const printers: { [k: string]: Printer } = {\n \"blade-format\": {\n print,\n },\n};\n\nexport { options, defaultOptions };\n", "import { Parser, ParserOptions, resolveConfigFile } from \"prettier\";\nimport { FormatterOption } from \"blade-formatter\";\nimport { createSyncFn } from \"synckit\";\nimport path from 'path';\n\nexport const parse = (\n text: string,\n parsers: { [parserName: string]: Parser },\n opts: ParserOptions & FormatterOption\n) => {\n const formatterOptions: FormatterOption = {\n indentSize: opts.tabWidth,\n wrapLineLength: opts.printWidth,\n wrapAttributes: opts.singleAttributePerLine ? 'force-expand-multiline' : opts.bracketSameLine ? 'force-aligned' : opts.wrapAttributes,\n endWithNewline: opts.endWithNewline,\n useTabs: opts.useTabs,\n sortTailwindcssClasses: opts.sortTailwindcssClasses,\n tailwindcssConfigPath: resolveTailwindConfigPath(opts.filepath, opts.tailwindcssConfigPath),\n sortHtmlAttributes: opts.sortHtmlAttributes,\n noMultipleEmptyLines: true,\n noPhpSyntaxCheck: opts.noPhpSyntaxCheck,\n customHtmlAttributesOrder: opts.customHtmlAttributesOrder,\n };\n\n const syncFn = createSyncFn(require.resolve(\"./worker\"));\n const result = syncFn(text, formatterOptions);\n\n return {\n type: \"blade-formatter\",\n body: result,\n end: text.length,\n source: text,\n start: 0,\n };\n};\n\nfunction resolveTailwindConfigPath(filepath: string | undefined, optionPath: string | undefined): string | undefined {\n if (!optionPath) {\n return;\n }\n\n if (path.isAbsolute(optionPath ?? '')) {\n return optionPath;\n }\n\n const prettierRcPath = resolveConfigFile.sync(filepath);\n\n return path.resolve(path.dirname(prettierRcPath ?? ''), optionPath ?? '')\n}", "import { AstPath, Doc } from \"prettier\";\n\nexport const print = (path: AstPath): Doc => {\n const node = path.getValue();\n\n switch (node.type) {\n case \"blade-formatter\": {\n return node.body;\n }\n }\n\n throw new Error(`Unknown node type: ${node.type}`);\n};\n", "export const defaultOptions = {\n tabWidth: 4,\n printWidth: 120,\n};\n\nexport const options = {\n wrapAttributes: {\n type: \"string\",\n category: \"Blade\",\n default: \"auto\",\n description:\n \"The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]\",\n since: \"1.0.0\",\n },\n endWithNewLine: {\n type: \"boolean\",\n category: \"Blade\",\n default: true,\n description: \"End output with newline.\",\n since: \"1.0.0\",\n },\n sortTailwindcssClasses: {\n type: \"boolean\",\n category: \"Blade\",\n default: false,\n description: \"Sort Tailwindcss classes automatically. This option respects `tailwind.config.js`.\",\n since: \"1.0.0\",\n },\n tailwindcssConfigPath: {\n type: \"string\",\n category: \"Blade\",\n default: '',\n description: \"Path to custom Tailwindcss config. This option is available only when `sortTailwindcssClasses` is present.\",\n since: \"1.5.7\",\n },\n sortHtmlAttributes: {\n type: \"string\",\n category: \"Blade\",\n default: \"none\",\n description: \"Sort HTML Attributes. [none|alphabetical|code-guide|idiomatic|vuejs|custom]\",\n since: \"1.5.0\",\n },\n customHtmlAttributesOrder: {\n type: \"string\",\n category: \"Blade\",\n default: \"\",\n description: \"Comma separated custom HTML attributes order. e.g. \\\"id, aria-.+, class, src\\\". To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names.\",\n since: \"1.8.0\",\n },\n noPhpSyntaxCheck: {\n type: \"boolean\",\n category: \"Blade\",\n default: false,\n description: \"Disable PHP syntax checking\",\n since: \"1.7.0\",\n },\n};\n\n"],
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,cAAAC,EAAA,YAAAC,EAAA,YAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAP,GCAA,IAAAQ,EAAyD,oBAEzDC,EAA6B,mBAC7BC,EAAiB,mBAEJC,EAAQ,CACnBC,EACAC,EACAC,IACG,CACH,IAAMC,EAAoC,CACxC,WAAYD,EAAK,SACjB,eAAgBA,EAAK,WACrB,eAAgBA,EAAK,uBAAyB,yBAA2BA,EAAK,gBAAkB,gBAAkBA,EAAK,eACvH,eAAgBA,EAAK,eACrB,QAASA,EAAK,QACd,uBAAwBA,EAAK,uBAC7B,sBAAuBE,EAA0BF,EAAK,SAAUA,EAAK,qBAAqB,EAC1F,mBAAoBA,EAAK,mBACzB,qBAAsB,GACtB,iBAAkBA,EAAK,iBACvB,0BAA2BA,EAAK,yBAClC,EAKA,MAAO,CACL,KAAM,kBACN,QALa,gBAAa,gBAAgB,eAAU,CAAC,EACjCF,EAAMG,CAAgB,EAK1C,IAAKH,EAAK,OACV,OAAQA,EACR,MAAO,CACT,CACF,EAEA,SAASI,EAA0BC,EAA8BC,EAAoD,CACnH,GAAI,CAACA,EACH,OAGF,GAAI,EAAAC,QAAK,WAAWD,GAAc,EAAE,EAClC,OAAOA,EAGT,IAAME,EAAiB,oBAAkB,KAAKH,CAAQ,EAEtD,OAAO,EAAAE,QAAK,QAAQ,EAAAA,QAAK,QAAQC,GAAkB,EAAE,EAAGF,GAAc,EAAE,CAC1E,CC9CO,IAAMG,EAASC,GAAuB,CAC3C,IAAMC,EAAOD,EAAK,SAAS,EAE3B,OAAQC,EAAK,KAAM,CACjB,IAAK,kBACH,OAAOA,EAAK,IAEhB,CAEA,MAAM,IAAI,MAAM,sBAAsBA,EAAK,MAAM,CACnD,ECZO,IAAMC,EAAiB,CAC5B,SAAU,EACV,WAAY,GACd,EAEaC,EAAU,CACrB,eAAgB,CACd,KAAM,SACN,SAAU,QACV,QAAS,OACT,YACE,2HACF,MAAO,OACT,EACA,eAAgB,CACd,KAAM,UACN,SAAU,QACV,QAAS,GACT,YAAa,2BACb,MAAO,OACT,EACA,uBAAwB,CACtB,KAAM,UACN,SAAU,QACV,QAAS,GACT,YAAa,qFACb,MAAO,OACT,EACA,sBAAuB,CACrB,KAAM,SACN,SAAU,QACV,QAAS,GACT,YAAa,6GACb,MAAO,OACT,EACA,mBAAoB,CAClB,KAAM,SACN,SAAU,QACV,QAAS,OACT,YAAa,8EACb,MAAO,OACT,EACA,0BAA2B,CACzB,KAAM,SACN,SAAU,QACV,QAAS,GACT,YAAa,gMACb,MAAO,OACT,EACA,iBAAkB,CAChB,KAAM,UACN,SAAU,QACV,QAAS,GACT,YAAa,8BACb,MAAO,OACT,CACF,EHnDO,IAAMC,EAA+B,CAC1C,CACE,KAAM,QACN,QAAS,CAAC,OAAO,EACjB,MAAO,QACP,WAAY,CAAC,YAAY,EACzB,QAAS,mBACT,QAAS,OACT,mBAAoB,GACpB,kBAAmB,CAAC,OAAO,CAC7B,CACF,EAEaC,EAAmC,CAC9C,MAAO,CACL,MAAAC,EACA,UAAW,eACX,SAASC,EAAW,CAClB,OAAOA,EAAK,KACd,EACA,OAAOA,EAAW,CAChB,OAAOA,EAAK,GACd,CACF,CACF,EAEaC,EAAqC,CAChD,eAAgB,CACd,MAAAC,CACF,CACF",
"names": ["src_exports", "__export", "defaultOptions", "languages", "options", "parsers", "printers", "__toCommonJS", "import_prettier", "import_synckit", "import_path", "parse", "text", "parsers", "opts", "formatterOptions", "resolveTailwindConfigPath", "filepath", "optionPath", "path", "prettierRcPath", "print", "path", "node", "defaultOptions", "options", "languages", "parsers", "parse", "node", "printers", "print"]
}
@@ -0,0 +1,4 @@
#!/usr/bin/env node
const cli = require('../dist/cli-bundle');
cli.default();
@@ -0,0 +1,64 @@
#!/usr/bin/env node
"use strict";
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = function(cb, mod) {
return function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
};
// node_modules/semver-compare/index.js
var require_semver_compare = __commonJS({
"node_modules/semver-compare/index.js": function(exports2, module2) {
module2.exports = function cmp(a, b) {
var pa = a.split(".");
var pb = b.split(".");
for (var i = 0; i < 3; i++) {
var na = Number(pa[i]);
var nb = Number(pb[i]);
if (na > nb)
return 1;
if (nb > na)
return -1;
if (!isNaN(na) && isNaN(nb))
return 1;
if (isNaN(na) && !isNaN(nb))
return -1;
}
return 0;
};
}
});
// node_modules/please-upgrade-node/index.js
var require_please_upgrade_node = __commonJS({
"node_modules/please-upgrade-node/index.js": function(exports2, module2) {
var semverCompare = require_semver_compare();
module2.exports = function pleaseUpgradeNode2(pkg, opts) {
var opts = opts || {};
var requiredVersion = pkg.engines.node.replace(">=", "");
var currentVersion = process.version.replace("v", "");
if (semverCompare(currentVersion, requiredVersion) === -1) {
if (opts.message) {
console.error(opts.message(requiredVersion));
} else {
console.error(
pkg.name + " requires at least version " + requiredVersion + " of Node, please upgrade"
);
}
if (opts.hasOwnProperty("exitCode")) {
process.exit(opts.exitCode);
} else {
process.exit(1);
}
}
};
}
});
// bin/prettier.js
var pleaseUpgradeNode = require_please_upgrade_node();
var packageJson = require("./package.json");
pleaseUpgradeNode(packageJson);
var cli = require("./cli.js");
module.exports = cli.run(process.argv.slice(2));
@@ -0,0 +1,58 @@
{
"name": "@shufo/prettier-plugin-blade",
"engines": {
"node": ">= 14.0.0"
},
"version": "1.8.12",
"dependencies": {
"blade-formatter": "^1.32.12",
"prettier": "^2.6.2",
"synckit": "^0.8.5"
},
"devDependencies": {
"@types/concat-stream": "^2.0.0",
"@types/jest": "^29.0.0",
"@types/prettier": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.30.0",
"codecov": "^3.8.3",
"concat-stream": "^2.0.0",
"cross-env": "^7.0.3",
"esbuild": "^0.17.0",
"esbuild-node-externals": "^1.4.1",
"eslint": "^8.15.0",
"jest": "^29.0.0",
"ts-jest": "^29.0.0",
"ts-node": "^10.5.0",
"typescript": "^5.0.0"
},
"main": "dist/index.js",
"scripts": {
"build": "cross-env NODE_ENV=production node esbuild.ts",
"watch": "node esbuild.ts",
"test": "yarn build && jest",
"lint": "eslint . --ext .ts",
"fix": "eslint . --ext .ts --fix",
"prettier": "prettier --plugin . --plugin-search-dir ."
},
"license": "MIT",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/shufo/prettier-plugin-blade.git"
},
"files": [
"dist",
"src",
"CHANGELOG.md"
],
"keywords": [
"prettier",
"blade",
"formatter",
"laravel"
],
"author": "Shuhei Hayashibara"
}
@@ -0,0 +1,38 @@
import { parse } from "./parser";
import { print } from "./printer";
import { options, defaultOptions } from "./options";
import { Parser, Printer, SupportLanguage } from "prettier";
export const languages: SupportLanguage[] = [
{
name: "Blade",
parsers: ["blade"],
since: "1.0.0",
extensions: [".blade.php"],
tmScope: "source.blade.php",
aceMode: "text",
linguistLanguageId: 33,
vscodeLanguageIds: ["blade"],
},
];
export const parsers: { [k: string]: Parser } = {
blade: {
parse,
astFormat: "blade-format",
locStart(node: any) {
return node.start;
},
locEnd(node: any) {
return node.end;
},
},
};
export const printers: { [k: string]: Printer } = {
"blade-format": {
print,
},
};
export { options, defaultOptions };
@@ -0,0 +1,58 @@
export const defaultOptions = {
tabWidth: 4,
printWidth: 120,
};
export const options = {
wrapAttributes: {
type: "string",
category: "Blade",
default: "auto",
description:
"The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]",
since: "1.0.0",
},
endWithNewLine: {
type: "boolean",
category: "Blade",
default: true,
description: "End output with newline.",
since: "1.0.0",
},
sortTailwindcssClasses: {
type: "boolean",
category: "Blade",
default: false,
description: "Sort Tailwindcss classes automatically. This option respects `tailwind.config.js`.",
since: "1.0.0",
},
tailwindcssConfigPath: {
type: "string",
category: "Blade",
default: '',
description: "Path to custom Tailwindcss config. This option is available only when `sortTailwindcssClasses` is present.",
since: "1.5.7",
},
sortHtmlAttributes: {
type: "string",
category: "Blade",
default: "none",
description: "Sort HTML Attributes. [none|alphabetical|code-guide|idiomatic|vuejs|custom]",
since: "1.5.0",
},
customHtmlAttributesOrder: {
type: "string",
category: "Blade",
default: "",
description: "Comma separated custom HTML attributes order. e.g. \"id, aria-.+, class, src\". To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names.",
since: "1.8.0",
},
noPhpSyntaxCheck: {
type: "boolean",
category: "Blade",
default: false,
description: "Disable PHP syntax checking",
since: "1.7.0",
},
};
@@ -0,0 +1,49 @@
import { Parser, ParserOptions, resolveConfigFile } from "prettier";
import { FormatterOption } from "blade-formatter";
import { createSyncFn } from "synckit";
import path from 'path';
export const parse = (
text: string,
parsers: { [parserName: string]: Parser },
opts: ParserOptions & FormatterOption
) => {
const formatterOptions: FormatterOption = {
indentSize: opts.tabWidth,
wrapLineLength: opts.printWidth,
wrapAttributes: opts.singleAttributePerLine ? 'force-expand-multiline' : opts.bracketSameLine ? 'force-aligned' : opts.wrapAttributes,
endWithNewline: opts.endWithNewline,
useTabs: opts.useTabs,
sortTailwindcssClasses: opts.sortTailwindcssClasses,
tailwindcssConfigPath: resolveTailwindConfigPath(opts.filepath, opts.tailwindcssConfigPath),
sortHtmlAttributes: opts.sortHtmlAttributes,
noMultipleEmptyLines: true,
noPhpSyntaxCheck: opts.noPhpSyntaxCheck,
customHtmlAttributesOrder: opts.customHtmlAttributesOrder,
};
const syncFn = createSyncFn(require.resolve("./worker"));
const result = syncFn(text, formatterOptions);
return {
type: "blade-formatter",
body: result,
end: text.length,
source: text,
start: 0,
};
};
function resolveTailwindConfigPath(filepath: string | undefined, optionPath: string | undefined): string | undefined {
if (!optionPath) {
return;
}
if (path.isAbsolute(optionPath ?? '')) {
return optionPath;
}
const prettierRcPath = resolveConfigFile.sync(filepath);
return path.resolve(path.dirname(prettierRcPath ?? ''), optionPath ?? '')
}
@@ -0,0 +1,13 @@
import { AstPath, Doc } from "prettier";
export const print = (path: AstPath): Doc => {
const node = path.getValue();
switch (node.type) {
case "blade-formatter": {
return node.body;
}
}
throw new Error(`Unknown node type: ${node.type}`);
};
@@ -0,0 +1,7 @@
const { runAsWorker } = require("synckit");
const { BladeFormatter } = require("blade-formatter");
runAsWorker(async (text, options) => {
const result = await new BladeFormatter(options).format(text);
return result;
});
@@ -0,0 +1,158 @@
# Changelog
## [2.0.0](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.12...v2.0.0) (2023-01-20)
### ⚠ BREAKING CHANGES
* 🧨 drop support for node 12.x
### Features
* 🎸 support tailwind 3.2 ([8c08b53](https://github.com/shufo/tailwindcss-class-sorter/commit/8c08b53727a8ad32ca1bc7ff86b538107d24d27f))
### Miscellaneous
* 🤖 bump tailwindcss to 3.2.4 ([2080eaf](https://github.com/shufo/tailwindcss-class-sorter/commit/2080eaf78ca24f71f3cef6003248e036fd50fd08))
* 🤖 drop support for node 12.x ([97b45ee](https://github.com/shufo/tailwindcss-class-sorter/commit/97b45ee21ee6021560bec7b278859bc90807e3fb))
* **deps:** update pozil/auto-assign-issue action to v1.11.0 ([b156b17](https://github.com/shufo/tailwindcss-class-sorter/commit/b156b170d1a45c1f4bbbc42c7dcedcd48fbb5fd1))
## [1.0.12](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.11...v1.0.12) (2022-09-21)
### Fixes
* 🐛 create context based on config hash ([a1c5084](https://github.com/shufo/tailwindcss-class-sorter/commit/a1c50844e1938b491eec5ed19fff9e8d3a072bba))
## [1.0.11](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.10...v1.0.11) (2022-09-20)
### Fixes
* 🐛 uncached default sorting is affecting performance ([e8d2fd4](https://github.com/shufo/tailwindcss-class-sorter/commit/e8d2fd42b681fdbc9ce0b110e8faeb4195eb01ae))
## [1.0.10](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.9...v1.0.10) (2022-09-19)
### Fixes
* 🐛 slow performance with uncached tailwind config object ([6dd6f61](https://github.com/shufo/tailwindcss-class-sorter/commit/6dd6f6113816c7fbfd8474a56087ddd5ccc6ea88))
## [1.0.9](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.8...v1.0.9) (2022-09-19)
### Fixes
* 🐛 `tailwindConfig` caches context unexpectedly ([ffd98c9](https://github.com/shufo/tailwindcss-class-sorter/commit/ffd98c94328bd74120e12a74a8a82c4197d907e8))
### Miscellaneous
* 💡 delete unnecessary console.log ([9cb1aeb](https://github.com/shufo/tailwindcss-class-sorter/commit/9cb1aeb9bf3ccc316c14f426421bb4f2d3265ce7))
## [1.0.8](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.7...v1.0.8) (2022-09-18)
### Miscellaneous
* 💡 improve error message for config file ([0f3de1d](https://github.com/shufo/tailwindcss-class-sorter/commit/0f3de1dbf77214730cf9febdfc022f0f8430f81a))
* **deps:** bump minimist from 1.2.5 to 1.2.6 ([6295e69](https://github.com/shufo/tailwindcss-class-sorter/commit/6295e694e870b7c525048559a81a4452a9aa1023))
## [1.0.7](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.6...v1.0.7) (2022-09-17)
### Fixes
* 🐛 import config type from tailwindcss ([2858a4a](https://github.com/shufo/tailwindcss-class-sorter/commit/2858a4a71441d5b999ab83f32925a275c7699393))
### Miscellaneous
* 🤖 bump tailwindcss to 3.1.8 ([521f91e](https://github.com/shufo/tailwindcss-class-sorter/commit/521f91ebf033263712359db3b539f4d14b974282))
* 🤖 delete @types/tailwindcss from dependencies ([192473f](https://github.com/shufo/tailwindcss-class-sorter/commit/192473f2a0cbfbed6224b138143d6372670cc94b))
## [1.0.6](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.5...v1.0.6) (2022-09-17)
### Fixes
* 🐛 import type from tailwindcss/defaultConfig ([e27375f](https://github.com/shufo/tailwindcss-class-sorter/commit/e27375fe8b8bf3d2a94987791fdebae738a86f8e))
### Miscellaneous
* 💡 improve message for config not found error ([c66b6fc](https://github.com/shufo/tailwindcss-class-sorter/commit/c66b6fc3fdd125fa0679f187ecac8d2e9f528c08))
* 🤖 add refactor type to change log types ([9683647](https://github.com/shufo/tailwindcss-class-sorter/commit/96836474b88e7454cb7927eef8b13fa871fe1179))
* 🤖 disable pinning ([4e59016](https://github.com/shufo/tailwindcss-class-sorter/commit/4e5901680121629893715c0c6029093801ce7b5c))
* 🤖 revert @types/tailwindcss to 3.0.9 ([72f1dc4](https://github.com/shufo/tailwindcss-class-sorter/commit/72f1dc454129bf347e344a2a113f3cbbdf7cb588))
* 🤖 update renovate.json config ([b4ae20d](https://github.com/shufo/tailwindcss-class-sorter/commit/b4ae20db17ba8ac41de1fd01bc173020cf7457e7))
## [1.0.5](https://github.com/shufo/tailwindcss-class-sorter/compare/v1.0.4...v1.0.5) (2022-09-17)
### Miscellaneous
* **deps:** add renovate.json ([153c992](https://github.com/shufo/tailwindcss-class-sorter/commit/153c9926362d1308deb747ec8ade4c605fa00601))
* **deps:** update actions/cache action to v3 ([05a1992](https://github.com/shufo/tailwindcss-class-sorter/commit/05a19928451aca5b73edad77f0c9ad943334f980))
* **deps:** update actions/checkout action to v3 ([91b816f](https://github.com/shufo/tailwindcss-class-sorter/commit/91b816f060418f3c7448aff5766748200684770a))
* **deps:** update actions/setup-node action to v3 ([7e253d9](https://github.com/shufo/tailwindcss-class-sorter/commit/7e253d9fc28bb9a28d47ed1b6ec63556883e985b))
* **deps:** update akhilmhdh/contributors-readme-action action to v2.3.6 ([e6f24ef](https://github.com/shufo/tailwindcss-class-sorter/commit/e6f24ef7564e11636b06671950872f5c81bb88d7))
* **deps:** update codecov/codecov-action action to v3 ([50014a0](https://github.com/shufo/tailwindcss-class-sorter/commit/50014a0612771e8924f36015e87678722f6c3cbd))
* **deps:** update dependency @tailwindcss/typography to v0.5.7 ([c4b8ee0](https://github.com/shufo/tailwindcss-class-sorter/commit/c4b8ee016f39d9b8f912841538df5be12fd8cbb2))
* **deps:** update dependency @types/tailwindcss to v3.0.11 ([363be77](https://github.com/shufo/tailwindcss-class-sorter/commit/363be7725124a1f90e4a3bbba8ae4cc4b7f638aa))
* **deps:** update dependency esbuild to v0.15.7 ([407456b](https://github.com/shufo/tailwindcss-class-sorter/commit/407456b446ac8c8ec28882824b8cf0f29c19853e))
* **deps:** update dependency eslint to v8.23.1 ([bab24ac](https://github.com/shufo/tailwindcss-class-sorter/commit/bab24ac68df05cc572b277a253829d4dce1a9ad2))
* **deps:** update dependency prettier to v2.7.1 ([0a45d44](https://github.com/shufo/tailwindcss-class-sorter/commit/0a45d44b4a28630f5c1bab8b5da46a1f86fc5437))
* **deps:** update dependency prettier-plugin-tailwindcss to v0.1.13 ([9746058](https://github.com/shufo/tailwindcss-class-sorter/commit/9746058ca6b36bca4abe58bacbae1527cc1ce25c))
* **deps:** update googlecloudplatform/release-please-action action to v3 ([d119584](https://github.com/shufo/tailwindcss-class-sorter/commit/d1195849e2ce5ceee957521645c9d62c79e1796a))
* **deps:** update pozil/auto-assign-issue action to v1.10.0 ([a4b223f](https://github.com/shufo/tailwindcss-class-sorter/commit/a4b223ff947bc308c0cbbc7b8fab1e4d17acffe4))
### [1.0.4](https://www.github.com/shufo/tailwindcss-class-sorter/compare/v1.0.3...v1.0.4) (2022-05-11)
### Miscellaneous
* 🤖 (deps-dev) add codecov ([c57d40d](https://www.github.com/shufo/tailwindcss-class-sorter/commit/c57d40d966d358b26043b0a0c0fa94e359be2f8a))
* **deps:** bump tailwindcss from 3.0.23 to 3.0.24 ([218ffbb](https://www.github.com/shufo/tailwindcss-class-sorter/commit/218ffbbcd876c2549906c0af73c82e6457df18b4))
### [1.0.3](https://www.github.com/shufo/tailwindcss-class-sorter/compare/v1.0.2...v1.0.3) (2022-02-26)
### Fixes
* 🐛 avoid optionial chain syntax to support node 12.x ([cba197b](https://www.github.com/shufo/tailwindcss-class-sorter/commit/cba197be923159e55ad9a3cca978d3c93363f0de))
### Miscellaneous
* 🤖 support node12.x for backward compatibility ([2603089](https://www.github.com/shufo/tailwindcss-class-sorter/commit/2603089ec7a1262330eb98c19308a4e5a6642352))
### [1.0.2](https://www.github.com/shufo/tailwindcss-class-sorter/compare/v1.0.1...v1.0.2) (2022-02-25)
### Miscellaneous
* 🤖 (dev-deps) add benny to dev dependencies ([e218645](https://www.github.com/shufo/tailwindcss-class-sorter/commit/e218645f5a404c2cd53acf74b43a831cdf8e52ac))
* 🤖 add ignore pattern for benchmark ([19aa712](https://www.github.com/shufo/tailwindcss-class-sorter/commit/19aa712765d9fb01b8cdcfe7a6c1c0b75e4bcc47))
* 🤖 add object-hash to dependencies ([6353bf4](https://www.github.com/shufo/tailwindcss-class-sorter/commit/6353bf4b979351eec2214a58741dcc04b46766ea))
### Performance
* ⚡️ add benchmark script to measure performance ([2d4b1e6](https://www.github.com/shufo/tailwindcss-class-sorter/commit/2d4b1e6df1bb7ec415791f5860ae90f5cb908a85))
* ⚡️ improve creating context performance by cache context ([16e5d96](https://www.github.com/shufo/tailwindcss-class-sorter/commit/16e5d964bd3a2108e1d84db9b34bf47d16282f35))
### [1.0.1](https://www.github.com/shufo/tailwindcss-class-sorter/compare/v1.0.0...v1.0.1) (2022-02-25)
### Miscellaneous
* 🤖 (dev-deps) delete unnecessary package ([22aa384](https://www.github.com/shufo/tailwindcss-class-sorter/commit/22aa3841d73b55282e79b23ccd6abf647ffced6c))
## 1.0.0 (2022-02-25)
### Miscellaneous
* 🚀 initialize ([21e8b81](https://www.github.com/shufo/tailwindcss-class-sorter/commit/21e8b810e1fa617fbd4246785cedb840a7b771df))
@@ -0,0 +1,79 @@
[![npm](https://img.shields.io/npm/v/@shufo/tailwindcss-class-sorter)](https://www.npmjs.com/package/@shufo/tailwindcss-class-sorter)
[![CI](https://github.com/shufo/tailwindcss-class-sorter/actions/workflows/test.yml/badge.svg)](https://github.com/shufo/tailwindcss-class-sorter/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/shufo/tailwindcss-class-sorter/branch/main/graph/badge.svg?token=CuqqimnEC4)](https://codecov.io/gh/shufo/tailwindcss-class-sorter)
# tailwindcss-class-sorter
A tailwindcss class sorter that respects tailwind config file.
## Installation
```bash
$ npm install @shufo/tailwindcss-class-sorter
# yarn
$ yarn add @shufo/tailwindcss-class-sorter
```
## Usage
```typescript
const { sortClasses } = require("@shufo/tailwindcss-class-sorter");
const sorted = sortClasses("pt-2 p-4");
console.log(sorted);
// => "p-4 pt-2"
```
`tailwindcss-class-sorter` will automatically look for `tailwind.config.js` in the project directory.
Then if it exists, it will sort according to the tailwindcss configuration. If it does not exist, the default sort order of tailwindcss plugin will be used.
## API
### functions
#### sortClasses(classes: string, options: IOption)
`classes`: classes string e.g. `z-5 z-50`
### Interfaces
#### IOption
```typescript
export interface IOption {
tailwindConfigPath?: string;
tailwindConfig?: TailwindConfig;
}
```
| key | value |
| ------------------ | ----------------------------------------- |
| tailwindConfigPath | A path to tailwind config file |
| tailwindConfig | A configuration object of tailwind config |
## Testing
```bash
$ yarn install
$ yarn run test
```
## Benchmarking
```bash
$ yarn run benchmark
```
![image](https://user-images.githubusercontent.com/1641039/155764304-fd676354-1b29-4390-b035-96dc9aae051d.png)
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## LICENSE
MIT
@@ -0,0 +1,2 @@
"use strict";var U=Object.create;var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var M=(t,n)=>{for(var r in n)c(t,r,{get:n[r],enumerable:!0})},w=(t,n,r,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of j(n))!E.call(t,i)&&i!==r&&c(t,i,{get:()=>n[i],enumerable:!(e=b(n,i))||e.enumerable});return t};var g=(t,n,r)=>(r=t!=null?U(q(t)):{},w(n||!t||!t.__esModule?c(r,"default",{value:t,enumerable:!0}):r,t)),S=t=>w(c({},"__esModule",{value:!0}),t);var D={};M(D,{sortClasses:()=>v});module.exports=S(D);var y=require("tailwindcss/lib/lib/setupContextUtils"),O=require("tailwindcss/lib/lib/generateRules"),N=g(require("tailwindcss/resolveConfig")),_=g(require("escalade/sync")),P=g(require("object-hash")),d=g(require("path")),f={content:[],theme:{}},p=new Map,C="tailwind.config.js";function k(t){let n=t>0n,r=t<0n;return n-r}function h(t,n){let r=t.tailwindConfig.prefix;return typeof r=="function"?r(n):r+n}function W(t,n){var i;let r=new Set([h(n,"group"),h(n,"peer")]),e=[];for(let s of t){let a=((i=(0,O.generateRules)(new Set([s]),n).sort(([u],[m])=>k(m-u))[0])==null?void 0:i[0])??null;a===null&&r.has(s)&&(a=n.layerOrder.components),e.push([s,a])}return e}function v(t,n={}){let r=(0,_.default)(__dirname,(o,l)=>{if(l.includes(C))return C});if(f.content=["no-op"],r&&(f=require(r)),n.tailwindConfig&&n.tailwindConfigPath)throw new Error("You can not specify tailwinfConfig or tailwinfConfigPath. Please specify either one.");n.tailwindConfigPath&&(f=A(n.tailwindConfigPath)),n.tailwindConfig&&(f=n.tailwindConfig);let e=(0,P.default)(f,{ignoreUnknown:!0}),i,s=p.get(e);s&&s.hash===e?i=s.context:(i=(0,y.createContext)((0,N.default)(f)),p.set(e,{context:i,hash:e}));let a=t.split(/\s+/).filter(o=>o!==""&&o!=="|"),u=[],x=(i.getClassOrder?i.getClassOrder(a):W(a,i)).sort(([,o],[,l])=>o===l?0:o===null?-1:l===null?1:k(o-l)).map(([o])=>o);return[...u,...x].join(" ")}function A(t){try{return require(t)}catch(n){throw n.code==="MODULE_NOT_FOUND"&&n.moduleName===d.default.resolve(t)?new Error("tailwind config could not be found at: "+d.default):n}}0&&(module.exports={sortClasses});
//# sourceMappingURL=main.js.map
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../src/main.ts"],
"sourcesContent": ["import { createContext } from \"tailwindcss/lib/lib/setupContextUtils\";\r\nimport { generateRules } from \"tailwindcss/lib/lib/generateRules\";\r\nimport resolveConfig from \"tailwindcss/resolveConfig\";\r\nimport type { Config } from \"tailwindcss/types/config\";\r\nimport escalade from \"escalade/sync\";\r\nimport { IOption } from \"./options\";\r\nimport objectHash from \"object-hash\";\r\nimport path from \"path\";\r\n\r\nlet tailwindConfig: Config = {\r\n content: [],\r\n theme: {},\r\n};\r\n\r\nconst contextMap = new Map();\r\n\r\nconst __defaultConfig__ = \"tailwind.config.js\";\r\n\r\nfunction bigSign(bigIntValue: number) {\r\n const left: any = bigIntValue > 0n;\r\n const right: any = bigIntValue < 0n;\r\n return left - right;\r\n}\r\n\r\nfunction prefixCandidate(context, selector) {\r\n const prefix = context.tailwindConfig.prefix;\r\n return typeof prefix === \"function\" ? prefix(selector) : prefix + selector;\r\n}\r\n\r\nfunction getClassOrderPolyfill(classes, context) {\r\n const parasiteUtilities = new Set([\r\n prefixCandidate(context, \"group\"),\r\n prefixCandidate(context, \"peer\"),\r\n ]);\r\n\r\n const classNamesWithOrder: Array<Array<string>> = [];\r\n\r\n for (const className of classes) {\r\n let order =\r\n generateRules(new Set([className]), context).sort(([a], [z]) =>\r\n bigSign(z - a)\r\n )[0]?.[0] ?? null;\r\n\r\n if (order === null && parasiteUtilities.has(className)) {\r\n order = context.layerOrder.components;\r\n }\r\n\r\n classNamesWithOrder.push([className, order]);\r\n }\r\n\r\n return classNamesWithOrder;\r\n}\r\n\r\nexport function sortClasses(classStr: string, options: IOption = {}): string {\r\n const tailwindConfigPath = escalade(__dirname, (dir, names) => {\r\n if (names.includes(__defaultConfig__)) {\r\n return __defaultConfig__;\r\n }\r\n });\r\n\r\n tailwindConfig.content = [\"no-op\"];\r\n if (tailwindConfigPath) {\r\n tailwindConfig = require(tailwindConfigPath);\r\n }\r\n\r\n if (options.tailwindConfig && options.tailwindConfigPath) {\r\n throw new Error(\r\n \"You can not specify tailwinfConfig or tailwinfConfigPath. Please specify either one.\"\r\n );\r\n }\r\n\r\n if (options.tailwindConfigPath) {\r\n tailwindConfig = requireConfig(options.tailwindConfigPath);\r\n }\r\n\r\n if (options.tailwindConfig) {\r\n tailwindConfig = options.tailwindConfig;\r\n }\r\n\r\n const hash = objectHash(tailwindConfig, { ignoreUnknown: true });\r\n\r\n let context;\r\n\r\n const existing = contextMap.get(hash);\r\n\r\n if (existing && existing.hash === hash) {\r\n context = existing.context;\r\n } else {\r\n context = createContext(resolveConfig(tailwindConfig));\r\n // console.log(context.getClassOrder);\r\n contextMap.set(hash, { context, hash });\r\n }\r\n\r\n const parts: string[] = classStr\r\n .split(/\\s+/)\r\n .filter((x) => x !== \"\" && x !== \"|\");\r\n\r\n const unknownClassNames: string[] = [];\r\n const knownClassNamesWithOrder = context.getClassOrder\r\n ? context.getClassOrder(parts)\r\n : getClassOrderPolyfill(parts, context);\r\n\r\n const knownClassNames = knownClassNamesWithOrder\r\n .sort(([, a]: any, [, z]: any) => {\r\n if (a === z) return 0;\r\n if (a === null) return -1;\r\n if (z === null) return 1;\r\n return bigSign(a - z);\r\n })\r\n .map(([className]) => className);\r\n\r\n return [...unknownClassNames, ...knownClassNames].join(\" \");\r\n}\r\n\r\nfunction requireConfig(configPath: string) {\r\n try {\r\n return require(configPath);\r\n } catch (err: any) {\r\n if (\r\n err.code === \"MODULE_NOT_FOUND\" &&\r\n err.moduleName === path.resolve(configPath)\r\n ) {\r\n throw new Error(\"tailwind config could not be found at: \" + path);\r\n }\r\n\r\n throw err;\r\n }\r\n}\r\n"],
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,iDAC9BC,EAA8B,6CAC9BC,EAA0B,wCAE1BC,EAAqB,4BAErBC,EAAuB,0BACvBC,EAAiB,mBAEbC,EAAyB,CACzB,QAAS,CAAC,EACV,MAAO,CAAC,CACZ,EAEMC,EAAa,IAAI,IAEjBC,EAAoB,qBAE1B,SAASC,EAAQC,EAAqB,CAClC,IAAMC,EAAYD,EAAc,GAC1BE,EAAaF,EAAc,GACjC,OAAOC,EAAOC,CAClB,CAEA,SAASC,EAAgBC,EAASC,EAAU,CACxC,IAAMC,EAASF,EAAQ,eAAe,OACtC,OAAO,OAAOE,GAAW,WAAaA,EAAOD,CAAQ,EAAIC,EAASD,CACtE,CAEA,SAASE,EAAsBC,EAASJ,EAAS,CA7BjD,IAAAK,EA8BI,IAAMC,EAAoB,IAAI,IAAI,CAC9BP,EAAgBC,EAAS,OAAO,EAChCD,EAAgBC,EAAS,MAAM,CACnC,CAAC,EAEKO,EAA4C,CAAC,EAEnD,QAAWC,KAAaJ,EAAS,CAC7B,IAAIK,IACAJ,KAAA,iBAAc,IAAI,IAAI,CAACG,CAAS,CAAC,EAAGR,CAAO,EAAE,KAAK,CAAC,CAACU,CAAC,EAAG,CAACC,CAAC,IACtDhB,EAAQgB,EAAID,CAAC,CACjB,EAAE,KAFF,YAAAL,EAEO,KAAM,KAEbI,IAAU,MAAQH,EAAkB,IAAIE,CAAS,IACjDC,EAAQT,EAAQ,WAAW,YAG/BO,EAAoB,KAAK,CAACC,EAAWC,CAAK,CAAC,CAC/C,CAEA,OAAOF,CACX,CAEO,SAASvB,EAAY4B,EAAkBC,EAAmB,CAAC,EAAW,CACzE,IAAMC,KAAqB,EAAAC,SAAS,UAAW,CAACC,EAAKC,IAAU,CAC3D,GAAIA,EAAM,SAASvB,CAAiB,EAChC,OAAOA,CAEf,CAAC,EAOD,GALAF,EAAe,QAAU,CAAC,OAAO,EAC7BsB,IACAtB,EAAiB,QAAQsB,IAGzBD,EAAQ,gBAAkBA,EAAQ,mBAClC,MAAM,IAAI,MACN,sFACJ,EAGAA,EAAQ,qBACRrB,EAAiB0B,EAAcL,EAAQ,kBAAkB,GAGzDA,EAAQ,iBACRrB,EAAiBqB,EAAQ,gBAG7B,IAAMM,KAAO,EAAAC,SAAW5B,EAAgB,CAAE,cAAe,EAAK,CAAC,EAE3DQ,EAEEqB,EAAW5B,EAAW,IAAI0B,CAAI,EAEhCE,GAAYA,EAAS,OAASF,EAC9BnB,EAAUqB,EAAS,SAEnBrB,KAAU,oBAAc,EAAAsB,SAAc9B,CAAc,CAAC,EAErDC,EAAW,IAAI0B,EAAM,CAAE,QAAAnB,EAAS,KAAAmB,CAAK,CAAC,GAG1C,IAAMI,EAAkBX,EACnB,MAAM,KAAK,EACX,OAAQY,GAAMA,IAAM,IAAMA,IAAM,GAAG,EAElCC,EAA8B,CAAC,EAK/BC,GAJ2B1B,EAAQ,cACnCA,EAAQ,cAAcuB,CAAK,EAC3BpB,EAAsBoB,EAAOvB,CAAO,GAGrC,KAAK,CAAC,CAAC,CAAEU,CAAC,EAAQ,CAAC,CAAEC,CAAC,IACfD,IAAMC,EAAU,EAChBD,IAAM,KAAa,GACnBC,IAAM,KAAa,EAChBhB,EAAQe,EAAIC,CAAC,CACvB,EACA,IAAI,CAAC,CAACH,CAAS,IAAMA,CAAS,EAEnC,MAAO,CAAC,GAAGiB,EAAmB,GAAGC,CAAe,EAAE,KAAK,GAAG,CAC9D,CAEA,SAASR,EAAcS,EAAoB,CACvC,GAAI,CACA,OAAO,QAAQA,EACnB,OAASC,EAAP,CACE,MACIA,EAAI,OAAS,oBACbA,EAAI,aAAe,EAAAC,QAAK,QAAQF,CAAU,EAEpC,IAAI,MAAM,0CAA4C,EAAAE,OAAI,EAG9DD,CACV,CACJ",
"names": ["main_exports", "__export", "sortClasses", "__toCommonJS", "import_setupContextUtils", "import_generateRules", "import_resolveConfig", "import_sync", "import_object_hash", "import_path", "tailwindConfig", "contextMap", "__defaultConfig__", "bigSign", "bigIntValue", "left", "right", "prefixCandidate", "context", "selector", "prefix", "getClassOrderPolyfill", "classes", "_a", "parasiteUtilities", "classNamesWithOrder", "className", "order", "a", "z", "classStr", "options", "tailwindConfigPath", "escalade", "dir", "names", "requireConfig", "hash", "objectHash", "existing", "resolveConfig", "parts", "x", "unknownClassNames", "knownClassNames", "configPath", "err", "path"]
}
@@ -0,0 +1,2 @@
import { IOption } from "./options";
export declare function sortClasses(classStr: string, options?: IOption): string;
@@ -0,0 +1,5 @@
import type { Config } from "tailwindcss/types/config";
export interface IOption {
tailwindConfigPath?: string;
tailwindConfig?: Config;
}
@@ -0,0 +1,7 @@
#!/usr/bin/env node
"use strict";
if (false) {
module.exports = require("./oxide/cli");
} else {
module.exports = require("./cli/index");
}
@@ -0,0 +1,7 @@
#!/usr/bin/env node
"use strict";
if (false) {
module.exports = require("./oxide/cli");
} else {
module.exports = require("./cli/index");
}
@@ -0,0 +1,69 @@
{
"name": "@shufo/tailwindcss-class-sorter",
"version": "2.0.0",
"description": "A tailwindcss class sorter that respects tailwind config file",
"main": "dist/main.js",
"types": "./dist/types/main.d.ts",
"scripts": {
"build": "cross-env NODE_ENV=production node esbuild.ts",
"watch": "node esbuild.ts",
"test": "yarn build && node --experimental-vm-modules ./node_modules/.bin/jest",
"lint": "eslint . --ext .ts",
"fix": "eslint . --ext .ts --fix && yarn run format",
"prepublish": "tsc src/main.ts --declaration --emitDeclarationOnly --outDir ./dist/types || true",
"format": "yarn run format:ts",
"format:ts": "prettier {src,__tests__}/**/*.{ts,json} -w",
"format:check": "prettier {src,__tests__}/**/*.{ts,json} -c",
"prepare": "husky install",
"benchmark": "yarn run build && node benchmark/run.js"
},
"author": "Shuhei Hayashibara",
"license": "MIT",
"devDependencies": {
"@tailwindcss/typography": "^0.5.7",
"@types/jest": "^27.4.1",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"benny": "^3.7.1",
"codecov": "^3.8.3",
"cross-env": "^7.0.3",
"esbuild": "^0.15.7",
"esbuild-node-externals": "^1.4.1",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.4.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^12.3.4",
"prettier": "^2.7.1",
"prettier-plugin-tailwindcss": "^0.1.13",
"ts-jest": "^27.1.3",
"ts-node": "^10.5.0",
"typescript": "^4.5.5"
},
"dependencies": {
"escalade": "^3.1.1",
"object-hash": "^3.0.0",
"tailwindcss": "^3.2.4"
},
"files": [
"dist",
"src",
"CHANGELOG.md"
],
"repository": {
"type": "git",
"url": "https://github.com/shufo/tailwindcss-class-sorter.git"
},
"publishConfig": {
"access": "public"
},
"lint-staged": {
"*.ts": "yarn run fix"
},
"keywords": [
"tailwindcss"
],
"engines": {
"node": ">= 14.0.0"
}
}
@@ -0,0 +1,128 @@
import { createContext } from "tailwindcss/lib/lib/setupContextUtils";
import { generateRules } from "tailwindcss/lib/lib/generateRules";
import resolveConfig from "tailwindcss/resolveConfig";
import type { Config } from "tailwindcss/types/config";
import escalade from "escalade/sync";
import { IOption } from "./options";
import objectHash from "object-hash";
import path from "path";
let tailwindConfig: Config = {
content: [],
theme: {},
};
const contextMap = new Map();
const __defaultConfig__ = "tailwind.config.js";
function bigSign(bigIntValue: number) {
const left: any = bigIntValue > 0n;
const right: any = bigIntValue < 0n;
return left - right;
}
function prefixCandidate(context, selector) {
const prefix = context.tailwindConfig.prefix;
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
}
function getClassOrderPolyfill(classes, context) {
const parasiteUtilities = new Set([
prefixCandidate(context, "group"),
prefixCandidate(context, "peer"),
]);
const classNamesWithOrder: Array<Array<string>> = [];
for (const className of classes) {
let order =
generateRules(new Set([className]), context).sort(([a], [z]) =>
bigSign(z - a)
)[0]?.[0] ?? null;
if (order === null && parasiteUtilities.has(className)) {
order = context.layerOrder.components;
}
classNamesWithOrder.push([className, order]);
}
return classNamesWithOrder;
}
export function sortClasses(classStr: string, options: IOption = {}): string {
const tailwindConfigPath = escalade(__dirname, (dir, names) => {
if (names.includes(__defaultConfig__)) {
return __defaultConfig__;
}
});
tailwindConfig.content = ["no-op"];
if (tailwindConfigPath) {
tailwindConfig = require(tailwindConfigPath);
}
if (options.tailwindConfig && options.tailwindConfigPath) {
throw new Error(
"You can not specify tailwinfConfig or tailwinfConfigPath. Please specify either one."
);
}
if (options.tailwindConfigPath) {
tailwindConfig = requireConfig(options.tailwindConfigPath);
}
if (options.tailwindConfig) {
tailwindConfig = options.tailwindConfig;
}
const hash = objectHash(tailwindConfig, { ignoreUnknown: true });
let context;
const existing = contextMap.get(hash);
if (existing && existing.hash === hash) {
context = existing.context;
} else {
context = createContext(resolveConfig(tailwindConfig));
// console.log(context.getClassOrder);
contextMap.set(hash, { context, hash });
}
const parts: string[] = classStr
.split(/\s+/)
.filter((x) => x !== "" && x !== "|");
const unknownClassNames: string[] = [];
const knownClassNamesWithOrder = context.getClassOrder
? context.getClassOrder(parts)
: getClassOrderPolyfill(parts, context);
const knownClassNames = knownClassNamesWithOrder
.sort(([, a]: any, [, z]: any) => {
if (a === z) return 0;
if (a === null) return -1;
if (z === null) return 1;
return bigSign(a - z);
})
.map(([className]) => className);
return [...unknownClassNames, ...knownClassNames].join(" ");
}
function requireConfig(configPath: string) {
try {
return require(configPath);
} catch (err: any) {
if (
err.code === "MODULE_NOT_FOUND" &&
err.moduleName === path.resolve(configPath)
) {
throw new Error("tailwind config could not be found at: " + path);
}
throw err;
}
}
@@ -0,0 +1,6 @@
import type { Config } from "tailwindcss/types/config";
export interface IOption {
tailwindConfigPath?: string;
tailwindConfig?: Config;
}