RFC: Multi-dimensional Element Classification with Categories #369
javierbrea
started this conversation in
RFCs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Status
✅ Accepted - Implementation in progress
Summary
This RFC proposes adding an optional
categoryfield to element definitions ineslint-plugin-boundaries. This enhancement would enable multi-dimensional architectural classification while maintaining full backward compatibility with existing configurations.Key Changes
categoryfield: Elements can declare a semantic category dimensioncategory,type, or bothcapturefeature continues working as beforeMotivation
Current Limitation: One Type Per File
Currently, when a file matches multiple element patterns, only the first matching type is assigned. This creates a limitation for projects with multiple architectural dimensions.
Example scenario (from #348):
This file is:
With the current system, you must choose which dimension to enforce. The file will either be recognized as
type: "service"ORtype: "user-domain", but not both simultaneously.Why Categories Over Tags?
Initially, I considered a flat tags system (similar to other tools), but categories offer significant advantages:
1. Backward Compatibility
Adding an optional
categoryfield is non-breaking:2. Semantic Hierarchy
Categories provide explicit architectural intent:
Compare to a flat tags system:
With categories:
3. Multi-dimensional Visualization
I'm planning to create a visualization package that generates dependency graphs from the boundaries detected by this plugin. Categories would enable powerful visualization capabilities that are currently impossible:
This would enable viewing the same codebase from different architectural perspectives without changing the configuration—simply by switching which category to visualize.
Detailed Design
1. Multiple Type Assignment (Opt-in)
New behavior: To avoid breaking changes, multiple type assignment will be opt-in via a new setting.
2. Enhanced Element Definition
Element definitions now support an optional
categoryfield:3. Enhanced Rules Syntax
Rules can now match elements by
category,type, or both:4. Capture Remains Powerful and Complementary
Important: The
capturefeature is unchanged and complementary to categories.Key Difference: Dynamic vs Semantic
capture: Extracts dynamic values from file paths for flexible pattern matchingcategory: Declares semantic intent for architectural classificationWhen to use what:
categoryfor: Grouping elements by architectural concern, visualization, high-level boundariescapturefor: Dynamic path-based rules, extracting specific values, fine-grained matching5. Complete Configuration Example
Migration Path
This proposal is designed to be fully backward compatible:
Phase 1: v6.0 - Soft Launch
categoryas an optional fieldboundaries/multi-typessetting (default:falsefor backward compatibility)Phase 2: Adoption Period (v6.x)
Phase 3: v7.0 - Default Multi-types
boundaries/multi-typesdefault totruefalseif neededcategoryremains optional for maximum flexibilityPhase 4: Future (v7.x+)
Examples
Example 1: Atomic Design + Domain-Driven Design
Example 2: With Capture for Fine-grained Rules
Example 3: Backward Compatible (no changes required)
Open Questions for Community
I'd love to hear your thoughts on:
boundaries/multi-typessetting make sense? Is the migration path reasonable?Related Issues
Next Steps
Thank you for taking the time to review this proposal! Your feedback is invaluable in shaping the future of
eslint-plugin-boundaries. Please share your thoughts, concerns, and use cases below. 🙏Beta Was this translation helpful? Give feedback.
All reactions