Closed frozenbonito closed 2 years ago
Latest commit: ee030fdc709fdbe2923990132e1f3442a4b1e22f
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
File | Before | After |
---|---|---|
Total (Includes all files) | 211.6 kB |
211.6 kB |
Tarball size | 68.1 kB |
68.1 kB |
🤖 This report was automatically generated by pkg-size-action
Merging #207 (8c2a3ba) into master (2c1f8c8) will increase coverage by
0.58%
. The diff coverage is100.00%
.:exclamation: Current head 8c2a3ba differs from pull request most recent head ee030fd. Consider uploading reports for the commit ee030fd to get more accurate results
@@ Coverage Diff @@
## master #207 +/- ##
==========================================
+ Coverage 83.96% 84.54% +0.58%
==========================================
Files 7 7
Lines 106 110 +4
Branches 27 28 +1
==========================================
+ Hits 89 93 +4
Misses 17 17
Impacted Files | Coverage Δ | |
---|---|---|
packages/sql/src/index.ts | 65.38% <100.00%> (+6.29%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 2c1f8c8...ee030fd. Read the comment docs.
Thanks for this PR!
But should we reuse the endOfLine
option from prettier
core?
https://prettier.io/docs/en/options.html#end-of-line
The previous behavior could be a new option value avoid
as the default value for compatibility.
Thanks for comment.
But should we reuse the
endOfLine
option fromprettier
core?
sql-formatter
seems to support only lf
.
It means the end of other each line is always lf
, so I think the final line should be so too.
The previous behavior could be a new option value
avoid
as the default value for compatibility.
In previous version, it always removes a final newline, doesn't preserve original.
There is a final newline here: https://github.com/un-ts/prettier/blob/2c1f8c8d9de6702557bdc6273b7ea4f771e5c64e/packages/sql/test/fixtures/basic.sql#L10
After formatting, the final newline have been removed: https://github.com/un-ts/prettier/blob/2c1f8c8d9de6702557bdc6273b7ea4f771e5c64e/packages/sql/test/__snapshots__/fixtures.spec.ts.snap#L29
sql-formatter seems to support only lf.
We can adapt this in prettier-plugin-sql
by simple formatted.replace(/\r?\n/g, ending)
In previous version, it always removes a final newline, doesn't preserve original.
That's why I say we should use avoid
as the default value.
endOfLine
is for all lines, so avoid
should not be presented, maybe we should just keep the previous behavior on auto
.
This would a BREAKING CHANGE as prettier use lf
by default now, but this feature is on v0.10.0
, so breaking is allowed.
I added a new commit. Do you mean like this?
Hmm, I think it is a strange that endOfLine
affects final newline.
~In addition, if this plugin respects endOfLine
, I think it should preserve original line ending on auto
same as prettier
.~
"auto" - Maintain existing line endings (mixed values within one file are normalised by looking at what’s used after the first line)
~Acutually, however, even if the original line ending is crlf
, it will be replaced with lf
by sql-formatter
.
This is an unexpected behavior for users.~
Sorry, it's my misunderstanding.
All crlf
will replaced with lf
by sql-formatter
, but prettier
core replaces them with a value based endOfLine
again.
The same is true for the final newline, formatted + '\n'
works as expected without reference to endOfLine
.
For that reason, I think we just need an option to control the final newline for this plugin.
Hmm, I think it is a strange that endOfLine affects final newline.
Isn’t prettier core doing this also?
It seems there is no way to get original auto
endOfLine
value
So a new option seems really needed, thanks!
I'm thinking is there any user case to have no final new line support? Prettier always print final new line AFAIK.
@frozenbonito Thanks for your contribution!
I'm thinking is there any user case to have no final new line support? Prettier always print final new line AFAIK.
I agree with you.
Thank you for refactoring and merging!
close #204