ember-no-implicit-this-codemod
ember-no-implicit-this-codemod copied to clipboard
Add support for prefixing `this` only for owned properties
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 https://github.com/ember-codemods/ember-codemods-telemetry-helpers/pull/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
The telemetry helpers PR has been merged and released as v1.2.0.
Any update on this PR? This is something we are also running into.
@rwjblue , could you review the PR whenever you get some time? I ll resolve the merge conflicts until then
@suchitadoshi1987 Can you please fix the conflicts 😄
Ping @suchitadoshi1987 😸
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
https://github.com/ember-codemods/ember-no-implicit-this-codemod/issues/101#issuecomment-820817914
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.
Ping! Is this still something we could move forward?
Ping 😢, did you find a way of doing this @snewcomer ?