-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[babel-generator] Add check for undefined endToken in whitespace #7205
Conversation
Can you add test case for the same? |
@rajzshkr Yes but I don't know what kind of tests I can add as there's no unit test for this method and I don't have a deep understanding of babel-generator's internals. |
check this test case, https://github.com/babel/babel/blob/master/packages/babel-generator/test/fixtures/auto-indentation/hard-tab. Make your failing code in input.js and make sure you get the required output. |
@MatthieuLemoine Does this bug also affect Babel 7? If yes, please make your PR target that branch. In case it has alread been fixed, we probably won't release a new Babel 6 version. |
@nicolo-ribaudo I don't think that this bug affects Babel 7 as Tokens have been removed from babel-generator |
Upgrading to Babel 7 is not straightforward as a lot of plugins has not been updated to work with Babel 7. So I hope that a new bug fix release will be made. |
Test case added. |
@nicolo-ribaudo As you can see, a lot of people is experiencing this issue. This PR only adds a missing undefined check. It looks like an oversight as there's already an undefined check two lines below : if (endToken && endToken.type.label === "eof") If Babel 6 is still officially supported, a bug fix release should be possible. |
I have been running into this issue on a daily basis - very annoying! A Babel 6 release would be awesome! ✨ |
@MatthieuLemoine if we can make CircleCI to pass (I've restarted the build now to see if that helps) - then we should be able to prepare a bug fix release. |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6787/ |
Hope this is understandable but we're not going to be doing this often as the last 6.x release was 6 months ago, and probably won't be doing it at all once 7.x is out unless it's sponsored. We have been working on 7.x for probably a year now and would like to focus on releasing that and fixing any issues people have with upgrading that instead of backporting forever, especially with the limited time people have. No one is really funding the development, especially for something like a backport which is a time consuming thing to do for a volunteer team, let alone a full time sponsored project. Also had a lot of issues with releasing 6.x in the past due to publishing issues in our old setup so I have to go back to figure out why that is and then might cause even more issues for others so it's another reason why extremely hesitate to land anything #4947 https://medium.com/@mikeal/stop-supporting-old-releases-70cfa0e04b0c I am going to update the readme's so we can finally switch our docs over and provide an upgrade experience for 7.x while allowing for switching to the 6.x docs babel/website#1544 so might as well add this in since it's unlikely this will cause any issues unlike a new feature request or port on 6.x
|
Hi ! 👋
In some weird cases, in the following method in
src/whitespace.js
:startToken
can be anEOF
which leads toendToken
beingundefined
and the following error :To avoid this issue, this PR adds an undefined check.
You can look into this issue for reference : detrohutt/babel-plugin-import-graphql#2.
You can find a small reproduction and a video showing this weird behavior.