* chore(codemod): add named examples to the `keep-previous-data` codemod, because these were missing
* chore(codemod): remove the unnecessary `return` statement
* feat(codemod): cover the `setQueryDefaults` method usages on the `QueryClient` instance with the codemod
For further details see: https://github.com/TanStack/query/pull/6196#discussion_r1377371519
* chore(codemod): rename the `isKeepPreviousDataInUse` to `shouldAddKeepPreviousDataImport`
The new name describes better the purpose of this variable.
* feat(codemod): cover the `QueryClient` class instantiations with the codemod
For further details see: https://github.com/TanStack/query/pull/6196#discussion_r1377371519
* chore(codemod): fix `eslint` issues within the `keep-previous-data` codemod
* chore(codemod): fix the `prettier` issues within the `keep-previous-data` codemod README file
* chore(codemod): turn off the `sort-imports` ESLint rule in case of the codemods
Since the codemods might not respect the import order, it's easier to turn off the `sort-imports` ESLint rule.
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
It's necessary, because before this change the above-mentioned function was looking for imports from the `react-query` package, but the package was renamed in the version 4 release. In case of the older codemods the `react-query` is still a valid package name, but for the current and future codemods we have to locate imports from the `@tanstack/react-query` package.
- I noticed this while I was trying to use useQuery and trying to capture the error property.
I think this is something which can be added as extra information for those who will be using it for first time.
* Simplify load method, fix syntax highlighting
SvelteKit now automatically infers the type of an exported load method, so no need to manually define it.
Also, Github has an ongoing issue with the Svelte syntax highlighting so using `html` is a good fallback.
* Change back to using svelte for code blocks
---------
Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
* feat(codemod): add initial implementation of the `placeholderData` codemod
* chore(codemod): remove the parameter from the `placeholderData` function examples
It was a request by @TkDodo, since in `v4` the `placeholderData` function didn't have a parameter.
For further details see: https://github.com/TanStack/query/pull/6196#discussion_r1366618334
* chore(codemod): add an example where the `placeholderData` property is not a function
It was a request by @TkDodo, see: https://github.com/TanStack/query/pull/6196#discussion_r1366618334
* refactor(codemod): transform the usage only when the `keepPreviousData` has value `true`
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
To ensure comprehensive documentation, I have included the import declaration to ensure that everyone is aware that the import is necessary for the module augmentation to function properly.
If you omit the import, you will overwrite the entire react-query declaration.
* fix(query-core): ensureQueryData call fetchQuery when the query actually does not exist
* fix: all the returned data covered by the test case to be falsy values
---------
Co-authored-by: goo <goo@tossbank.com>
* fix(codemod): remove the function overloads when the second argument is a function expression
After a quick sync with @TkDodo, it turned out in this case it's safe to do the transformation, because the second argument is a function expression, so it means the first parameter must be the query key.
* fix(codemod): add the `useQuery` hook to the transformation list, because it was missing
* chore(codemod): rename the `parameters` constant to `functionArguments`
The naming was wrong from the beginning. The codemod does transformations with the arguments of the functions, not with their parameters. :)
* chore(codemod): fix the import order
The CI was failing because of it.
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>