ember-codemods / ember-no-implicit-this-codemod

Template codemod for refactoring from `{{foo}}` to `{{this.foo}}`
MIT License
17 stars 25 forks source link

Transform to `{{@foo}}` if component class does not define the property #107

Open jelhan opened 4 years ago

jelhan commented 4 years ago

In it's current state the codemod transforms {{foo}} always to {{this.foo}} (skipping template-only components). It should transform {{foo}} to {{@foo}} instead if the property is not defined by the class of the codemod.

It may always transform to {{this.foo}} if the component extends from another component cause parsing parent classes may be to complex. It should print a warning in that case.

gabrielcsapo commented 4 years ago

I think given that we can use the arguments passed into the component to reference what needs this. and what needs @ this should be straightforward. Looking into fixing this for our use cases in our application.

rwjblue commented 4 years ago

I'm pretty sure that @suchitadoshi1987 has work in progress to address this.

gabrielcsapo commented 4 years ago

@rwjblue she said she would link to this issue in a conversation I had with her. @suchitadoshi1987 😄

suchitadoshi1987 commented 4 years ago

https://github.com/ember-codemods/ember-no-implicit-this-codemod/pull/123 This PR would address this issue. However, it will not assume the prefixing of @. It just makes the prefixing of this more stricter.

suchitadoshi1987 commented 4 years ago

cc @gabrielcsapo ^^

gabrielcsapo commented 4 years ago

thank you @suchitadoshi1987

kexposito commented 7 months ago

Any update on this?