ember-codemods / ember-native-class-codemod

A codemod-cli project for converting Ember objects to es6 native classes
67 stars 38 forks source link

Codemod mistakes `computed.equal` for a modifier #429

Open elwayman02 opened 3 years ago

elwayman02 commented 3 years ago

When encountering code where the computed namespace has been imported rather than the individual methods (e.g. computed.equal), the codemod outputs the following error:

Transform not supported - value has modifiers like 'property' or 'meta'

Presumably, it thinks computed.equal is the same thing as computed().volatile() or computed().meta(), and thus is erroring out instead of codemodding the file. Changing uses of the computed namespace to their equivalent imports is an existing workaround, but we should fix the codemod bug instead of requiring people to work around it!

elwayman02 commented 3 years ago

The error comes from hasModifierWithArgs having the incorrect value: https://github.com/ember-codemods/ember-native-class-codemod/search?q=hasModifierWithArgs

pzuraq commented 3 years ago

Importing computed and invoking values like computed.equal was not part of the module API, and was a quirk of the fact that the module API was polyfilled via the global API. This functionality has been deprecated along with using the Ember global, and you should take this opportunity to rewrite the class in question to use the proper import path.

I don't think this is necessarily a case the codemod has to handle, given it's unusual and can be fixed before the codemod is run, but will accept a PR to add the functionality.