This PR adds 2 options that configures the behavior when escope encountered unknown nodes.
fallback (default is "iteration") - The default behavior is as is. So it visits every enumerable property of the unknown node. If we set "none" to this fallback option then escope comes to just raise an error at unknown nodes. This is helpful to prevent the stack overflow caused by circular references.
childVisitorKeys (default is null) - This option allows us to extend known nodes. This option is the same as the childVisitorKeys option of esrecurse.
For example, how to support JSX syntax:
var jsxKeys = require("estraverse-fb/keys");
var result = escope.analyze(ast, {fallback: "none", childVisitorKeys: jsxKeys});
I like the behavior of fallback: "none", but I didn't change the default behavior in order to avoid a breaking change.
This PR adds 2 options that configures the behavior when
escope
encountered unknown nodes.fallback
(default is"iteration"
) - The default behavior is as is. So it visits every enumerable property of the unknown node. If we set"none"
to thisfallback
option thenescope
comes to just raise an error at unknown nodes. This is helpful to prevent the stack overflow caused by circular references.childVisitorKeys
(default isnull
) - This option allows us to extend known nodes. This option is the same as thechildVisitorKeys
option ofesrecurse
.For example, how to support JSX syntax:
I like the behavior of
fallback: "none"
, but I didn't change the default behavior in order to avoid a breaking change.Related: https://github.com/eslint/eslint/issues/5007
I'm happy to follow review and direction.