ember-native-class-codemod
ember-native-class-codemod copied to clipboard
need option '--decorators=true' thrown when transforming `action(function) {})`
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() {
//
});
})
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,
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
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
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!
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
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?