-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codemod): improve the keep previous data codemod (#6283)
* 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: #6196 (comment) * 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: #6196 (comment) * 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>
- Loading branch information
1 parent
41e0938
commit b3c7dba
Showing
7 changed files
with
1,097 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
### Intro | ||
|
||
The prerequisite for this code mod is to migrate your usages to the new syntax, so overloads for hooks and `QueryClient` methods shouldn't be available anymore. | ||
|
||
### Affected usages | ||
|
||
Please note, this code mod transforms usages only where the first argument is an object expression. | ||
|
||
The following usage should be transformed by the code mod: | ||
|
||
```ts | ||
const { data } = useQuery({ | ||
queryKey: ['posts'], | ||
queryFn: queryFn, | ||
keepPreviousData: true, | ||
}) | ||
``` | ||
|
||
But the following usage won't be transformed by the code mod, because the first argument an identifier: | ||
|
||
```ts | ||
const hookArgument = { | ||
queryKey: ['posts'], | ||
queryFn: queryFn, | ||
keepPreviousData: true, | ||
} | ||
const { data } = useQuery(hookArgument) | ||
``` | ||
|
||
### Troubleshooting | ||
|
||
In case of any errors, feel free to reach us out via Discord or open an issue. If you open an issue, please provide a code snippet as well, because without a snippet we cannot find the bug in the code mod. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.