-
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make chain breaking as similar to original prettier (js) as much as possible #2320
Conversation
I have updated the pull request to include a new option where user can define their own max calls in a chain before break occurs. The default option is left as is (I think the number 3 is based on similar option in main prettier repo) so it would not affect current codebases. |
Updated description in options file
Hi @eldair, thanks for contributing! I think adding an option for this doesn't fit to the Prettier option philosophy. Did you already look into how Prettier for JS handles this? It would be awesome if we could solve it the same way. |
Hi @czosel , I'm sorry, I didn't see that doc about adding options. The next best thing in my opinion is to remove chains limit and to leave them in single line if they can fit (they would still break in case of multiline closures). this would be as close to the js counterpart as possible without adding checks for call complexity which might not even be needed for php. This is from prettier (js) with my comments
|
Me again, I have started digging into |
Fixed array handling in complexity test
@czosel Pull request can be checked now. The code is not perfect and I tried to test as many combination as I could think of but it is much closer to the JS counterpart and I think better than the current implementation. |
Change looks good to me, however, can you reformat with prettier and commit? See CI / Lint action, at least |
@cseufert thanks for checking it out, i've fixed the file |
LGTM, thanks for the awesome contribution @eldair! 🎉 |
Released in |
Woohoo 🎉 |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@prettier/plugin-php](https://togithub.com/prettier/prettier-php) | [`^0.18.9` -> `^0.22.0`](https://renovatebot.com/diffs/npm/@prettier%2fplugin-php/0.18.9/0.22.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@prettier%2fplugin-php/0.22.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@prettier%2fplugin-php/0.22.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@prettier%2fplugin-php/0.18.9/0.22.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@prettier%2fplugin-php/0.18.9/0.22.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>prettier/prettier-php (@​prettier/plugin-php)</summary> ### [`v0.22.2`](https://togithub.com/prettier/plugin-php/releases/tag/v0.22.2) [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.22.1...v0.22.2) #### What's Changed - Make chain breaking as similar to original prettier (js) as much as possible by [@​eldair](https://togithub.com/eldair) in [https://github.com/prettier/plugin-php/pull/2320](https://togithub.com/prettier/plugin-php/pull/2320) - fix: 🐛 singleQuote option does not work on format API by [@​shufo](https://togithub.com/shufo) in [https://github.com/prettier/plugin-php/pull/2303](https://togithub.com/prettier/plugin-php/pull/2303) - chore: upgrade dependencies by [@​czosel](https://togithub.com/czosel) in [https://github.com/prettier/plugin-php/pull/2321](https://togithub.com/prettier/plugin-php/pull/2321) #### New Contributors - [@​eldair](https://togithub.com/eldair) made their first contribution in [https://github.com/prettier/plugin-php/pull/2320](https://togithub.com/prettier/plugin-php/pull/2320) **Full Changelog**: prettier/plugin-php@v0.22.1...v0.22.2 ### [`v0.22.1`](https://togithub.com/prettier/plugin-php/releases/tag/v0.22.1) [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.22.0...v0.22.1) - fix the entry ([#​2290](https://togithub.com/prettier/prettier-php/issues/2290), thanks [@​fisker](https://togithub.com/fisker)) ### [`v0.22.0`](https://togithub.com/prettier/plugin-php/releases/tag/v0.22.0) [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.21.0...v0.22.0) - feat: make format compatible with "PER Coding Style 2.0" ([#​2269](https://togithub.com/prettier/prettier-php/issues/2269), thanks [@​ferchoz](https://togithub.com/ferchoz)) - fix: make `/standalone` entry work with `require()` ([#​2247](https://togithub.com/prettier/prettier-php/issues/2247), thanks [@​shufo](https://togithub.com/shufo)) - chore: upgrade deps ([#​2289](https://togithub.com/prettier/prettier-php/issues/2289)) ### [`v0.21.0`](https://togithub.com/prettier/plugin-php/releases/tag/v0.21.0): 0.21.0 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.20.1...v0.21.0) - fix(match): Indent match conditions ([#​2258](https://togithub.com/prettier/prettier-php/issues/2258), thanks [@​claytonrcarter](https://togithub.com/claytonrcarter)!) - chore!: upgrade dependencies ([#​2262](https://togithub.com/prettier/prettier-php/issues/2262)) #### Breaking changes This release drops support for node v14. ### [`v0.20.1`](https://togithub.com/prettier/plugin-php/releases/tag/v0.20.1) [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.20.0...v0.20.1) **This package is now pure ESM.** - vscode documentation update ([#​2194](https://togithub.com/prettier/prettier-php/issues/2194), thanks [@​WazzaJB](https://togithub.com/WazzaJB)!) - Use `AstPath` getters ([#​2214](https://togithub.com/prettier/prettier-php/issues/2214), thanks [@​fisker](https://togithub.com/fisker)!) - Migrate to ESM ([#​2213](https://togithub.com/prettier/prettier-php/issues/2213), thanks [@​fisker](https://togithub.com/fisker)!) ### [`v0.20.0`](https://togithub.com/prettier/plugin-php/releases/tag/v0.20.0) [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.7...v0.20.0) Many thanks to [@​fisker](https://togithub.com/fisker) for many contributions! - feat: upgrade to prettier 3 ([#​2200](https://togithub.com/prettier/prettier-php/issues/2200)) - Simplify `print()` ([#​2212](https://togithub.com/prettier/prettier-php/issues/2212)) - Convert tests to ES Modules ([#​2210](https://togithub.com/prettier/prettier-php/issues/2210)) - Fix standalone test ([#​2211](https://togithub.com/prettier/prettier-php/issues/2211)) - Update .gitattributes ([#​2209](https://togithub.com/prettier/prettier-php/issues/2209)) ### Breaking Change This adds support for Prettier v3. It also drops compatibility with Prettier v1 and v2. ### [`v0.19.7`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.7): 0.19.7 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.6...v0.19.7) - fix(match): Support empty lines and comments in match expressions ([#​1956](https://togithub.com/prettier/prettier-php/issues/1956), [#​2201](https://togithub.com/prettier/prettier-php/issues/2201) - thanks [@​claytonrcarter](https://togithub.com/claytonrcarter)!) ### [`v0.19.6`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.6): 0.19.6 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.5...v0.19.6) - Add support for final class const ([#​2186](https://togithub.com/prettier/prettier-php/issues/2186), thanks [@​cseufert](https://togithub.com/cseufert)!) - chore: upgrade dependencies ([#​2193](https://togithub.com/prettier/prettier-php/issues/2193)) ### [`v0.19.5`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.5): 0.19.5 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.4...v0.19.5) - fix: add option for PHP 8.2 ([#​2179](https://togithub.com/prettier/prettier-php/issues/2179)) *Note*: This allows setting `phpVersion` to `8.2` - Support for PHP 8.2 is still incomplete, though! ### [`v0.19.4`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.4): 0.19.4 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.3...v0.19.4) This release includes several internal cleanups and updates, thanks to contributions by [@​fisker](https://togithub.com/fisker)! - improve doc print and update prettier dependency ([#​1922](https://togithub.com/prettier/prettier-php/issues/1922)) - use `clean.ignoredProperties` ([#​2158](https://togithub.com/prettier/prettier-php/issues/2158)) - Remove handling `\r` ([#​2157](https://togithub.com/prettier/prettier-php/issues/2157)) - dependency updates ### [`v0.19.3`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.3): 0.19.3 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.2...v0.19.3) - feat: add support for readonly classes \[PHP 8.2] ([#​2131](https://togithub.com/prettier/prettier-php/issues/2131), thanks [@​genintho](https://togithub.com/genintho)!) - chore: upgrade dependencies ([#​2134](https://togithub.com/prettier/prettier-php/issues/2134)) ### [`v0.19.2`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.2): 0.19.2 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.1...v0.19.2) #### Deprecations The `psr2` setting for the `braceStyle` option has been renamed to `per-cs` to be more in line with future PER releases (see [https://github.com/prettier/plugin-php/issues/2060](https://togithub.com/prettier/plugin-php/issues/2060) for details). `psr2` will continue to work for now, but will be removed in a future release. #### Bugfixes - Support expressions in new statement ([#​2086](https://togithub.com/prettier/prettier-php/issues/2086), thanks [@​cseufert](https://togithub.com/cseufert)!) - Fix for function curly brace with attrs ([#​2089](https://togithub.com/prettier/prettier-php/issues/2089), thanks [@​cseufert](https://togithub.com/cseufert)!) - Deprecated PSR-2 braceStyle and use PER-CS instead ([#​2070](https://togithub.com/prettier/prettier-php/issues/2070), thanks [@​cseufert](https://togithub.com/cseufert)!) ### [`v0.19.1`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.1): 0.19.1 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.19.0...v0.19.1) - fix for inline closure ([#​2062](https://togithub.com/prettier/prettier-php/issues/2062), thanks [@​cseufert](https://togithub.com/cseufert)!) - chore: upgrade dependencies ([#​2068](https://togithub.com/prettier/prettier-php/issues/2068)) ### [`v0.19.0`](https://togithub.com/prettier/plugin-php/releases/tag/v0.19.0): 0.19.0 [Compare Source](https://togithub.com/prettier/prettier-php/compare/v0.18.9...v0.19.0) - fix: formatting of long cases in match statement ([#​2054](https://togithub.com/prettier/prettier-php/issues/2054)) - chore: upgrade dependencies ([#​2059](https://togithub.com/prettier/prettier-php/issues/2059)) Breaking Change: - Dropped support for Node v12. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tisnamuliarta/laravel-shadcn). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
There is a hardcoded line which is the cause of chain breaks even though the expression would fit in one line. This is a quick and easy solution for #1545
I have adjusted test so they all pass but if this is merged than some of those could be removed as redundant.