angelozerr/tern.lint — pull request #3 by rkistner (2014-05-12 13:15:45+00:00)
Title: Detect undefined properties and identifiers, and invalid function calls

Thanks for the PoC! I wanted to try something like this earlier, but had no idea where to start.

I rewrote some of the logic to properly detect undefined properties and identifiers, as well as invalid function calls:

* Check for `Identifier` expressions to detect top-level identifiers (instead of just properties).
* Use `.isEmpty()` on the expression type to determine whether or not the property or identifier is defined.
* Use `.getFunctionType() == null` on CallExpressions to determine whether or not it is a function.
* Use `infer.scopeAt()` instead of `file.scope` to get the local scopes of the nodes (otherwise variables declared inside functions are not picked up).
* Use `walk.simple()` instead of `walk.recursive()`, so that it continues walking the tree recursively.