-
Notifications
You must be signed in to change notification settings - Fork 924
Option to create groups for std, external crates, and other imports #4445
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
38056e4
Add config option.
MattX 5ac3b72
Add test case for opinionated reordering
MattX d0fe771
Opinionated reordering
MattX ce79ded
Update Documentation.md examples
MattX a469976
Rename tests
MattX eba49fe
Removed temp test
MattX 16fd87b
Rename reorder_imports_opinionated -> group_imports
MattX 4f39fc4
Add extra tests
MattX 93b7cc3
Decouple reordering and grouping
MattX ec219b5
Change None -> Preserve for group_imports config
MattX a0b4a3b
Move test files; change description wording.
MattX f8f55c7
Handle indented import groups
MattX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/source/configs/group_imports/StdExternalCrate-merge_imports.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
// rustfmt-merge_imports: true | ||
use chrono::Utc; | ||
use super::update::convert_publish_payload; | ||
|
||
use juniper::{FieldError, FieldResult}; | ||
use uuid::Uuid; | ||
use alloc::alloc::Layout; | ||
|
||
use std::sync::Arc; | ||
use alloc::vec::Vec; | ||
|
||
use broker::database::PooledConnection; | ||
|
||
use super::schema::{Context, Payload}; | ||
use core::f32; | ||
use crate::models::Event; |
6 changes: 6 additions & 0 deletions
6
tests/source/configs/group_imports/StdExternalCrate-nested.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
mod test { | ||
use crate::foo::bar; | ||
use std::path; | ||
use crate::foo::bar2; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/source/configs/group_imports/StdExternalCrate-no_reorder.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
// rustfmt-reorder_imports: false | ||
|
||
use chrono::Utc; | ||
use super::update::convert_publish_payload; | ||
|
||
use juniper::{FieldError, FieldResult}; | ||
use uuid::Uuid; | ||
use alloc::alloc::Layout; | ||
|
||
use std::sync::Arc; | ||
|
||
use broker::database::PooledConnection; | ||
|
||
use super::schema::{Context, Payload}; | ||
use core::f32; | ||
use crate::models::Event; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
use chrono::Utc; | ||
use super::update::convert_publish_payload; | ||
|
||
use juniper::{FieldError, FieldResult}; | ||
use uuid::Uuid; | ||
use alloc::alloc::Layout; | ||
|
||
use std::sync::Arc; | ||
|
||
use broker::database::PooledConnection; | ||
|
||
use super::schema::{Context, Payload}; | ||
use core::f32; | ||
use crate::models::Event; |
16 changes: 16 additions & 0 deletions
16
tests/target/configs/group_imports/StdExternalCrate-merge_imports.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
// rustfmt-merge_imports: true | ||
use alloc::{alloc::Layout, vec::Vec}; | ||
use core::f32; | ||
use std::sync::Arc; | ||
|
||
use broker::database::PooledConnection; | ||
use chrono::Utc; | ||
use juniper::{FieldError, FieldResult}; | ||
use uuid::Uuid; | ||
|
||
use super::{ | ||
schema::{Context, Payload}, | ||
update::convert_publish_payload, | ||
}; | ||
use crate::models::Event; |
7 changes: 7 additions & 0 deletions
7
tests/target/configs/group_imports/StdExternalCrate-nested.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
mod test { | ||
use std::path; | ||
|
||
use crate::foo::bar; | ||
use crate::foo::bar2; | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/target/configs/group_imports/StdExternalCrate-no_reorder.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
// rustfmt-reorder_imports: false | ||
|
||
use alloc::alloc::Layout; | ||
use std::sync::Arc; | ||
use core::f32; | ||
|
||
use chrono::Utc; | ||
use juniper::{FieldError, FieldResult}; | ||
use uuid::Uuid; | ||
use broker::database::PooledConnection; | ||
|
||
use super::update::convert_publish_payload; | ||
use super::schema::{Context, Payload}; | ||
use crate::models::Event; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// rustfmt-group_imports: StdExternalCrate | ||
use alloc::alloc::Layout; | ||
use core::f32; | ||
use std::sync::Arc; | ||
|
||
use broker::database::PooledConnection; | ||
use chrono::Utc; | ||
use juniper::{FieldError, FieldResult}; | ||
use uuid::Uuid; | ||
|
||
use super::schema::{Context, Payload}; | ||
use super::update::convert_publish_payload; | ||
use crate::models::Event; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll confess this gave me pause at first glance, but see why we had to wrap the sorting behind the
reorder_imports
check here now since we can get here even ifreorder_imports
false with non-Preservation group import strategies.