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. |
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