-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the possibility to select different parsers (closes #117)
jscodeshift uses Babel v5 to parse source files. Since Babel v5 doesn't get updated anymore, jscodeshift is unable to parse files that contain more modern flow type annotation. To solve this, jscodeshift now supports three parsers: Babel v5, babylon and flow. The parser to use can be chosen by either - passing the command line option `parser`: `--parser=babelv5`, `--parser=babylon`, `--parser=flow`. - having the transform file export `parser`, with either the values `"babelv5"`, `"babylon"` or `"flow` to choose one of the built-int parsers, or export a parser object (e.g. `exports.parser = require('flow=parser'`) This allows transform to specify their own parser (as long as it is compatible with ESTree / recast), making them a bit more independent from jscodeshifts internals. In addition to this change, `jscodeshift` now accepts a second argument, `options` which is directly parsed passed to `recast.parse`. So if you use `jscodeshift` programmatically , you can now pass your own parser with ``` jscodeshift(source, {parser: require('myParser')}) ``` **Note:** This is *not* a breaking change. Babel v5 still stays the default parser, but we will likely use another parser (babylon or flow) as default in the future.
- Loading branch information
Showing
30 changed files
with
699 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,8 @@ | |
}, | ||
"env": { | ||
"node": true | ||
}, | ||
"globals": { | ||
"Promise": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/src/ | ||
/sample/ | ||
.gitignore | ||
.eslintrc | ||
.eslintrc.yaml | ||
.jshintrc | ||
.module-cache | ||
__tests__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ sudo: false | |
language: node_js | ||
node_js: | ||
- 4 | ||
- 5 | ||
- stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
327f985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Happy to help debug any problems that arise from this.
327f985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm i jscodeshift
now yields an ENOENT error attempting to install thebabelv5
local fork. Perhaps the packaging when published didn't pick it up?node v6.2.0
npm v3.9.6
327f985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh :( I'll look into it
327f985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not use
file:
URLs in the dependencies? (and publish to npm)