Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export class SWRVisitor extends ClientSideBaseVisitor<
this._additionalImports.push(
`import type { SWRInfiniteConfiguration } from 'swr/infinite';`
)
this._additionalImports.push(`import useSWR from 'swr';`)
this._additionalImports.push(
`import useSWR, { useSWRInfinite } from 'swr';`
`import useSWRInfinite from 'swr/infinite';`
)
} else {
this._additionalImports.push(
Expand All @@ -135,10 +136,10 @@ export class SWRVisitor extends ClientSideBaseVisitor<
}
} else if (this._enabledInfinite) {
this._additionalImports.push(
`import useSWR, { useSWRInfinite, SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
`import useSWR, { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
)
this._additionalImports.push(
`import { SWRInfiniteConfiguration } from 'swr/infinite';`
`import useSWRInfinite, { SWRInfiniteConfiguration } from 'swr/infinite';`
)
} else {
this._additionalImports.push(
Expand Down
4 changes: 2 additions & 2 deletions tests/swr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ async function test() {
const usage = basicUsage
const output = await validate(content, config, docs, schema, usage)
expect(content.prepend).toContain(
`import useSWR, { useSWRInfinite, SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
`import useSWR, { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
)
expect(content.prepend).toContain(
`import { SWRInfiniteConfiguration } from 'swr/infinite';`
`import useSWRInfinite, { SWRInfiniteConfiguration } from 'swr/infinite';`
)
expect(output).toContain(readOutput('infinite'))
})
Expand Down