substack/node-detective — pull request #27 by thlorenz (2014-01-17 16:34:16+00:00)
Title: adding support to provide custom parse opts and stop esprima from throwing on script level returns

This PR is in two parts.

Put them separately if for whatever reason you have a problem with the 2nd one. The most important is the first commit.
However the current implementation has incorrect location information for the first line which is a problem if you want to use detective in order to **replace** requires instead of just finding them.

`tolerant: true` stops esprima from throwing and is a better solution IMO than wrapping the code inside a function.

1. adding support to provide custom parse opts
- necessary if you want parser to include extra info like location info in the AST

2. esprima tolerant: true and removing wrapper
- tolerant parsing does not throw on script level returns
- enforcing this option for parse makes the function wrapper no longer needed
- location info for first line is now correct (see test/parseopts.js)