-
Notifications
You must be signed in to change notification settings - Fork 491
Can I inert inline commentBlock before an argument? #688
Copy link
Copy link
Open
Description
I have:
f('foo');and I want to insert inline block comment, like this:
f(/* comment */'foo');Unfortunately, Im always getting newline between comment and argument:
// arg.comments = [ j.commentBlock(` comment `) ];
f(/* comment */
'foo');
// arg.comments = [ j.commentBlock(` comment `, true, false) ];
f(/* comment */
'foo');
// arg.comments = [ j.commentBlock(` comment `, false, true) ];
f('foo'/* comment */);Any Ideas?
Playground:
https://astexplorer.net/#/gist/efea82bb2a028629e17f70a97e43a355/9d951cc12f51086f315d6772443c603dfb020aa4
Transformer:
export default function transformer(file: FileInfo, api: API) {
const j = api.jscodeshift
const root = j(file.source);
root
.find(j.CallExpression, { callee: { type: "Identifier", name: "f" } })
.forEach((path) => {
const arg = path.node.arguments[0];
arg.comments = [ j.commentBlock(` comment `) ];
});
return root.toSource({ quote: 'single' });
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.