Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle service name on multi-lines (strings with '+' operator) #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ludosch
Copy link

@ludosch ludosch commented Jan 30, 2020

Got error on test file :

ERR tests/unit/features/components/xxx/component-test.js Transformation error (undefined does not match field "name": string of type Identifier)
Error: undefined does not match field "name": string of type Identifier
    at addParam (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\node_modules\ast-types\lib\types.js:565:23)
    at C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\node_modules\ast-types\lib\types.js:594:21
    at Array.forEach (<anonymous>)
    at Function.identifier (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\node_modules\ast-types\lib\types.js:592:30)
    at NodePath.ctx.find.forEach.p (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\transforms\convert-module-for-to-setup-test/index.js:890:26)
    at __paths.forEach (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\node_modules\jscodeshift\src\Collection.js:77:36)
    at Array.forEach (<anonymous>)
    at Collection.forEach (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\node_modules\jscodeshift\src\Collection.js:76:18)
    at updateInjectCalls (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\transforms\convert-module-for-to-setup-test/index.js:879:8)
    at moduleInfo.moduleOptions.properties.forEach.property (C:\Users\Public\app\nvm\v10.16.3\node_modules\ember-qunit-codemod\transforms\convert-module-for-to-setup-test/index.js:403:13)

Reproduction

In test file, you have an inject service name cuted like this :

this.inject.service('service-with-a' + 
'-really-long-name', { as: 'service-with-a' +
 '-really-long-name' });

And run ember-qunit-codemod (no special arguments)

Change

This PR transforms cuted long services names in a single one, so there are no longer errors

@ludosch ludosch requested a review from rwjblue January 31, 2020 16:41
Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we should flatten things here (vs preserving the concatenation).

Happy to land either way (though I'd love to discuss the pros/cons of flattening), but will need some tests in order to move forward.

@ludosch ludosch force-pushed the fix-service-multilines branch from 508179e to f32f5dd Compare February 10, 2020 11:03
@ludosch
Copy link
Author

ludosch commented Feb 10, 2020

@rwjblue : I added tests.
Yes, I think not flatten names is the best choice, but it's easiest to find services names after apply the codemod because they have the same name as attributes.

@ludosch ludosch requested a review from rwjblue February 10, 2020 14:32
@ludosch
Copy link
Author

ludosch commented Mar 10, 2020

@rwjblue : do you finally want a new version without flattening the names anyway ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants