Create Dependency Injection Container #84
Merged
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 a custom dependency injection (DI) system to the codebase, refactors the formatter rules to leverage this DI container, and adds a custom Vite plugin to transform generic method calls for compatibility with compiled JavaScript. It also updates the build process to use Vite, reorganizes exports, and makes related adjustments to configuration and scripts.
Dependency Injection System and Refactoring:
Container) and service registration system (ServiceRegistration) insrc/core/di, enabling automatic dependency resolution and singleton management for services and formatting rules. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-e0cfb749b35f472cec2b3e7ce0252ebe46144799fac73e1d86930cbe054d69e3R1-R241),[[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-9b6ac34670c12d84be455a42fdc64b8eb91d448463aea6879f8221bfd21cb26fR1-R36),[[3]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-72d6a009a92f58436c78302c67159017ba656e77dda2cf1979413ebd40ea05d3R1-R5))BaseFormattingRule, providing container access and configuration helpers for all rules. Updated rules (e.g.,ClassMemberSortingRule) to extend this base class and use injected configuration. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-6fcfbe86570f4173d3d506bdda506e7df7cbd3b54712464bfc3a5b06e0d1a0b0R1-R62),[[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-9f780b370206c13aece8cbd9d75b710e2693bbb0db0917530beb7e5d7c422febR4),[[3]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-891d7486bdf3d932b174ff7c39cd1893aeb245c9c0baebb15a03c193321729dbL9-R9),[[4]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-891d7486bdf3d932b174ff7c39cd1893aeb245c9c0baebb15a03c193321729dbL56-L61),[[5]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-891d7486bdf3d932b174ff7c39cd1893aeb245c9c0baebb15a03c193321729dbL138-R135))src/cli.ts) to use the DI container for resolving the formatter pipeline and registering services, instead of direct instantiation. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-fa8d4e24d8399e8350f1c8bad05df53e8032ea995835bf911507015e2db61cddR4-R16),[[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-fa8d4e24d8399e8350f1c8bad05df53e8032ea995835bf911507015e2db61cddL31-R37))Build Process and Plugin Enhancements:
transformGenericsPlugin) insrc/build-pluginsto transform genericaddRulecalls into explicit string-based calls, ensuring correct operation after TypeScript generics are stripped in compiled JS. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-08dea0082f21f16e583b1158de6026d2325d7d8583ba653372591da4818a944aR1-R120),[[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-a47d06b8354caaf1b1b96d3ad3faddda32e1155f2b0511d4c18cc09384e54e82R1-R5))package.jsonto output todist/, and adjusted the CLI and binary paths accordingly. ([[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R16-R35),[[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L41-R44))Export Organization:
[[1]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-72d6a009a92f58436c78302c67159017ba656e77dda2cf1979413ebd40ea05d3R1-R5),[[2]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-9f780b370206c13aece8cbd9d75b710e2693bbb0db0917530beb7e5d7c422febR4),[[3]](https://github.com/EncoreDigitalGroup/tsfmt/pull/84/files#diff-a47d06b8354caaf1b1b96d3ad3faddda32e1155f2b0511d4c18cc09384e54e82R1-R5))These changes collectively modernize the codebase, improve extensibility and maintainability, and ensure compatibility with modern build tooling and dependency management.