-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Option to create groups for std, external crates, and other imports (#…
…4445) * Add config option. It might actually be better to have a three-way option. * Add test case for opinionated reordering * Opinionated reordering * Update Documentation.md examples * Rename tests * Removed temp test * Rename reorder_imports_opinionated -> group_imports * Add extra tests Tests for interaction with `no_reorder` and `merge_imports`. * Decouple reordering and grouping * Change None -> Preserve for group_imports config Also reword configuration to be less specific. * Move test files; change description wording. * Handle indented import groups
- Loading branch information
Showing
12 changed files
with
254 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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; |