Skip to content

Commit ab2a93c

Browse files
committed
Remove glimmer components from tests as telemetry helpers do not report glimmer components
1 parent 208d697 commit ab2a93c

File tree

9 files changed

+24
-68
lines changed

9 files changed

+24
-68
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
root: true,
33
parserOptions: {
4-
ecmaVersion: 2017,
4+
ecmaVersion: 'latest',
55
},
66
env: {
77
node: true,

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,19 @@ If you would like to only convert certain component invocations to use the angle
193193

194194
### Making helper invocations unambiguous
195195

196-
In order to make helper invocations unambiguous, use this:
196+
You may want to convert invocations like `{{concat "foo" "bar"}}` into `{{(concat "foo" "bar")}}`, which may be useful as a temporary step when upgrading to strict-mode Embroider.
197197

198-
**config/anglebrackets-codemod-config.json**
198+
In your **config/anglebrackets-codemod-config.json**, add this:
199199

200200
```js
201201
{
202202
"unambiguousHelpers": true
203203
}
204204
```
205205

206-
This will result in invocations like `{{concat "foo" "bar"}}` to be converted into `{{(concat "foo" "bar")}}`, which may be useful in strict-mode Embroider.
207-
208-
Note that it does not work in non-Embroider Ember, as of January 2024.
206+
Note that unambiguous helpers do not work in non-Embroider Ember, as of January 2024.
209207

210-
Note that ambiguous invocations, that cannot be statically distinguished between a helper, a property and a component, will not be modified.
208+
Note that ambiguous invocations that cannot be statically distinguished between a helper, a property and a component will not be modified.
211209

212210
## Debugging Workflow
213211

test/fixtures/with-telemetry/input/app/templates/application.hbs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,19 @@
33
<h3 class="sr-only">
44
Components
55
</h3>
6-
<BsNav @type="pills" @stacked={{true}} as |nav|>
6+
{{#bs-nav type="pills" stacked=true as |nav|}}
77
{{#each this.model as |comp|}}
8-
<nav.item>
9-
<nav.link-to @route={{comp.demoRoute}}>
8+
{{#nav.item}}
9+
{{#nav.link-to route=comp.demoRoute}}
1010
{{comp.title}}
11-
</nav.link-to>
12-
</nav.item>
11+
{{/nav.link-to}}
12+
{{/nav.item}}
1313
{{/each}}
14-
</BsNav>
14+
{{/bs-nav}}
1515
</div>
1616
<div class="col-sm-8 col-sm-pull-4 col-md-9 col-md-pull-3">
17-
{{utils/bee-bop}}
1817
{{-wat-wat}}
19-
{{utils/-wat-wat}}
20-
{{#if this.isDetailPage}}
21-
<h1>
22-
{{currentComponent.title}}
23-
</h1>
24-
<p class="lead">
25-
{{currentComponent.description}}
26-
</p>
27-
{{api-reference component=this.currentComponent}}
28-
{{/if}}
29-
{{outlet}}
30-
31-
{{#bs-button id="openModal" onClick=(action "addModal")}}Open{{/bs-button}}
32-
33-
{{#if hasModal}}
34-
{{#bs-modal-simple open=modal onHidden=(action "removeModal") title="Dynamic Dialog"}}
35-
Hi there
36-
{{/bs-modal-simple}}
37-
{{/if}}
38-
<FileLess @foo={{true}} />
18+
{{outlet}}
19+
{{file-less foo=true}}
3920
</div>
4021
</div>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
<div>this template has no js </div>
2-
{{#bs-button type="primary"}}Primary{{/bs-button}}

test/fixtures/with-telemetry/output/app/templates/application.hbs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,8 @@
1414
</BsNav>
1515
</div>
1616
<div class="col-sm-8 col-sm-pull-4 col-md-9 col-md-pull-3">
17-
<Utils::BeeBop />
1817
{{-wat-wat}}
19-
<Utils::-WatWat />
20-
{{#if this.isDetailPage}}
21-
<h1>
22-
{{currentComponent.title}}
23-
</h1>
24-
<p class="lead">
25-
{{currentComponent.description}}
26-
</p>
27-
<ApiReference @component={{this.currentComponent}} />
28-
{{/if}}
29-
{{outlet}}
30-
31-
<BsButton @id="openModal" @onClick={{action "addModal"}}>Open</BsButton>
32-
33-
{{#if hasModal}}
34-
<BsModalSimple @open={{modal}} @onHidden={{action "removeModal"}} @title="Dynamic Dialog">
35-
Hi there
36-
</BsModalSimple>
37-
{{/if}}
18+
{{outlet}}
3819
<FileLess @foo={{true}} />
3920
</div>
4021
</div>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
<div>this template has no js </div>
2-
<BsButton @type="primary">Primary</BsButton>

transforms/angle-brackets/telemetry/invokable.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ function invokableName(name, type) {
1616
invokePath = '/components/';
1717
}
1818

19-
console.log({
20-
name,
21-
invokePath,
22-
result: name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length),
23-
});
2419
return name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length);
2520
}
2621

transforms/angle-brackets/transform.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ function isKnownHelper(fullName, config, invokableData) {
349349
if (isComponent) {
350350
return false;
351351
}
352+
353+
let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
354+
let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);
355+
let strName = `${name}`; // coerce boolean and number to string
356+
return isHelper && !strName.includes('.');
352357
} else {
353358
let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
354359
let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);

transforms/angle-brackets/transform.test.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,24 +1382,22 @@ test('unknown helper with args', () => {
13821382
"
13831383
<ApiReference @component={{this.currentComponent}} />
13841384
{{api-reference someArg}}
1385-
<ApiReference />
1385+
{{api-reference}}
13861386
"
13871387
`);
13881388
});
13891389

13901390
test('unambiguousHelpers: true', () => {
13911391
let input = `
1392-
{{concat}}
1393-
{{unknown}}
1394-
{{t "some.string" param="string" another=1}}
1392+
{{helper-1}}
1393+
{{nested/helper "some.string" param="string" another=1}}
13951394
`;
13961395

13971396
expect(runTest('unambiguousHelpers: true', input, { unambiguousHelpers: true }))
13981397
.toMatchInlineSnapshot(`
13991398
"
1400-
{{(concat)}}
1401-
{{unknown}}
1402-
{{(t \\"some.string\\" param=\\"string\\" another=1)}}
1399+
{{(helper-1)}}
1400+
{{(nested/helper \\"some.string\\" param=\\"string\\" another=1)}}
14031401
"
14041402
`);
14051403
});

0 commit comments

Comments
 (0)