ember-native-class-codemod icon indicating copy to clipboard operation
ember-native-class-codemod copied to clipboard

need option '--decorators=true' thrown when transforming `action(function) {})`

Open mehulkar opened this issue 5 years ago • 6 comments

With a pretty vanilla run of this codemod, I saw these errors in the logs:

Transform not supported - need option '--decorators=true' or the property type CallExpression can not be transformed

Each of them (I only checked the first few) seems to be pointing to a function that is defined using the action import. E.g.:

export default Component.extend({
  foo: action(function() {
    // 
  });
})

mehulkar avatar Nov 22 '19 19:11 mehulkar

i also ran to the same issue, with

export default Controller.extend({
  foo: new Date().getFullYear().toString()
})

which seems result from the same line of logic https://github.com/ember-codemods/ember-native-class-codemod/blob/ebe7c883bb2771602ab37f6005f037e11bec7779/transforms/helpers/validation-helper.js#L77,

lelea2 avatar May 27 '20 21:05 lelea2

I just hit the same with:

export default Controller.extend({
  endPeriodYear: new Date().getFullYear(),
});
2020-07-02T01:16:43.311Z [warn] [cup-client/app/controllers/returns/history/list.js]: FAILURE 
Validation errors: 
	[endPeriodYear]: Transform not supported - need option '--decorators=true' or the property type CallExpression can not be transformed

jaydgruber avatar Jul 02 '20 01:07 jaydgruber

Was there every a resolution to this? It basically negates the usefulness of this codemod for me as I have properties like this on pretty much every route / controller

wynnerd avatar Oct 28 '21 12:10 wynnerd

I think it would be really helpful to know what https://github.com/ember-codemods/ember-native-class-codemod/blob/ebe7c883bb2771602ab37f6005f037e11bec7779/transforms/helpers/validation-helper.js#L77 is checking for? Removing that last check just does what I was originally expecting this codemod to do!

wynnerd avatar Oct 29 '21 10:10 wynnerd

Same issue here, even though the 'no-actions-hash' eslint rule dictates that this is the correct way of wiring up actions, any classic class that uses it gets skipped during the codemod.

Use the @action decorator or foo: action(function() {})) syntax instead of an actions hash.

https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-actions-hash.md

2021-11-03T12:28:49.559Z [warn] [./app/pods/components/animated-line/component.js]: FAILURE Validation errors: [stage]: Transform not supported - need option '--decorators=true' or the property type CallExpression can not be transformed [points]: Transform not supported - need option '--decorators=true' or the property type CallExpression can not be transformed

eelke avatar Nov 03 '21 12:11 eelke

Hmm I have almost 1000 of this style of action decorator in the codebase. Anyone here find a good way of leveraging this code mod for individual who used action decorators in the ember classic style?

arthur5005 avatar Jan 28 '22 18:01 arthur5005