Merged
Conversation
Implements comprehensive ESLint plugin that provides rich VS Code context information about how TDI2 interfaces resolve to implementations. **di-core changes:** - Add ESLintMetadataGenerator class to generate metadata for ESLint - Create metadata types for interface resolution context - Hook metadata generation into SharedServiceRegistry - Generate `.tdi2/eslint-metadata.json` during DI config generation **ESLint plugin features:** - show-interface-resolution: Display context at Inject<> usage points * Shows selected implementation with selection reason * Lists all alternative implementations * Displays dependencies, scope, and profiles * Warns about ambiguous resolutions * Detects profile mismatches - show-implementation-context: Display context at @service() declarations * Shows implemented interfaces * Displays usage statistics * Lists alternative implementations * Indicates primary status - show-interface-implementations: Display all implementations at interface declarations * Lists all registered implementations * Shows selection status and reason * Displays usage stats per implementation * Warns about ambiguity **Architecture:** - Metadata-driven approach (no AST parsing in ESLint) - Generated JSON file consumed by ESLint rules - Supports multiple implementations per interface - Bi-directional navigation (interface ↔ implementations) - 5-second metadata cache for performance **Benefits:** - Instant feedback on interface resolution in IDE - No need to dig through generated configs - Early detection of ambiguous resolutions - Clear visibility into DI dependency graph - Helpful warnings when config missing/stale Closes #XX
Adds comprehensive test suite for the TDI2 ESLint plugin using Vitest. **Test coverage:** - Metadata structure validation (19 tests) * Validates generated metadata format * Tests interface resolution data * Tests implementation tracking * Tests component injection data * Tests lookup maps * Tests issue detection - Plugin integration tests (13 tests) * Validates rule exports * Tests recommended and strict configs * Validates rule metadata and schemas **Test infrastructure:** - package.json with vitest dependencies - vitest.config.js for test configuration - Mock metadata fixtures for testing - 32 tests total, all passing **Architecture:** - Tests focus on critical functionality - Uses mock data to avoid file system complexity - Simple, maintainable test structure - Fast execution (~2 seconds for full suite) All tests passing ✅
Moves eslint-plugin-tdi2 from apps/legacy to packages folder as a proper monorepo package with full build infrastructure. **Changes:** - Move eslint-plugin-tdi2 from apps/legacy to packages/ - Rename package to @tdi2/eslint-plugin-tdi2 (scoped) - Add tsup build configuration for ESM + CJS output - Add TypeScript configuration - Update package.json with proper exports and build scripts - Add dist/ output with both ESM and CJS builds **Build outputs:** - dist/index.js - ESM module - dist/index.cjs - CommonJS module - dist/index.d.ts - TypeScript types - Source maps for debugging **Package structure:** ``` packages/eslint-plugin-tdi2/ ├── index.js # Main plugin entry ├── rules/ # ESLint rules ├── utils/ # Utilities (metadata loader) ├── __tests__/ # Test suite ├── package.json # Scoped package config ├── tsup.config.ts # Build configuration └── tsconfig.json # TypeScript config ``` **Verification:** - ✅ Build succeeds with tsup - ✅ Both ESM and CJS outputs generated - ✅ All 32 tests passing - ✅ Package properly scoped as @tdi2/eslint-plugin-tdi2 The plugin is now a first-class monorepo package with proper build tooling consistent with other packages.
Convert all JavaScript files to TypeScript with proper type annotations: - Moved all source files to src/ directory - Added comprehensive type definitions in src/types.ts - Converted all ESLint rules with Rule.RuleModule typing - Converted test files with proper type assertions - Updated build configuration for TypeScript compilation Changes: - src/index.ts: Main plugin entry with ESLint.Plugin types - src/types.ts: Complete type definitions for metadata structures - src/utils/metadata-loader.ts: Fully typed metadata loader - src/rules/*.ts: All rules with proper ESLint types - __tests__/*.ts: Test files with type safety - tsconfig.json: Strict TypeScript configuration - tsup.config.ts: Build from src/index.ts All 32 tests passing. Build successful with ESM + CJS outputs.
…ce-resolution-context-01KCTxABvmz6mphfwY7nhfyT
Replace stub ESLint plugin in legacy app and add plugin to example app: **Legacy App Changes:** - Added @tdi2/eslint-plugin-tdi2 dependency - Replaced local stub plugin with published package - Updated eslint.config.js with interface resolution rules - Removed old eslint-tdi2-plugin.js stub file - Configured 3 new rules: - tdi2/show-interface-resolution: Show Inject<> resolution - tdi2/show-implementation-context: Show @service() context - tdi2/show-interface-implementations: Show all implementations **Example App Changes:** - Added @tdi2/eslint-plugin-tdi2 dependency - Created eslint.config.js with TDI2 rules - Updated dependencies to modern ESLint 9.x flat config - Added proper React and TypeScript ESLint plugins The plugin provides VS Code context information about: - How Inject<Interface> markers resolve to implementations - Multiple implementations per interface (with @primary, @Profile) - Bi-directional navigation between interfaces and implementations - Selection logic explanations Requires metadata generation via vite-plugin-di to function.
Add getProjectRoot() and getScanDirs() methods to ConfigManager to fix TypeScript compilation errors in ESLintMetadataGenerator. These methods are required by the ESLint metadata generator to: - Normalize file paths relative to project root - Access scan directories for metadata generation Methods added: - getProjectRoot(): Returns process.cwd() as project root - getScanDirs(): Returns this.options.scanDirs array Fixes TypeScript errors at lines 290, 341, 342, 467 in eslint-metadata-generator.ts
…erfaces The show-interface-implementations rule was incorrectly reporting warnings for ALL interface declarations, including regular React component props like DICardBodyProps, RouterProps, etc. Fixed by making the rule silent for interfaces that aren't in the DI metadata. The rule now ONLY provides context information for interfaces that are actually used with Inject<> in the dependency injection system. Changes: - Return early (silent) when interface not found in metadata - Remove unused 'interfaceNoImplementations' message - Keep rule focused on DI interfaces only Before: Showed '❌ No implementations found' for ALL interfaces After: Silent for non-DI interfaces, shows info only for DI interfaces All 32 tests still passing.
Added a new ESLint rule to show DI context when components are missing
the 'services' prop, providing additional information alongside TypeScript
errors.
**New Rule: show-missing-services-context**
- Detects when DI components are used without services prop
- Shows what services would be auto-injected by TDI2
- Displays resolved implementations and file paths
- Tells users they can safely ignore the TypeScript error
**Example Output:**
```
💡 DI Context: This component expects services
🔧 Auto-injected by TDI2:
• i18n: AppLangInterface
└─ Resolves to: AppLangService
└─ 📍 src/services/AppLangService.ts
✅ The services prop is handled by the DI transformer
You can safely ignore the TypeScript error above.
```
**Changes:**
- Added src/rules/show-missing-services-context.ts
- Updated plugin index to export new rule
- Added to recommended and strict configs
- Updated ESLint configs in legacy and example apps
- Added comprehensive tests (34 tests passing)
**Addresses User Feedback:**
1. ✅ File links already clickable (path:line format)
2. ✅ Inject<T> resolution already working
3. ✅ NEW: Enhanced missing services error with DI context
- Added hasSuggestions: true to all three rules - show-interface-implementations: Navigate to implementation classes - show-implementation-context: Navigate to interface definitions - show-missing-services-context: Navigate to resolved service implementations - Suggestions appear as clickable quick fixes in VS Code (Ctrl+.) - All 34 tests passing
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.
No description provided.