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

feat: if code frame error is on a single line, highlight the whole path #10361

Merged
merged 2 commits into from Oct 29, 2019

Conversation

SimenB
Copy link
Contributor

@SimenB SimenB commented Aug 22, 2019

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? 👍
Tests Added + Pass? No
Documentation PR Link
Any Dependency Changes? No
License MIT

Before:
image

After:
image

buildCodeFrameError doesn't seem to have any tests, at least not any I could find. Thoughts on where I can add one (if you want this)

This might make sense as an option passed to path.buildCodeFrameError rather than buildCodeFrameError forcing it on consumers?

@babel-bot
Copy link
Collaborator

babel-bot commented Aug 22, 2019

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

@JLHwung
Copy link
Contributor

JLHwung commented Aug 22, 2019

The highlighted path may contain many subpaths even though they are within the same line, i.e.

foo(a, b(f, { g: h(i) }))

If the whole callExpression foo(a, b(f, { g: h(i) })) is highlighted, user may even get more confused than we simply highlight the start foo.

@JLHwung JLHwung added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Aug 22, 2019
@nicolo-ribaudo
Copy link
Member

I prefer this PR to the current behavior. In @JLHwung example, if the problem is the whole call expression I don't see why it shouldn't be highlighted.

@nicolo-ribaudo nicolo-ribaudo added this to the v7.7.0 milestone Sep 17, 2019
@existentialism existentialism added the PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release label Sep 25, 2019
@nicolo-ribaudo nicolo-ribaudo merged commit f1bc6c4 into babel:master Oct 29, 2019
@SimenB SimenB deleted the code-frame-end-line branch October 29, 2019 22:48
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 29, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 29, 2020
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 pkg: core PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants