Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change response to top-level this? #151

Closed
Rich-Harris opened this issue Apr 12, 2015 · 5 comments
Closed

change response to top-level this? #151

Rich-Harris opened this issue Apr 12, 2015 · 5 comments

Comments

@Rich-Harris
Copy link
Contributor

Follow-on from https://github.com/artsyca/ember-cli-lodash/issues/3.

I'm happy with adding an allowThis option that simply replaces this with undefined rather than throwing an error on property access, but I'm unconvinced that we should only throw an error if someone has checked the disallowThis (or whatever) option. In the vast majority of cases, the use of this.whatever would be a misunderstanding on the part of the module author, and we have an opportunity to educate them and save them a good deal of frustration.

My suggestion: implement allowThis (any ideas for a more accurate name? allowTopLevelThisPropertyAccess possibly overkill), and change the error message to read

`this` at the top level of an ES6 module is `undefined` - you cannot read or write its
properties. Use the `allowThis` option if you need to suppress this error
@jdalton
Copy link
Contributor

jdalton commented Apr 12, 2015

I don't think it's Esperanto's place to educate with default errors. Strict mode and its this behavior has been around for a while now, it's nothing new. If anything a doc note on it would be fine. By erroring by default you catch valid JS. After all you don't know what kind of feature checks devs have in place.

jdalton referenced this issue in mike-north/ember-lodash Jul 6, 2015
@jdalton
Copy link
Contributor

jdalton commented Jul 6, 2015

Ping. This is still causing problems.

@Rich-Harris
Copy link
Contributor Author

Noted. Am tied up with a bunch of other stuff at the moment but if anyone out there wants to submit a PR...?

@jdalton
Copy link
Contributor

jdalton commented Jul 6, 2015

I'm down for a PR. I'll try to get something working this evening. \cc @truenorth.

@mike-north
Copy link

Awesome. This would be lovely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants