jshint/jshint — pull request #1971 by jugglinmike (2014-11-10 20:40:10+00:00)
Title: Improve function name inference

When used programmatically from Node.js, [JSHint exposes a `data` function that returns an object with a `functions` key](https://github.com/jshint/jshint/blob/d0b3cfd935c9445f14b37ea9694d8a172a52739a/src/jshint.js#L5307-L5391). This data describes the functions defined in the linted code. Currently, JSHint uses a simple heuristic to infer the name of functions, and this is often incorrect.

In gh-1893, I proposed removing JSHint's function name inference because I believed the `name` property of function to be well-defined by the ECMAScript 5 spec. [I was wrong about that](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name), but @caitp [showed me how the ES6 spec strictly defines what it means for a function to have a name](https://github.com/jshint/jshint/pull/1893#issuecomment-58914855). This patch mimics much of the behavior defined by the specification.

A notable omission is names that are computed from expressions. For instance, the function in the following example should receive the name "Gozer the Traveler":

```javascript
var name = "Gozer the Traveler";
var obj = {};
obj[name] = function() {};
```

...but this behavior cannot be replicated statically. Instead, such functions are reported as having the name `"(expression)"`.