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

fix(code-frame): do not pad gutter of empty lines #12567

Merged
merged 2 commits into from Dec 29, 2020

Conversation

SimenB
Copy link
Contributor

@SimenB SimenB commented Dec 28, 2020

Q                       A
Fixed Issues? Dunno 😅 It does most of jestjs/jest#10982
Patch: Bug Fix? Yes
Major: Breaking Change? Possibly, depending on whether the whitespace of the code frame is considered part of the contract (e.g. it'll break people snapshotting errors from Jest, but that is not a supported use case on Jest's side, so it doesn't matter)
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link N/A
Any Dependency Changes? No
License MIT

I don't think the trailing space adds anything.

@@ -105,8 +105,8 @@ describe("@babel/code-frame", function () {
test("opts.highlightCode with multiple columns and lines", function () {
// prettier-ignore
const rawLines = [
"function a(b, c) {",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ergh, shouldn't matter, I thought for a moment the trailing spaces were inside the string. So I'll leave it as is for now unless you want me to roll back

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that it wasn't already fixed by prettier 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ignore above it I assume 🙂

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 28, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/36577/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 28, 2020

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.

Latest deployment of this branch, based on commit 0d68324:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@nicolo-ribaudo nicolo-ribaudo added the PR: Polish 💅 A type of pull request used for our changelog categories label Dec 28, 2020
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicolo-ribaudo
Copy link
Member

@SimenB I pushed a workaround since the Jest e2e test is failing (as expected).
We'll remove it once we publish a new version of @babel/code-frame and you update it in the Jest repo.

@SimenB
Copy link
Contributor Author

SimenB commented Dec 29, 2020

@nicolo-ribaudo if you run against jest@master I can just apply a patch to the local install of @babel/code-frame until you release, if that's easier

@nicolo-ribaudo
Copy link
Member

I don't want to force it on you since it's just caused by our tests, I just have to tune the regexp to make it pass 😅

@nicolo-ribaudo nicolo-ribaudo force-pushed the gutter-padding branch 2 times, most recently from d80ebeb to e0421aa Compare December 29, 2020 02:12
@nicolo-ribaudo nicolo-ribaudo merged commit 2d35f5a into babel:main Dec 29, 2020
@SimenB SimenB deleted the gutter-padding branch December 29, 2020 14:48
@fisker
Copy link
Contributor

fisker commented Feb 3, 2021

I'm late for this, when we replace the EOL

Before

  1 | <LF>
  2 | <LF>
> 3 | class    a {<LF>
    |         ^^^^<LF>
> 4 |   b(  <|> ) {}<LF>
    | ^^^^^^^^^^^^^^<LF>
  5 | }<LF>
  6 | <LF>
  7 | let    x

After

  1 |<LF>
  2 |<LF>
> 3 | class    a {<LF>
    |         ^^^^<LF>
> 4 |   b(  <|> ) {}<LF>
    | ^^^^^^^^^^^^^^<LF>
  5 | }<LF>
  6 |<LF>
  7 | let    x

The first one looks more "real" 😄

Diff on Prettier PR, https://github.com/prettier/prettier/pull/10226/files#diff-802d6e48b5b7304cbc7abcb6aa1690a5419eecec01b4d971926a8ebd94548a04R85

Not important, but just want let you know.

@SimenB
Copy link
Contributor Author

SimenB commented Feb 3, 2021

ah it's released, nice 👍

PR updating in Jest if you wanna remove the hack made to the e2e tests here: jestjs/jest#11048

nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Feb 3, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants