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 support for prefixing this only for owned properties #123

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

suchitadoshi1987
Copy link

@suchitadoshi1987 suchitadoshi1987 commented Feb 24, 2020

Currently, the no-implicit-this-codemodprefixes the local, as well as the passed in args with this. While the resulting output of the codemod is guaranteed to be valid runable code, this approach would result in extra churn in the template by changing all paths to this.* paths and subsequently require additional cleanup to change any this.* paths to leverage named arguments such as @foo whenever the backing class does not modify the specific property locally.

Instead of always prefixing ambiguous paths with this. the codemod should only modify the paths that are guaranteed to be local properties of the component. Since the lint rule will complain about all the places in the template where there are still occurrences of implicit-this, it would be easier for the developer to manually inspect all unchanged properties and determine if they need to be prefixed with @.

This PR depends on ember-codemods/ember-codemods-telemetry-helpers#28 PR to be merged

Note: this is an optional feature, to enable it, add the prefix-component-properties-only=true flag to your codemod command

Copy link
Member

rwjblue commented Apr 24, 2020

The telemetry helpers PR has been merged and released as v1.2.0.

@joukevandermaas
Copy link

Any update on this PR? This is something we are also running into.

@suchitadoshi1987
Copy link
Author

@rwjblue , could you review the PR whenever you get some time? I ll resolve the merge conflicts until then

@Alonski
Copy link

Alonski commented Aug 9, 2020

@suchitadoshi1987 Can you please fix the conflicts 😄

@rwjblue
Copy link
Member

rwjblue commented Sep 22, 2020

Ping @suchitadoshi1987 😸

@Techn1x
Copy link

Techn1x commented Apr 16, 2021

I installed from this branch, then ran it and got this error;

npx ember-no-implicit-this-codemod http://localhost:4200 .
Cannot find module 'find-package-json'
Require stack:
- /home/user/my-app/node_modules/ember-no-implicit-this-codemod/bin/cli.js

Had to add find-package-json to my dependencies to get it to work. Also tried installing this branch globally with the same problem.

Then I could run it successfully.

At that point I noticed it was prefixing this. to components, exactly as per my comment here
#101 (comment)

I get that problem with the main branch too so it might just be my use of pods. But I was hoping this branch would avoid that problem because it is supposed to be only prefixing this for owned properties.

@snewcomer
Copy link

Ping! Is this still something we could move forward?

@kexposito
Copy link

Ping 😢, did you find a way of doing this @snewcomer ?

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

Successfully merging this pull request may close these issues.

7 participants