-
Notifications
You must be signed in to change notification settings - Fork 488
Open
Description
When update BlockStatement body, template literals within the code are reformatted with unexpeted indentations.
Steps to Reproduce:
Transformer Code (transform.js):
module.exports = function (fileInfo, api, options) {
const j = api.jscodeshift;
const root = j(fileInfo.source);
root.find(j.BlockStatement).forEach((path) => {
path.node.body = [
...path.node.body,
// simply mutate the body by adding a empty statement
j.emptyStatement(),
];
});
return root.toSource();
};Source File (test.js):
Create a test file by
echo -e "{\`\n\`}" > test.jsthen the content should be
{`
`}Run the transformer
npx jscodeshift -t transform.js test.js
Expected Result:
if it's supposed to format the code then it should be
{
`
`
}Actual Result:
{
`
`
}where the indentation is unexpectedly added after the line break in template literal
Version
Metadata
Metadata
Assignees
Labels
No labels