I want to use the UglifyJS parser to check if any identifiers in a piece of code are used when they are not guaranteed to be defined.
Example:
// Should raise an error since myfunc and myvar have not been defined, but works
var ast = jsp.parse('myfunc(myvar);');
I realise that myfunc
and myvar
are not necessarily undefined (since they could exist in scope) but I want to know when they possibly might be undefined.
echo "myfunc(myvar);" | uglifyjs
happily returns myfunc(myvar);
and I can't find any option to check for undefined variables.
If I run JSLint and turn assume browser, window, node.js, etc
all off, then this is the result I'm after. I want to do a similar thing with UglifyJS, assuming nothing about the environment (no window, console, alert, etc).