✨ Feat: Update import order during commit#269
Merged
tyler-dane merged 3 commits intomainfrom Feb 22, 2025
Merged
Conversation
This was referenced Feb 22, 2025
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces changes to the project's code formatting and linting configuration. The primary focus is the integration of a new Prettier plugin for sorting imports and the reorganization of ESLint configuration to accommodate this change.
closes #271
related to #149 and #257
Usage
When you commit your changes, imports will be automatically organized for the files you staged.
To have imports organized on save, you'll have to configure you editor manually.
Here is my VSCode config, which automatically organizes imports on save:
Notice that I'm organizing imports before formatting.
Example
Given that this is the original file that you've staged for a commit:
When you run
git commit, thelint-stagedscript frompackage.jsonwill run. This will triggerprettier, which will use the import rules from.prettierrc.json. The result will be:Code formatting improvements:
.prettierrc: Added the@trivago/prettier-plugin-sort-importsplugin and defined import order rules to improve the consistency of import statements.ESLint configuration updates:
eslint.config.mjs: Reorganized import statements and added the@trivago/prettier-plugin-sort-importsplugin to the ESLint configuration. This ensures that import statements are sorted according to the new rules defined in.prettierrc. [1] [2]Dependency updates:
package.json: Added the@trivago/prettier-plugin-sort-importspackage to the project dependencies.package.json: Removed theeslint-plugin-importpackage, which is no longer needed with the new import sorting plugin.