Skip to content
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

Extra blank line after import statement with leading comment #371

Closed
ghost opened this issue Feb 21, 2017 · 5 comments
Closed

Extra blank line after import statement with leading comment #371

ghost opened this issue Feb 21, 2017 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 21, 2017

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

import connect from 'react-redux';

But should be:

//Core
import React, { Component, PropTypes } from 'react';
import connect from 'react-redux';
@DivineGod
Copy link

see #405

@benjamn
Copy link
Owner

benjamn commented Feb 24, 2018

Closing for the same reason I closed #405: #405 (comment)

There's no way to represent a group of sequential import declarations in the AST, so there's no way to attach a single comment to multiple import lines.

@benjamn benjamn closed this as completed Feb 24, 2018
@vivek12345
Copy link

For a program like this

async function getNormalData() {
  const c = await getData;
}

When I try to insert a try catch on top of the await statement and hoist the variable up like the following function:-

async function getNormalData() {
  let c;
  try {
    c = await getData;
  } catch (e) {
    console.log(e);
  }
}

Recast leaves one line after let c;
Something like this:-

async function getNormalData() {
  let c;

  try {
    c = await getData;
  } catch (e) {
    console.log(e);
  }
}

Can this be regarded as a bug and fixed?

@ImanMh
Copy link

ImanMh commented Dec 15, 2019

Finally I was able to fix my issue by adding reuseWhitespace to the printer options, This might be a hack and not work for everyone.

print(ast, {
    reuseWhitespace: false,
  });

@towry
Copy link

towry commented Jan 8, 2021

Finally I was able to fix my issue by adding reuseWhitespace to the printer options, This might be a hack and not work for everyone.

print(ast, {
    reuseWhitespace: false,
  });

This seems removed all empty lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants