Migration Codemods
Pinia Colada ships ast-grep codemods to automate breaking-change migrations. Always commit your changes before running a codemod so you can review the diff.
Running codemods
With pnpm dlx (no global install):
pnpm --package=@ast-grep/cli dlx ast-grep scan -r node_modules/@pinia/colada/codemods/rules/<rule-file>.yaml -i srcOr install ast-grep globally and run:
ast-grep scan -r node_modules/@pinia/colada/codemods/rules/<rule-file>.yaml -i srcReplace src with the directory that contains your source files and <rule-file> with the migration file name listed below.
0.13 → 0.14
File: migration-0-13-to-0-14.yaml
Global query options passed to the PiniaColada plugin have been moved under a queryOptions key. Calls without any options now require an empty object.
Before:
app.use(PiniaColada, {
staleTime: 10_000,
refetchOnWindowFocus: true,
plugins: [/* ... */],
})
app.use(PiniaColada)After:
app.use(PiniaColada, {
queryOptions: {
staleTime: 10_000,
refetchOnWindowFocus: true,
},
plugins: [/* ... */],
})
app.use(PiniaColada, {})Run the codemod:
ast-grep scan -r node_modules/@pinia/colada/codemods/rules/migration-0-13-to-0-14.yaml -i src0.21 → 1.0
File: migration-0-21-to-1-0.yaml
The two-parameter form of useQuery and useQueryState is deprecated in favor of a single function parameter.
Before:
useQuery(useContactList, () => ({ search: search.value }))
useQueryState(useContactList, () => ({ search: search.value }))After:
useQuery(() => useContactList({ search: search.value }))
useQueryState(() => useContactList({ search: search.value }).key)Run the codemod:
ast-grep scan -r node_modules/@pinia/colada/codemods/rules/migration-0-21-to-1-0.yaml -i src