un-ts / prettier

:package: Opinionated but Incredible Prettier plugins.
https://prettier.vercel.app
MIT License
260 stars 23 forks source link

fix(sql): printer to handle eol correctly #358

Closed LazyRichard closed 1 day ago

LazyRichard commented 2 months ago

I have the original document like below (with CRLF eol)

CREATE TABLE `CHANGELOG` (
  `ID` NUMERIC(20, 0) PRIMARY KEY NOT NULL,
  `APPLIED_AT` VARCHAR(25) NOT NULL,
  `DESCRIPTION` VARCHAR(256) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = UTF8MB4;

when I set endOfLine config to crlf than result like below

CREATE TABLE `CHANGELOG` (

  `ID` NUMERIC(20, 0) PRIMARY KEY NOT NULL,

  `APPLIED_AT` VARCHAR(25) NOT NULL,

  `DESCRIPTION` VARCHAR(256) NOT NULL

) ENGINE = INNODB DEFAULT CHARSET = UTF8MB4;

when I debug,

sql printer handle eol correctly, but I can find \r\n is replaced by \r\r\n after return formatted value.

actually I didn't find any reference but I guess prettier gives nomalized input as LF and process eol after printer printed.

this patch remove any eol conversion. so, prettier will handle it.


close #365

changeset-bot[bot] commented 2 months ago

⚠️ No Changeset found

Latest commit: 947b0af315ca1f45c47532f6d2108845752f8489

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

codesandbox-ci[bot] commented 2 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

LazyRichard commented 2 months ago

Hello, @JounQin could you review this PR?