[Feature Idea] Default to wildcard if too many merged imports
See original GitHub issueIf I have a number of qualified imports sharing a package name, such as below:
import cats.data.AndThen
import cats.data.Binested
import cats.data.BinestedBitraverse
import cats.data.Kleisli
import cats.data.Reader
import cats.data.OptionT
import cats.data.State
import cats.data.StateT
The optimizer under the Merge configuration (rightly) groups them all together:
import cats.data.{AndThen, Binested, BinestedBitraverse, Kleisli, OptionT, Reader, State, StateT}
However at some point the number of things imported from the same package can be so large that the merge grouping will go over the column limit. Of course, Scalafmt can catch this and turn it into this:
import cats.data.{
AndThen,
Binested,
BinestedBitraverse,
Kleisli,
Reader,
OptionT,
State,
StateT
}
But why not have an option to simplify to a wildcard like below? It’s much cleaner, albeit less precise w.r.t scope.
import cats.data._
So the feature idea I’m proposing is to add a configuration to the groupedImports
rule such as SmartMerge
which will default to a wildcard if the merged group goes over the standard column limit (100 chars?).
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
IntelliJ: Never use wildcard imports - Stack Overflow
Update: in IDEA 13 "Use single class import" does not prevent wildcard imports. The solution is to go to Preferences ( ⌘ +...
Read more >Auto import | IntelliJ IDEA Documentation - JetBrains
Disable wildcard imports. When the number of classes that IntelliJ IDEA has imported from the same package reaches the limit ( ...
Read more >Wildcard imports · Issue #48 · pinterest/ktlint - GitHub
My primary argument is that intellij does add wildcard imports in the default configuration, and I think I should not have to configure ......
Read more >How to disable wildcard imports in IntelliJ IDEA - Marc Nuri
IntelliJ IDEA uses wildcard imports ( import java. util. *; ) whenever the number of classes imported from the same package reaches the...
Read more >Why you should disable wildcard imports in IntelliJ IDEA
The default behavior of IntelliJ IDEA is to replace multiple class imports from a package with an asterisk. At my team, we decided...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
BTW, the reason why the
groupedImports
option defaults toExplode
is that having each import selector on their own line as a fully-qualified import is friendlier to version control and text searching. I personally prefer not grouping them together. It also avoids exceeding the column limit.Awesome, thanks for the update @liancheng! Gonna take it for a spin in one of my repos.