Download react-query/packages/query-codemods/src/v4/replace-import-specifier.cjs from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 605 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/query-codemods/src/v4/replace-import-specifier.cjs
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/query-codemods/src/v4/replace-import-specifier.cjs
-
curl -L -o replace-import-specifier.cjs https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/query-codemods/src/v4/replace-import-specifier.cjs
605 Bytes
| module.exports = (file, api) => { | |
| const jscodeshift = api.jscodeshift | |
| const root = jscodeshift(file.source) | |
| const replacements = [ | |
| { from: 'react-query', to: '@tanstack/react-query' }, | |
| { from: 'react-query/devtools', to: '@tanstack/react-query-devtools' }, | |
| ] | |
| replacements.forEach(({ from, to }) => { | |
| root | |
| .find(jscodeshift.ImportDeclaration, { | |
| source: { | |
| value: from, | |
| }, | |
| }) | |
| .replaceWith(({ node }) => { | |
| node.source.value = to | |
| return node | |
| }) | |
| }) | |
| return root.toSource({ quote: 'single', lineTerminator: '\n' }) | |
| } | |