The top-level "this" in an ES6 module is undefined.

IIRC the rule only flags top-level "this" in strict mode, where it becomes
undefined inside of functions.

Please open an issue if you'd like to discuss changes to the docs.

Thanks!

On Tue, Jan 12, 2016, 7:19 AM Nick Evans <[email protected]> wrote:

> I would like to improve the docs for 'no-invalid-this' because the
> behaviour is confusing. The documented behaviour is that the rule flags
> top-level `this` under top-level strict mode. This appears to be the
> desired behaviour (issues #2815, #3961). However, the rule does not flag
> top-level `this` under sloppy mode, even though top-level `this` has the
> same value under sloppy and strict modes:
>
> - Browser scripts: Top-level `this` === `window` (sloppy and strict modes).
> - Node.js scripts: Top-level `this` === `global` (sloppy and strict modes).
> - Node.js modules: Top-level `this` === `exports` (sloppy and strict
> modes).
>
> I cannot find a definite answer for the value of top-level `this` in ES6
> modules:
> - `undefined`
> http://exploringjs.com/es6/ch_modules.html#_browsers-scripts-versus-modules
> - `window`
> http://www.wintellect.com/devcenter/nstieglitz/5-great-features-in-es6-harmony
> - Configurable?
> https://esdiscuss.org/topic/this-if-the-global-object-is-not-in-the-scope-chain
>
> What should the documented behaviour be, and why?
>
> --
> 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.

Reply via email to