facebook / facebook/jscodeshift

Merge calls to curried function

Aperta
#369 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
10k
Fork
498
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

lodash/fp supports currying, so you can have calls, like this:
`set(key)(value)(obj)`
And I'd like to use a codemod to change them to be a single call, like this:
`set(key, value, obj)`

But I can't figure out how to get the args from the follow on calls (which appear to come before in the iteration) and make a single call. Is there a way to do this with the current version of `jscodeshift`? If not, can this be considered a bug?

Here's the error:
```
ERR web/sockets/PubSubWatcher.js Transformation error ([{ type: TemplateLiteral, start: 654, end: 671, loc: [object Object], expressions: [object Object], quasis: [object Object],[object Object] }, [{ type: MemberExpression, start: 682, end: 696, loc: [object Object], object: [object Object], property: [object Object], computed: false }]] does not match field "arguments": [Expression | SpreadElement] of type CallExpression)
Error: [{ type: TemplateLiteral, start: 654, end: 671, loc: [object Object], expressions: [object Object], quasis: [object Object],[object Object] }, [{ type: MemberExpression, start: 682, end: 696, loc: [object Object], object: [object Object], property: [object Object], computed: false }]] does not match field "arguments": [Expression | SpreadElement] of type CallExpression
at addParam (/usr/local/lib/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:447:27)
at /usr/local/lib/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:470:25
at Array.forEach ()
at Function.callExpression (/usr/local/lib/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:468:35)
at NodePath. (/Users/dlj/projects/numetric.other/tools/code/migrate-curry.js:56:22)
at NodePath. (/usr/local/lib/node_modules/jscodeshift/src/collections/Node.js:142:47)
at /usr/local/lib/node_modules/jscodeshift/src/Collection.js:75:36
at Array.forEach ()
at Collection.forEach (/usr/local/lib/node_modules/jscodeshift/src/Collection.js:74:18)
at Collection.replaceWith (/usr/local/lib/node_modules/jscodeshift/src/collections/Node.js:140:17)
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.