Skip to content
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

How can the format of the chain call be consistent? #14733

Closed
seekcx opened this issue Apr 20, 2023 · 5 comments
Closed

How can the format of the chain call be consistent? #14733

seekcx opened this issue Apr 20, 2023 · 5 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@seekcx
Copy link

seekcx commented Apr 20, 2023

Prettier 2.8.7
Playground link

Input:

Route
    .put('/user/location-abc', 'UserController.updateLocation')
    .middleware('auth')
    .name('test')
  
Route.put('/user/location-abc','User/ProfileController.updateLocation')
    .middleware('auth')
  
Route
    .put('/user/location-abc', 'UserController.updateLocation')
    .middleware('auth')

Output:

Route.put('/user/location-abc', 'UserController.updateLocation')
  .middleware('auth')
  .name('test');

Route.put(
  '/user/location-abc',
  'User/ProfileController.updateLocation'
).middleware('auth');

Route.put('/user/location-abc', 'UserController.updateLocation').middleware(
  'auth'
);

Expected behavior:

Route
  .put('/user/location-abc', 'UserController.updateLocation')
  .middleware('auth')
  .name('test')
  
Route
  .put('/user/location-abc', 'User/ProfileController.updateLocation')
  .middleware('auth')
  
Route
  .put('/user/location-abc', 'UserController.updateLocation')
  .middleware('auth')

OR

Route.put('/user/location-abc', 'UserController.updateLocation')
  .middleware('auth')
  .name('test')
  
Route.put('/user/location-abc', 'User/ProfileController.updateLocation')
  .middleware('auth')
  
Route.put('/user/location-abc', 'UserController.updateLocation')
  .middleware('auth')
@seiyab
Copy link
Sponsor Contributor

seiyab commented Apr 20, 2023

Do you mean that method chain should break first rather than each argument and it's different from #7884?

@seiyab
Copy link
Sponsor Contributor

seiyab commented Apr 20, 2023

Answering "how", using a comment might help you as a workaround:

Route
  // Hey prettier, would you break here, please?
  .put('/user/location-abc','User/ProfileController.updateLocation')
  .middleware('auth')

But probably, you want prettier to format as you suggested without workaround.
I agree that outputs you expect look better and want prettier to get better heuristic.

(Though I'm interested in it, I don't intend to work on it as of now. Go ahead if someone want to work on it.)

@seiyab
Copy link
Sponsor Contributor

seiyab commented Apr 20, 2023

Oops, probably duplicated? #14628

@seekcx
Copy link
Author

seekcx commented Apr 20, 2023

Showing the method in several lines is ugly and I don't understand why the expected behavior is this way. And for different situations, it seems that there are different formatting strategies. If they can be consistent, it will seem easier to understand.

@seekcx
Copy link
Author

seekcx commented Apr 20, 2023

Oops, probably duplicated? #14628

Yes, I confirmed the duplicate, close this first.

@seekcx seekcx closed this as completed Apr 20, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants