-
Notifications
You must be signed in to change notification settings - Fork 148
feat: Import sort order skip files #360
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
Conversation
@ayusharma @byara Can i get a review on this?
@Copilot
Copilot
AI
left a comment
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.
Pull Request Overview
This PR adds support for skipping import sorting based on user-defined glob patterns, improving maintainability for generated, test, and legacy files.
- Introduces
importOrderSkipFiles
configuration for file glob patterns - Implements
shouldSkipFile
utility with corresponding tests - Integrates skip logic in the main preprocessor
- Adds new option definition in
src/index.ts
and installsminimatch
Reviewed Changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/utils/should-skip-file.ts | New utility to determine if a file matches any skip patterns |
src/utils/tests/should-skip-file.spec.ts | Comprehensive tests for the skip-file utility |
src/preprocessors/preprocessor.ts | Early return in preprocessor when a file should be skipped |
src/index.ts | Defines importOrderSkipFiles option in plugin configuration |
package.json | Adds minimatch dependency and its types |
Comments suppressed due to low confidence (2)
src/index.ts:19
- The default value for importOrderSkipFiles should be an empty array of strings (e.g.,
default: []
) instead of an array with an object wrapper. This ensures the option is initialized correctly as a string array.
default: [{ value: [] }],
src/utils/tests/should-skip-file.spec.ts:61
- Consider adding a test case that uses Windows-style path separators (e.g.,
\\
on Windows) to verify thatshouldSkipFile
correctly normalizes backslashes to forward slashes before matching.
});
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.
It's really useful . Thank you for your effort! I've left a few minor comments.
This reverts commit a7db2b5.
@vladislavarsenev The comments are addressed. Please validate
Feature: Skip Import Sorting for Specified Files
Problem
In large codebases with hundreds of thousands of files, manually adding
// sort-imports-ignore
comments to each file that should be excluded from import sorting becomes impractical and maintenance-heavy. This is particularly problematic for:Solution
This PR introduces a new configuration option
importOrderSkipFiles
that allows users to specify glob patterns for files that should be excluded from import sorting. This provides a more scalable and maintainable way to manage import sorting exclusions.New Configuration Option
Features
Implementation Details
minimatch
dependency for robust glob pattern matchingshouldSkipFile
utility with thorough test coverageTesting
The implementation includes comprehensive tests covering:
Usage Example
Breaking Changes
None. This is a purely additive feature that maintains backward compatibility.
Future Considerations
!generated/important.ts
)