sql-formatter-org / sql-formatter-org/sql-formatter

Feature Request: Keep some blank lines when formatting

Open
#750 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
2.9k
Forks
456
Avg merge
3d 4h
Merged PRs (30d)
3

Description

Describe the Feature
A configuration option (or default behavior) to keep some existing blank lines from the input file. For example, IntelliJ has the following options for Java:
20240619_22h02m40s_grim

Why do you want this feature?
I have some SQL files used for database migrations with a header comment at the top that isn't directly related to the first query:

-- Some header comment
-- with metadata for migrations tool

CREATE TABLE something(id INTEGER PRIMARY KEY);

When I format this with sql-formatter, it currently deletes the blank line between the header comment and the first query.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with the SQL migration example in the issue and inspect the formatter's configuration and whitespace-handling entry points. The work is done when the requested blank line can be preserved through the proposed default or configuration option without breaking normal formatting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.