facebook / jscodeshift

A JavaScript codemod toolkit.
https://jscodeshift.com
MIT License
9.23k stars 477 forks source link

insertAfter adds empty line before #185

Open ghost opened 7 years ago

ghost commented 7 years ago

insertAfter adds new line before inserted ast.

I created second import by jscodeshift so in js it looks like

//Core
import React, { Component, PropTypes } from 'react';

import connect from 'react-redux';

But should be:

import React, { Component, PropTypes } from 'react';
import connect from 'react-redux';
fkling commented 7 years ago

Thanks for reporting this! jscodeshift doesn't do any of the printing, recast does. Please file an issue or PR there.

ghost commented 7 years ago

@fkling Thx. I've been doing it already.

alexlafroscia commented 7 years ago

For anyone else that comes across this, the accompanying recast issue can be found here:

https://github.com/benjamn/recast/issues/371

ghost commented 5 years ago

Also for anyone looking for a fix for running codemods: run this script afterwards to remove the empty lines: https://gist.github.com/jackaldridge/68b39a8e1de71384b8caaeb78ee10cda

alloy commented 5 years ago

@jackaldridge Excellent, thanks 🙌

shogunsea commented 4 years ago

https://github.com/facebook/jscodeshift/issues/185#issuecomment-497482753 Works like a charm

yungsters commented 3 years ago

benjamn/recast#371 has been closed without a resolution for 2 years. It isn't clear to me that there is an actionable next step for jscodeshift here, so we should probably close this issue.