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(babel-highlight::index.ts): Short-circuit empty source highlighting #14381
Conversation
Short-circuit empty source highlighting to prevent infinite iteration.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51536/ |
Add comma to match project lint errors
@nicolo-ribaudo @zxbodya @CommanderRoot @blankPen |
We already guard against the empty source in #14165. The |
Ah,#14165 should solve the problem we've encountered, and seemed to be a better solution. The situation we've been in is that we've using stylelint for style linting in vue-cli. When calling vue-cli-service lint:style, it will call stylelint to lint scss files. When we've create empty files in the project, the stylelint creates warning for empty file, showing that it conflicts with no-empty-source, using babel-highlight for highlighting outputs, passing '' to the highlighter, and eventually trapped in the infinite loop of highlightTokens. IMO this is nesassary for us, since it's not only awkward for not knowing what REALLY HAPPENS in linting styles by actually shows nothing but a forever spinning icon, but also stuck our building CI/CD procedure. Really looking forward for the bugfix releases, can you please to help for a faster progress? |
This PR should be closed since #14165 could be a better solution. |
It has been released in v7.16.10 🤔 |
Thanks! ❤ |
Short-circuit empty source highlighting to prevent infinite iteration.
When we are using babel-highlight to highlight the stylelint output results, we surprisingly found that babel-highlight plugin fails on
empty
source files: While passing''
totokenize
function, it will end up in an infinite iterator.IMO I thought the empty source is worthless for highlighting(since the result won't disappear to be different after highlighting), so maybe a short-circuit guard will be a solution to this case 😄
FYI,the case we've encountered in this situation: