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.

Comment section moved between two import declarations

See original GitHub issue

Prettier-Java 0.7.0

Launched through prettier-maven-plugin 0.7.0 without any option. In the following case, the comment section is moved between two import lines. This bugs depends on import declaration order. If “com.me.Util” is declared first, the generated file is OK.

Input:

package org.mypackage;

/*-
 */

import java.lang.Util;
import java.util.Map;
import com.me.Util;

public class Prettier {}

Output:

package org.mypackage;

import com.me.Util;
/*-
 */
import java.lang.Util;
import java.util.Map;

public class Prettier {}

Expected behavior:

package org.mypackage;

/*-
 */
import java.lang.Util;
import java.util.Map;

import com.me.Util;

public class Prettier {}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jhabercommented, Mar 27, 2020

My $0.02 is that sorting imports feels within scope for prettier-java, and we really like having it

0reactions
MathieuAAcommented, Apr 1, 2020

I agree with @murdos on sorting imports. Further more, in my opinion, prettier’s goal is to standardize code across an organization by sharing a common set of rules so that code made by each contributor looks the same (or at least aims at looking the same)., and imports too are a part of a codebase (maybe not as important as the rest, but still…).

The example is a bit weird too, and may not happen very often (I may not fully understand the motivation behind putting a comment in such a place though). IMO, I wouldn’t say this issue has a “high priority”. I’m sure there must be a more important task to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component is part of the declaration of 2 modules
Here is what I did to fix sharing a directive. create a new shared module. shared.module.ts import { NgModule, Directive,OnInit ...
Read more >
Instructions For CBP Form 3299 - Declaration for Free Entry of ...
PART V - Carrier's Certificate and Release Order - If the importer has hired a moving and/or freight company to transport the imported...
Read more >
Auto import | PyCharm Documentation - JetBrains
The import statement is added to the imports section, but the caret does not move from the current position, and your current editing...
Read more >
International Trade Definitions - Census Bureau
Card Count - The number of individual export or import line items. ... company under which freight is to be moved between points...
Read more >
PEP 8 – Style Guide for Python Code
Surround top-level function and class definitions with two blank lines. ... You should put a blank line between each group of imports.
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