Skip to content

Commit

Permalink
Use the Windows-friendly import resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Jun 30, 2024
1 parent 3aca262 commit 54da68e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
2 changes: 1 addition & 1 deletion packages/steiger-plugin-fsd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
],
"dependencies": {
"@feature-sliced/filesystem": "^2.2.4",
"@feature-sliced/filesystem": "^2.2.5",
"lodash-es": "^4.17.21",
"pluralize": "^8.0.0",
"precinct": "^12.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, it, vi } from 'vitest'
import { join } from 'node:path'

import { parseIntoFsdRoot } from '../_lib/prepare-test.js'
import forbiddenImports from './index.js'
Expand Down Expand Up @@ -81,7 +82,7 @@ it('reports errors on a project with cross-imports in entities', async () => {

expect((await forbiddenImports.check(root)).diagnostics).toEqual([
{
message: 'Forbidden cross-import on layer "entities" from "product/ui/ProductCard.tsx" to slice "user".',
message: `Forbidden cross-import on layer "entities" from "${join('product', 'ui', 'ProductCard.tsx')}" to slice "user".`,
},
])
})
Expand Down Expand Up @@ -110,7 +111,7 @@ it('reports errors on a project where a feature imports from a page', async () =

expect((await forbiddenImports.check(root)).diagnostics).toEqual([
{
message: 'Forbidden import from "features/comments/ui/CommentCard.tsx" to higher layer "pages".',
message: `Forbidden import from "${join('features', 'comments', 'ui', 'CommentCard.tsx')}" to higher layer "pages".`,
},
])
})
7 changes: 4 additions & 3 deletions packages/steiger-plugin-fsd/src/import-locality/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { join } from 'node:path'
import { expect, it, vi } from 'vitest'

import { parseIntoFsdRoot } from '../_lib/prepare-test.js'
Expand Down Expand Up @@ -79,7 +80,7 @@ it('reports errors on a project with absolute imports within a slice', async ()

expect((await importLocality.check(root)).diagnostics).toEqual([
{
message: 'Import on "entities/user" from "ui/UserAvatar.tsx" to "ui/Name.tsx" should be relative.',
message: `Import on "${join('entities', 'user')}" from "${join('ui', 'UserAvatar.tsx')}" to "${join('ui', 'Name.tsx')}" should be relative.`,
},
])
})
Expand Down Expand Up @@ -108,7 +109,7 @@ it('reports errors on a project with absolute imports from the index within a sl

expect((await importLocality.check(root)).diagnostics).toEqual([
{
message: 'Import on "entities/user" from "ui/Status.tsx" to "index.ts" should be relative.',
message: `Import on "${join('entities', 'user')}" from "${join('ui', 'Status.tsx')}" to "index.ts" should be relative.`,
},
])
})
Expand Down Expand Up @@ -141,7 +142,7 @@ it('reports errors on a project with relative imports between slices', async ()

expect((await importLocality.check(root)).diagnostics).toEqual([
{
message: 'Import from "features/comments/ui/CommentCard.tsx" to "entities/user/index.ts should not be relative.',
message: `Import from "${join('features', 'comments', 'ui', 'CommentCard.tsx')}" to "${join('entities', 'user', 'index.ts')} should not be relative.`,
},
])
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, it, vi } from 'vitest'
import { join } from 'node:path'

import { parseIntoFsdRoot } from '../_lib/prepare-test.js'
import noPublicApiSidestep from './index.js'
Expand Down Expand Up @@ -86,8 +87,7 @@ it('reports errors on a project with a public API sidestep on entities', async (

expect((await noPublicApiSidestep.check(root)).diagnostics).toEqual([
{
message:
'Forbidden sidestep of public API when importing "entities/product/ui/ProductCard.tsx" from "pages/editor/ui/Editor.tsx".',
message: `Forbidden sidestep of public API when importing "${join('entities', 'product', 'ui', 'ProductCard.tsx')}" from "${join('pages', 'editor', 'ui', 'Editor.tsx')}".`,
},
])
})
Expand All @@ -110,8 +110,7 @@ it('reports errors on a project with a public API sidestep on shared', async ()

expect((await noPublicApiSidestep.check(root)).diagnostics).toEqual([
{
message:
'Forbidden sidestep of public API when importing "shared/ui/Button.tsx" from "pages/editor/ui/SubmitButton.tsx".',
message: `Forbidden sidestep of public API when importing "${join('shared', 'ui', 'Button.tsx')}" from "${join('pages', 'editor', 'ui', 'SubmitButton.tsx')}".`,
},
])
})
2 changes: 1 addition & 1 deletion packages/steiger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"README.md"
],
"dependencies": {
"@feature-sliced/filesystem": "^2.2.4",
"@feature-sliced/filesystem": "^2.2.5",
"@feature-sliced/steiger-plugin": "workspace:*",
"chokidar": "^3.6.0",
"cosmiconfig": "^9.0.0",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 54da68e

Please sign in to comment.