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

Add "owner" reserved word warning #244

Closed
jrowlingson opened this issue Nov 14, 2017 · 4 comments
Closed

Add "owner" reserved word warning #244

jrowlingson opened this issue Nov 14, 2017 · 4 comments

Comments

@jrowlingson
Copy link

jrowlingson commented Nov 14, 2017

After running ember-qunit-codemod against our app I observed that a test was falling with the following message:

TypeError: Cannot read property 'apply' of undefined

The relevant potion of the affected test:

  test('it displays the project owner', async function(assert) {
    this.set('owner', 'some_username');
    await render(hbs`{{project owner=owner}}`);
    
    ...
    
  });

It looks like this is now falling because the owner property is now set within the test context (https://github.com/emberjs/ember-test-helpers/blame/0cacde9a1ba308409394b18f3705e60499955b45/addon-test-support/%40ember/test-helpers/setup-context.js#L90
).

I am not sure what may be the best way to handle this, but, I am thinking adding a check prior to setting owner may be helpful.

@Turbo87
Copy link
Member

Turbo87 commented Feb 16, 2018

That seems like a good idea. We should probably warn whenever someone tries to set owner, element or any of the other keywords.

Or we make this.get/set() operate on a different context, though that might be confusing 🤔

@rwjblue
Copy link
Member

rwjblue commented Feb 16, 2018

Yep, totally happy with this. But not quite sure how to implement. I suppose we could swap from normal property sets to Object.defineProperty with a setter that throws a helpful error?

@Turbo87
Copy link
Member

Turbo87 commented Feb 16, 2018

can't we do that check in the .set() function that we put onto this?

@rwjblue
Copy link
Member

rwjblue commented Feb 16, 2018

Sure, but won’t catch most cases. I don’t think most folks go through set unless required...

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

No branches or pull requests

3 participants