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.
