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

Standardize blank lines to no more than 1 or 2 #249

Closed
tconbeer opened this issue Aug 21, 2022 · 1 comment · Fixed by #359
Closed

Standardize blank lines to no more than 1 or 2 #249

tconbeer opened this issue Aug 21, 2022 · 1 comment · Fixed by #359
Labels
enhancement New feature or request style for issues that change the sqlfmt style
Milestone

Comments

@tconbeer
Copy link
Owner

The opinion of some formatters for other languages

Both leave empty lines from original format, but collapse them to a standard number of lines (ie. 0 empty lines remain 0, 7 or 6 or 1 empty lines all become eg 1 empty line)

Black goes even further and adds empty lines in some places (which I think you could consider doing eg around CTEs for readability)

Originally posted by @nfcampos in #230 (comment)

@tconbeer tconbeer added the enhancement New feature or request label Aug 22, 2022
@tconbeer tconbeer added this to the 0.12.0 milestone Aug 22, 2022
@tconbeer tconbeer added bug Something isn't working and removed bug Something isn't working labels Sep 13, 2022
@tconbeer tconbeer removed this from the v0.12.0 milestone Sep 29, 2022
@tconbeer tconbeer added the style for issues that change the sqlfmt style label Nov 4, 2022
@tconbeer tconbeer changed the title Standardize blank lines to no more than 1 Standardize blank lines to no more than 1 or 2 Nov 30, 2022
@tconbeer tconbeer added this to the v0.15.0 milestone Nov 30, 2022
@tconbeer
Copy link
Owner Author

tconbeer commented Nov 30, 2022

My proposal is:

  • No more than 2 consecutive blank lines of depth (0,0). In other words, we'll allow 2 blank lines in between statements (e.g., between a {{ config }} block and select, which seems popular)
  • No more than 1 consecutive blank line at any other depth.

(This is similar to Black, where there are 2 spaces between module-level classes/functions and 1 space between anything nested deeper than that. Right now we'll just enforce an upper bound, but in the future we can get more opinionated)

tconbeer added a commit that referenced this issue Jan 17, 2023
* feat: remove extra blank lines, close #249

* chore: bump primer refs

* feat: also remove extra newlines at start of files

* chore: bump primer refs again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request style for issues that change the sqlfmt style
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant