question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Organize imports should remove blank lines within imports

See original GitHub issue

TypeScript Version: 2.9.0-dev.20190327

Search Terms:

  • Organize imports

Code

  1. For the js:
import { x } from 'x';


import { y } from 'y';

console.log(x, y)
  1. Run organize imports.

Expected behavior: Blank lines within the import are removed

import { x } from 'x';
import { y } from 'y';

console.log(x, y)

Actual behavior: Blanklines preserved but shifted to end of imports:

import { x } from 'x';
import { y } from 'y';



console.log(x, y)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
marcelh-ghcommented, May 6, 2018

I agree that the current behavior of moving blank lines to the end of the imports is not helpful. But removing them in general is also not always desired. I like to group my imports using blank lines. For example one block of imports could be related to DB stuff and another one to features from math libraries.

Maybe the removal of blank lines could be optional via a config flag?

3reactions
PeterStaevcommented, Jan 7, 2020

+1 to have a flag to allow keeping spaces/groups.

Read more comments on GitHub >

github_iconTop Results From Across the Web

source.organizeImports must not remove empty line between ...
Usually imports are organized in groups separated by empty line (e.g. node packages, services, components). I think that organizeImports should respect ...
Read more >
How to stop Eclipse from inserting blank line between import ...
Make sure the Remove excess blank lines button right of the Between import groups selector is pressed.
Read more >
Imports - checkstyle
imports will be sorted in the groups; groups are separated by single blank line. Notes: "com" package is not mentioned on configuration, because ......
Read more >
scalafix-organize-imports - Scaladex
To make it easier to add OrganizeImports into existing Scala projects built using ... A blank line is automatically inserted between adjacent import...
Read more >
Eclipse Platform » Supressing blank line between import groups
Look in Windows > Preferences > Java > Code Style > Organize Imports HTH, Vijay Steven Caswell wrote: > I've looked everywhere I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found