-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing custom options to babylon or flow via CLI option
It is not possible anymore to enable every possible option for babylon, because some of them are incompatible. That also means that a single configuration cannot fulfill everybody's needs. While it has always been possible to pass a custom parser + options by using jscodeshift programmatically, this is probably too inconvenient for many people. I have been thinking about how to make different configuration sets available, but every possible combinations of plugins is still opinionated. That's why I introduced the `--parse-config` option, which accepts a path to a JSON file. If passed, the options there will be used instead. A list of all available options for babylon can be found at https://babeljs.io/docs/en/babel-parser#options . To support this I needed to change how parser wrappers are defined. At first I made `options` a second argument to `.parse`, with the default options be set as default value (i.e. `.parse(code, options=defaultOptions`). However, this causes problems with when *no* custom options are passed. Recast itself always passes options to `.parse`, in which case the default options wouldn't be used and parsing would fail.
- Loading branch information
Showing
14 changed files
with
197 additions
and
117 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
Oops, something went wrong.