Skip to content

JSX support#130

Merged
nene merged 10 commits intolebab:masterfrom
nene:espree-parser-2
Jun 3, 2016
Merged

JSX support#130
nene merged 10 commits intolebab:masterfrom
nene:espree-parser-2

Conversation

@nene
Copy link
Copy Markdown
Collaborator

@nene nene commented Jun 3, 2016

Using Espree instead of Esprima to parse the code.

Relatively few small fixes were needed to get our tests to pass with Espree.

New branch without the experiments I did in the other one to get the tests working with old NodeJS versions.

Refs: #128

nene added 9 commits June 3, 2016 10:33
When function has no default parameter values, Esprima 2 provided
an empty array, but Esprima 3 has no `defaults` field at all.

So take care of creating the array when needed.
When using Espree parser, it also adds `start` & `end` fields to
each node, which we also want to ignore when comparing the nodes.
ECMAScript strict mode forbids octal escapes and Espree parser
simply throws an error when it sees one.
Created separate parser module that exposes Esprima-like parse()
method, inside which it configures the parser.
This will allow us to extend ESTraverse functionality and make
it available for everybody who want to use the traversing.
Extend ESTraverse to support JSX AST node types.
Added tests for the full range of JSX syntax.

With this, Lebab should now work fine with code containing JSX.

Hurray!
Our package.json define Node 0.10 as the baseline - we better test against that.
At the same time Node 6 is already out - we better test against the latest stuff as well.
The latter isn't supported by Node < 4.x
This way it's also available for tests, which only require the Traverser class,
allowing the tests to run in NodeJS 0.10.x

As an added bonus, the polyfill is now imported in just one place.
@nene nene merged commit 13a2c58 into lebab:master Jun 3, 2016
@nene nene deleted the espree-parser-2 branch January 21, 2017 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant