Hi. You may be interested in `getStaticValue()` function in `eslint-utils` package: https://mysticatea.github.io/eslint-utils/api/ast-utils.html#getstaticvalue Though it doesn't support evaluating user-defined functions for now...
2019年2月21日(木) 7:34 <[email protected]>: > This would be reasonably tough to do. You would have to separately add a > listener for FunctionDelcaration and FunctionExpression and track their > return value. Then on program:exit get the list of all of the variables and > check which function is assigned to them. Basically you have to do that > using multiple passes. > > > > Thanks, > > > > Ilya Volodin > > > > *From:* [email protected] <[email protected]> *On Behalf Of *Chris > Meyer > *Sent:* Wednesday, February 20, 2019 5:11 PM > *To:* ESLint <[email protected]> > *Subject:* [ESLint] Rules: tracking variables back to a literal value > > > > Hi, I need some guidance on how to find a literal value for a variable, if > it can be determined. For example: > > > > function getValue() { > return false; > } > var val = getValue(); > ... > var x = val; > > > > Let's say I wanted to know when x was false. How would I go about walking > back to the return value in the getValue function? The rule I'm working on > is to detect synchronous XMLHttpRequests. > > > > Thanks for any advice! > > -- > You received this message because you are subscribed to the Google Groups > "ESLint" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "ESLint" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "ESLint" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
