acornjs / acorn-jsx

Alternative, faster React.js JSX parser
MIT License
648 stars 74 forks source link

Add support for acorn walker #77

Closed ehmicky closed 7 years ago

ehmicky commented 7 years ago

The current code does not add support for the acorn walker utility.

I have a branch ready to submit as a PR, I just want your confirmation this would be merged before I start working on it.

Note that I would add this, but would not add the corresponding unit tests.

RReverser commented 7 years ago

Personally I like a separate estraverse tool more for this kind of tasks and have extension for it https://github.com/RReverser/estraverse-fb. Is there something specific about Acorn walker you want to use?

ehmicky commented 7 years ago

There is one important missing feature from estraverse: one cannot specify abstract types. E.g. if I want to trigger a callback on any Declaration, I must check for several node types VariableDeclaration, FunctionDeclaration, ClassDeclaration (and check each time when new ES syntax introduce new types). Also, this project does not seem to be maintained anymore.

But I do agree that it probably is a better idea to have a separate project for ESTree walking, as oppose to add it to each parser or parser extension.

RReverser commented 7 years ago

@ehmicky That's certainly an interesting use case. How about ast-types? It has all these abstract types and already supports JSX AFAIK.

ehmicky commented 7 years ago

This looks like this would work. If anyone needs for some reason to traverse JSX using the acorn walker, they can always comment here, but I'm convinced external tools should be used instead.