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.js
then 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
jscodeshift@17.3.0
When update
BlockStatementbody, template literals within the code are reformatted with unexpeted indentations.Steps to Reproduce:
Transformer Code (transform.js):
Source File (test.js):
Create a test file by
then the content should be
Run the transformer
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
jscodeshift@17.3.0