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

Keep the empty line at the beginning of a function, if present. #3501

Closed
electrotype opened this issue Dec 15, 2017 · 4 comments
Closed

Keep the empty line at the beginning of a function, if present. #3501

electrotype opened this issue Dec 15, 2017 · 4 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@electrotype
Copy link

electrotype commented Dec 15, 2017

I'm new to Prettier (for Typescript) and I like pretty much all the decisions it makes except the one that removes the empty line at the beginning of a function.

I wish Prettier would keep such empty line if there's one, the same way it keeps an empty line elsewhere in the function.

For example :


beforeEach(async () => {

  // Sets the server port
  serverPort = 123;

  // The previous empty line is kept
});

would stay as is, and not reformatted to:

beforeEach(async () => {
  // Sets the server port
  serverPort = 123;

  // The previous empty line is kept
});

But if there is no empty line, none would be added :

beforeEach(async () => {
  // Sets the server port
  serverPort = 123;

  // The previous empty line is kept
});

would also stay as is.


Any chance we can have this feature?

@lydell
Copy link
Member

lydell commented Dec 15, 2017

Hi!

Empty lines have been discussed a lot, and Prettier has settled on its current "at most one blank line in a row, and no blank lines at the start and end of things" rule which seems to reasonable in 99% of the cases. Here is the most similar issue I could find right now: #2352.

I'm closing this one since it does not seem like this will be changed. Sorry! Feel free to comment here if I missed something.

@lydell lydell closed this as completed Dec 15, 2017
@electrotype
Copy link
Author

Thanks @lydell . Sorry to ask, but do you know of another issue or article with more information on why this won't be supported?

I think it's the only odd choice Prettier makes.
Mostly when the first line of a function is a comment, it think it's ugly (my opinion)...

@lydell
Copy link
Member

lydell commented Dec 15, 2017

This answer about allowing 2 blank lines in a row could be helpful: #1613 (comment)

@iamdanthedev
Copy link

@lydell Could you please kindly point to the file and line where this rule is implemented, I just thought of forking the lib because of this option, but feel quite lost looking at the code
Thanks!

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 6, 2018
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

3 participants