Skip to content

Add OrderedImports configuration to disable grouping by import type#1133

Merged
allevato merged 3 commits intoswiftlang:mainfrom
amja:add-ordered-import-configuration
Jan 13, 2026
Merged

Add OrderedImports configuration to disable grouping by import type#1133
allevato merged 3 commits intoswiftlang:mainfrom
amja:add-ordered-import-configuration

Conversation

@amja
Copy link
Contributor

@amja amja commented Dec 23, 2025

Adds the capability to disable grouping by import type (@testable, @_implementationOnly, etc.) and only order the imports lexicographically.

This is achieved via a configuration option orderedImports.shouldGroupImportTypes.

Updated testing and documentation to reflect this new option.

Closes #1128

@amja amja changed the title Add OrderedImports configuration to disable grouping by input type Add OrderedImports configuration to disable grouping by import type Dec 23, 2025
)
}

func testInvalidOrderingWithGroupingDisabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that includes some line comments and some non-import code lines intermixed with the imports to verify that the output is as expected in that case too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this suggestion. Adding the test uncovered a couple of issues that I have also resolved!

If you have any more thoughts for edge cases I should test, please let me know :)

- Improve config naming for clarity.
- Remove special array for combined import types.
- Undo unrelated code style change.
- Add a test and fix logic issues discovered by new test.
Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you for working on it!

@allevato allevato merged commit f4f5709 into swiftlang:main Jan 13, 2026
51 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Configure sectioning of orderedImports

2 participants