Skip to content

Commit

Permalink
Stop demanding public API from the App layer
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Jun 13, 2024
1 parent ab43b01 commit ded8bd3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/steiger-plugin-fsd/src/public-api/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `public-api`

Require slices (and segments on sliceless layers like Shared) to have a public API definition.
Require slices (and segments on Shared) to have a public API definition.

According to the _public API rule on slices_:

Expand Down
28 changes: 28 additions & 0 deletions packages/steiger-plugin-fsd/src/public-api/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,31 @@ it('reports errors on segments that are missing a public API', () => {
},
])
})

it('reports no errors when the App layer is missing a public API', () => {
const root = parseIntoFsdRoot(`
📂 shared
📂 ui
📄 index.ts
📂 entities
📂 users
📂 ui
📄 index.ts
📂 posts
📂 ui
📄 index.ts
📂 features
📂 comments
📂 ui
📄 index.ts
📂 pages
📂 editor
📂 ui
📄 index.ts
📂 app
📂 providers
📂 styles
`)

expect(publicApi.check(root, { sourceFileExtension: 'ts' })).toEqual({ diagnostics: [] })
})
4 changes: 4 additions & 0 deletions packages/steiger-plugin-fsd/src/public-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const publicApi = {

for (const [layerName, layer] of Object.entries(getLayers(root))) {
if (!isSliced(layer)) {
if (layerName === 'app') {
// The app layer is the top-level layer, there's no need for public API.
continue
}
for (const [segmentName, segment] of Object.entries(getSegments(layer))) {
if (getIndex(segment) === undefined) {
diagnostics.push({
Expand Down
2 changes: 1 addition & 1 deletion packages/steiger/steiger.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
rules: {
'public-api': 'off',
// 'public-api': 'off',
},
}

0 comments on commit ded8bd3

Please sign in to comment.