Skip to content

Commit 26a181d

Browse files
patocallaghanNullVoxPopuli
authored andcommitted
Add ES5 getters to telemetry data (#10)
* Use getter data to determine this usage * Bump ember-codemods-telemetry-helpers to 0.3.0
1 parent 2ece39f commit 26a181d

4 files changed

Lines changed: 7 additions & 3 deletions

File tree

transforms/no-implicit-this/__testfixtures__/-mock-telemetry.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
},
4444
"handlebars-without-params.input": {
4545
"type": "Component",
46-
"computedProperties": ["foo", "property"]
46+
"computedProperties": ["foo", "property"],
47+
"getters": ["someGetter"]
4748
},
4849
"my-helper": { "type": "Helper" },
4950
"a-helper": { "type": "Helper" },

transforms/no-implicit-this/__testfixtures__/handlebars-without-params.input.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
{{foo}}
44
{{property}}
55
{{namespace/foo}}
6+
{{someGetter}}

transforms/no-implicit-this/__testfixtures__/handlebars-without-params.output.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
{{this.foo}}
44
{{this.property}}
55
{{namespace/foo}}
6+
{{this.someGetter}}

transforms/no-implicit-this/helpers/plugin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ function doesTokenNeedThis(
8080
return false;
8181
}
8282

83-
let { computedProperties, ownActions, ownProperties } = runtimeData;
83+
let { computedProperties, getters, ownActions, ownProperties } = runtimeData;
8484
let isComputed = (computedProperties || []).includes(token);
8585
let isAction = (ownActions || []).includes(token);
8686
let isProperty = (ownProperties || []).includes(token);
87+
let isGetter = (getters || []).includes(token);
8788

88-
let needsThis = isComputed || isAction || isProperty;
89+
let needsThis = isComputed || isAction || isProperty || isGetter;
8990

9091
if (needsThis) {
9192
return true;

0 commit comments

Comments
 (0)