draft: add FSD layer aliases - #244
Conversation
🦋 Changeset detectedLatest commit: 1a3a6cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
9ec95f5 to
a455f81
Compare
|
We'll need some time to review and evaluate this change. But I got a couple of things right now: I don't really like the idea of doing aliases by patching and replacing paths for rules and diagnostics; it definitely has some edge cases in some specific edge cases. A cleaner approach would be to do it in https://github.com/feature-sliced/filesystem , so you don't have to patch diagnostics in and out and reimplement prefixed layer normalization. Another thing is config typing of export type LayerAliases = Partial<Record<LayerName, string | Array<string>>>This introduces a lot of ambiguity: does it mean that there could be 2 different folders that are treated as a single layer? Do we need to report imports between those folders as cross-import? And I don't really think that example of using |
a455f81 to
3412241
Compare
Add createFsdPlugin({ layerAliases }) so projects can map custom folder names to canonical FSD layers without forking or renaming packages. Keep default plugin export behavior unchanged and document usage in package and root READMEs.
Tests: pnpm --filter @feature-sliced/steiger-plugin typecheck; pnpm --filter @feature-sliced/steiger-plugin test; pnpm --filter @feature-sliced/steiger-plugin build
Codex: implemented config API, tests, docs, and changeset.
3412241 to
1a3a6cc
Compare
|
@Solant Thanks, agreed on all points. The path rewrite approach was too fragile. I reworked this so layer aliases are handled in I also agree that export type LayerAliases = Partial<Record<LayerName, string>> |
|
@Solant If you know better ways to pass config let me know |
|
@beautyfree this thread may be interesting for you: #53 |
|
Hey We had some discussions with the team, and I'm not alone with concerns about aliases. Basically, FSD is supposed to be a common ground for development so developers can transfer knowledge between projects. For now we allow prefixed layers (like Can you describe why you think this might be needed? From my perspective, all development can be done within the current naming convention just fine. But if there is some evidence that current naming can cause issues, I want to see what we can do in this case, because we also need to document how to properly use aliases. |
|
@Solant I think the main motivation is platform-native terminology, rather than allowing arbitrary project-specific naming. The current convention is especially natural for web applications, where
In these cases, forcing the I agree that a shared, recognizable structure is valuable, so I would not want aliases to turn into unrestricted custom naming. The intent is a constrained one-to-one mapping from a platform-native term to a canonical FSD layer - so that the tooling and the underlying architectural meaning remain the same, while the project can use terminology appropriate to its platform. Web, desktop/window-based applications, and mobile/screen-based applications are the concrete cases I have in mind so far. If there are other platform models, it would be useful to identify them before deciding whether this belongs in the standard. |
|
I still don't think But for native apps, this indeed makes sense. I think we should introduce a platform-neutral layer name on the architecture level, not as an option for a linter. |
I can understand and agree with some of the points raised by both beautyfree and Solant. I'd like to take another day or two to think through both perspectives a bit more, and then I'll organize my thoughts and get back to you. |
|
After thinking about this a bit more, I can understand the point that the So I think it could be reasonable to allow some flexibility in naming, such as using On the other hand, layers such as I also think it could be useful to mention this in the official documentation: the architectural role of |
Summary
createFsdPlugin({ layerAliases })for mapping one project-specific folder name to a canonical FSD layerLayerConventionthrough FSD rule options explicitlyscreensexamples instead of Electron/window-specific framingDepends on
@feature-sliced/filesystemreleasesLayerConventionTests
Verified locally with
@feature-sliced/filesystemlinked from filesystem PR #10:pnpm --filter @feature-sliced/steiger-plugin typecheckpnpm --filter @feature-sliced/steiger-plugin testpnpm --filter @feature-sliced/steiger-plugin build