-
-
Notifications
You must be signed in to change notification settings - Fork 18
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 destructuring arguments #117
fix destructuring arguments #117
Conversation
Hi and very thanks! And yet, I'm not sure if this case really is "args". I always wonder what to do in such complex cases. That's probably the beauty of the plugins structure. I really want to first publish the #72 / #67 (v6 release) and then consider what to do with these cases. For now you can literally make another plugin like the following export default () => (node, result) => {
result.destructuredArgs = result.destructuredArgs || [];
node.params.forEach((param) => {
if (
param.type === 'ObjectPattern' &&
param.properties &&
param.properties.length > 0
) {
param.properties.forEach((prop) => {
const { name } = prop.value;
result.destructuredArgs.push(name);
});
}
})
return result
} and if you want them all to be in |
I update the tests, you just need to update the snapshots with Jest's |
Actually, why not create a new file in import body from './body';
import props from './props';
import params from './params';
+ import destructured from './destructured-args'; and later result = props(app)(node, result);
result = params(app)(node, result);
result = body(app)(node, result);
+ result = destructured(app)(node, result); But in anyway, a new published version probably won't be that soon that you may need it, so just use the above snippet. |
Thank you!! |
@tunnckoCore HI! |
oh) I found the bug on my code )
I will fix this asap) |
I found the decide) |
Just get your code from here and pass it to https://github.com/tunnckoCore/opensource/tree/master/@packages/parse-function#use
|
Added parse arguments of function like:
Which return result.args =
['x', 'y']
@tunnckoCore Can you help me with tests?