uber/uber-ngen — pull request #38 by Raynos (2014-07-01 08:44:13+00:00)
Title: Set shadow to outer

I ran into this bug 10 minutes ago

```js
if (opts.lateTimeoutLogger) {
opts.logger = {
fatal: function fatal(message, opts, cb) {
// simulate a really slow logger
setTimeout(function delay() {
cb();
}, opts.loggerTimeout * 2);
}
};
}
```

Here I set `opts.logger` to a function that has a parameter named `opts`. The function parameter of the fatal method shadows the outer `opts` and thus referencing `opts.loggerTimeout` is `undefined` which means passing `NaN` to `setTimeout` which is much fun.

jshint has a feature called `"shadow": "outer"` which is disabled by default. If you opt into this it will complain about all shadowing of variable names defined in outer scopes.

This means the above code is now a static bug and has to be refactored to `fatal(message, options, cb)` or something.

This is a great poorly documented feature. (only documented in the unit tests -.-)

cc @dfellis @sh1mmer @mlmorg @Matt-Esch