diff --git a/.eslintrc.js b/.eslintrc.js
index 3bc604e7..c9a0cdd4 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,7 +1,7 @@
module.exports = {
root: true,
parserOptions: {
- ecmaVersion: 2017,
+ ecmaVersion: 'latest',
},
env: {
node: true,
diff --git a/README.md b/README.md
index 508417c4..b1f42e7f 100644
--- a/README.md
+++ b/README.md
@@ -193,9 +193,9 @@ If you would like to only convert certain component invocations to use the angle
### Making helper invocations unambiguous
-In order to make helper invocations unambiguous, use this:
+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.
-**config/anglebrackets-codemod-config.json**
+In your **config/anglebrackets-codemod-config.json**, add this:
```js
{
@@ -203,11 +203,9 @@ In order to make helper invocations unambiguous, use this:
}
```
-This will result in invocations like `{{concat "foo" "bar"}}` to be converted into `{{(concat "foo" "bar")}}`, which may be useful in strict-mode Embroider.
-
-Note that it does not work in non-Embroider Ember, as of January 2024.
+Note that unambiguous helpers do not work in non-Embroider Ember, as of January 2024.
-Note that ambiguous invocations, that cannot be statically distinguished between a helper, a property and a component, will not be modified.
+Note that ambiguous invocations that cannot be statically distinguished between a helper, a property and a component — will not be modified.
## Debugging Workflow
diff --git a/test/fixtures/with-telemetry/input/app/templates/application.hbs b/test/fixtures/with-telemetry/input/app/templates/application.hbs
index c0dba446..332dd51e 100644
--- a/test/fixtures/with-telemetry/input/app/templates/application.hbs
+++ b/test/fixtures/with-telemetry/input/app/templates/application.hbs
@@ -3,38 +3,19 @@
Components
-
+ {{#bs-nav type="pills" stacked=true as |nav|}}
{{#each this.model as |comp|}}
-
-
+ {{#nav.item}}
+ {{#nav.link-to route=comp.demoRoute}}
{{comp.title}}
-
-
+ {{/nav.link-to}}
+ {{/nav.item}}
{{/each}}
-
+ {{/bs-nav}}
- {{utils/bee-bop}}
{{-wat-wat}}
- {{utils/-wat-wat}}
- {{#if this.isDetailPage}}
-
- {{currentComponent.title}}
-
-
- {{currentComponent.description}}
-
- {{api-reference component=this.currentComponent}}
- {{/if}}
- {{outlet}}
-
- {{#bs-button id="openModal" onClick=(action "addModal")}}Open{{/bs-button}}
-
- {{#if hasModal}}
- {{#bs-modal-simple open=modal onHidden=(action "removeModal") title="Dynamic Dialog"}}
- Hi there
- {{/bs-modal-simple}}
- {{/if}}
-
+ {{outlet}}
+ {{file-less foo=true}}
diff --git a/test/fixtures/with-telemetry/input/app/templates/components/file-less.hbs b/test/fixtures/with-telemetry/input/app/templates/components/file-less.hbs
index b9c03c0c..6c801e1d 100644
--- a/test/fixtures/with-telemetry/input/app/templates/components/file-less.hbs
+++ b/test/fixtures/with-telemetry/input/app/templates/components/file-less.hbs
@@ -1,2 +1 @@
this template has no js
-{{#bs-button type="primary"}}Primary{{/bs-button}}
diff --git a/test/fixtures/with-telemetry/output/app/templates/application.hbs b/test/fixtures/with-telemetry/output/app/templates/application.hbs
index 552feede..87bcba4c 100644
--- a/test/fixtures/with-telemetry/output/app/templates/application.hbs
+++ b/test/fixtures/with-telemetry/output/app/templates/application.hbs
@@ -14,27 +14,8 @@
-
{{-wat-wat}}
-
- {{#if this.isDetailPage}}
-
- {{currentComponent.title}}
-
-
- {{currentComponent.description}}
-
-
- {{/if}}
- {{outlet}}
-
-
Open
-
- {{#if hasModal}}
-
- Hi there
-
- {{/if}}
+ {{outlet}}
diff --git a/test/fixtures/with-telemetry/output/app/templates/components/file-less.hbs b/test/fixtures/with-telemetry/output/app/templates/components/file-less.hbs
index 4c50d5d9..6c801e1d 100644
--- a/test/fixtures/with-telemetry/output/app/templates/components/file-less.hbs
+++ b/test/fixtures/with-telemetry/output/app/templates/components/file-less.hbs
@@ -1,2 +1 @@
this template has no js
-Primary
diff --git a/transforms/angle-brackets/telemetry/invokable.js b/transforms/angle-brackets/telemetry/invokable.js
index 663abd02..62a3f854 100644
--- a/transforms/angle-brackets/telemetry/invokable.js
+++ b/transforms/angle-brackets/telemetry/invokable.js
@@ -16,11 +16,6 @@ function invokableName(name, type) {
invokePath = '/components/';
}
- console.log({
- name,
- invokePath,
- result: name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length),
- });
return name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length);
}
diff --git a/transforms/angle-brackets/transform.js b/transforms/angle-brackets/transform.js
index 18fbca42..8d94df81 100755
--- a/transforms/angle-brackets/transform.js
+++ b/transforms/angle-brackets/transform.js
@@ -349,6 +349,11 @@ function isKnownHelper(fullName, config, invokableData) {
if (isComponent) {
return false;
}
+
+ let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
+ let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);
+ let strName = `${name}`; // coerce boolean and number to string
+ return isHelper && !strName.includes('.');
} else {
let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])];
let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name);
diff --git a/transforms/angle-brackets/transform.test.js b/transforms/angle-brackets/transform.test.js
index af03ac45..eec96619 100644
--- a/transforms/angle-brackets/transform.test.js
+++ b/transforms/angle-brackets/transform.test.js
@@ -1382,24 +1382,22 @@ test('unknown helper with args', () => {
"
{{api-reference someArg}}
-
+ {{api-reference}}
"
`);
});
test('unambiguousHelpers: true', () => {
let input = `
- {{concat}}
- {{unknown}}
- {{t "some.string" param="string" another=1}}
+ {{helper-1}}
+ {{nested/helper "some.string" param="string" another=1}}
`;
expect(runTest('unambiguousHelpers: true', input, { unambiguousHelpers: true }))
.toMatchInlineSnapshot(`
"
- {{(concat)}}
- {{unknown}}
- {{(t \\"some.string\\" param=\\"string\\" another=1)}}
+ {{(helper-1)}}
+ {{(nested/helper \\"some.string\\" param=\\"string\\" another=1)}}
"
`);
});