From 2aca521a882e54b01ee6a070cb4a38f38bfa4bcf Mon Sep 17 00:00:00 2001 From: Anton Jeppsson Date: Thu, 25 Apr 2024 09:06:14 +0200 Subject: [PATCH] fix(codemods): Use .cjs extension for CommonJS files (#7333) * bug(codemods): rename CommonJS files to .cjs Rename CommonJS files in codemods to distinguish them from ES module files otherwise used in this project. Resolve an issue occuring since package.json in codemods is removed when publishing causing module type data to be lost. Fix issue #7154 * Fix knip errors * Add file extension to tests * Update migration doc --------- Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> --- .../framework/react/guides/migrating-to-v5.md | 4 +- knip.json | 2 +- .../src/utils/{index.js => index.cjs} | 0 ...sformer.js => query-cache-transformer.cjs} | 0 ...former.js => query-client-transformer.cjs} | 0 ...rmer.js => use-query-like-transformer.cjs} | 0 .../v4/__tests__/key-transformation.test.cjs | 38 +++++++++++++++++++ .../v4/__tests__/key-transformation.test.js | 32 ---------------- ...t.js => replace-import-specifier.test.cjs} | 2 +- ...ansformation.js => key-transformation.cjs} | 10 ++--- ...cifier.js => replace-import-specifier.cjs} | 0 .../{key-replacer.js => key-replacer.cjs} | 0 .../__tests__/is-loading.test.cjs} | 4 +- .../{is-loading.js => is-loading.cjs} | 6 +-- ...ta.test.js => keep-previous-data.test.cjs} | 4 +- ...revious-data.js => keep-previous-data.cjs} | 8 ++-- ...already-has-placeholder-data-property.cjs} | 0 .../__tests__/remove-overloads.test.cjs} | 4 +- ...move-overloads.js => remove-overloads.cjs} | 6 +-- ....js => filter-aware-usage-transformer.cjs} | 10 ++--- ...s => query-fn-aware-usage-transformer.cjs} | 6 +-- .../utils/{index.js => index.cjs} | 2 +- ...usage-error.js => unknown-usage-error.cjs} | 0 .../__tests__/rename-hydrate.test.cjs} | 4 +- .../{rename-hydrate.js => rename-hydrate.cjs} | 0 .../__tests__/rename-properties.test.cjs | 16 ++++++++ .../__tests__/rename-properties.test.js | 10 ----- ...me-properties.js => rename-properties.cjs} | 0 28 files changed, 90 insertions(+), 78 deletions(-) rename packages/query-codemods/src/utils/{index.js => index.cjs} (100%) rename packages/query-codemods/src/utils/transformers/{query-cache-transformer.js => query-cache-transformer.cjs} (100%) rename packages/query-codemods/src/utils/transformers/{query-client-transformer.js => query-client-transformer.cjs} (100%) rename packages/query-codemods/src/utils/transformers/{use-query-like-transformer.js => use-query-like-transformer.cjs} (100%) create mode 100644 packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs delete mode 100644 packages/query-codemods/src/v4/__tests__/key-transformation.test.js rename packages/query-codemods/src/v4/__tests__/{replace-import-specifier.test.js => replace-import-specifier.test.cjs} (86%) rename packages/query-codemods/src/v4/{key-transformation.js => key-transformation.cjs} (96%) rename packages/query-codemods/src/v4/{replace-import-specifier.js => replace-import-specifier.cjs} (100%) rename packages/query-codemods/src/v4/utils/replacers/{key-replacer.js => key-replacer.cjs} (100%) rename packages/query-codemods/src/v5/{rename-hydrate/__tests__/rename-hydrate.test.js => is-loading/__tests__/is-loading.test.cjs} (57%) rename packages/query-codemods/src/v5/is-loading/{is-loading.js => is-loading.cjs} (98%) rename packages/query-codemods/src/v5/keep-previous-data/__tests__/{keep-previous-data.test.js => keep-previous-data.test.cjs} (56%) rename packages/query-codemods/src/v5/keep-previous-data/{keep-previous-data.js => keep-previous-data.cjs} (98%) rename packages/query-codemods/src/v5/keep-previous-data/utils/{already-has-placeholder-data-property.js => already-has-placeholder-data-property.cjs} (100%) rename packages/query-codemods/src/v5/{is-loading/__tests__/is-loading.test.js => remove-overloads/__tests__/remove-overloads.test.cjs} (55%) rename packages/query-codemods/src/v5/remove-overloads/{remove-overloads.js => remove-overloads.cjs} (92%) rename packages/query-codemods/src/v5/remove-overloads/transformers/{filter-aware-usage-transformer.js => filter-aware-usage-transformer.cjs} (97%) rename packages/query-codemods/src/v5/remove-overloads/transformers/{query-fn-aware-usage-transformer.js => query-fn-aware-usage-transformer.cjs} (96%) rename packages/query-codemods/src/v5/remove-overloads/utils/{index.js => index.cjs} (98%) rename packages/query-codemods/src/v5/remove-overloads/utils/{unknown-usage-error.js => unknown-usage-error.cjs} (100%) rename packages/query-codemods/src/v5/{remove-overloads/__tests__/remove-overloads.test.js => rename-hydrate/__tests__/rename-hydrate.test.cjs} (56%) rename packages/query-codemods/src/v5/rename-hydrate/{rename-hydrate.js => rename-hydrate.cjs} (100%) create mode 100644 packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs delete mode 100644 packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.js rename packages/query-codemods/src/v5/rename-properties/{rename-properties.js => rename-properties.cjs} (100%) diff --git a/docs/framework/react/guides/migrating-to-v5.md b/docs/framework/react/guides/migrating-to-v5.md index b2ffc37db9..aa6ea1a741 100644 --- a/docs/framework/react/guides/migrating-to-v5.md +++ b/docs/framework/react/guides/migrating-to-v5.md @@ -91,7 +91,7 @@ If you want to run it against `.js` or `.jsx` files, please use the command belo ``` npx jscodeshift@latest ./path/to/src/ \ --extensions=js,jsx \ - --transform=./node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.js + --transform=./node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.cjs ``` If you want to run it against `.ts` or `.tsx` files, please use the command below: @@ -100,7 +100,7 @@ If you want to run it against `.ts` or `.tsx` files, please use the command belo npx jscodeshift@latest ./path/to/src/ \ --extensions=ts,tsx \ --parser=tsx \ - --transform=./node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.js + --transform=./node_modules/@tanstack/react-query/build/codemods/src/v5/remove-overloads/remove-overloads.cjs ``` Please note in the case of `TypeScript` you need to use `tsx` as the parser; otherwise, the codemod won't be applied properly! diff --git a/knip.json b/knip.json index b5c8fe0913..adf7dfcb9c 100644 --- a/knip.json +++ b/knip.json @@ -3,7 +3,7 @@ "ignoreWorkspaces": ["examples/**", "integrations/**"], "workspaces": { "packages/query-codemods": { - "entry": ["src/v4/*.js", "src/v5/*/*.js"], + "entry": ["src/v4/**/*.cjs", "src/v5/**/*.cjs"], "ignore": ["**/__testfixtures__/**"] }, "packages/vue-query": { diff --git a/packages/query-codemods/src/utils/index.js b/packages/query-codemods/src/utils/index.cjs similarity index 100% rename from packages/query-codemods/src/utils/index.js rename to packages/query-codemods/src/utils/index.cjs diff --git a/packages/query-codemods/src/utils/transformers/query-cache-transformer.js b/packages/query-codemods/src/utils/transformers/query-cache-transformer.cjs similarity index 100% rename from packages/query-codemods/src/utils/transformers/query-cache-transformer.js rename to packages/query-codemods/src/utils/transformers/query-cache-transformer.cjs diff --git a/packages/query-codemods/src/utils/transformers/query-client-transformer.js b/packages/query-codemods/src/utils/transformers/query-client-transformer.cjs similarity index 100% rename from packages/query-codemods/src/utils/transformers/query-client-transformer.js rename to packages/query-codemods/src/utils/transformers/query-client-transformer.cjs diff --git a/packages/query-codemods/src/utils/transformers/use-query-like-transformer.js b/packages/query-codemods/src/utils/transformers/use-query-like-transformer.cjs similarity index 100% rename from packages/query-codemods/src/utils/transformers/use-query-like-transformer.js rename to packages/query-codemods/src/utils/transformers/use-query-like-transformer.cjs diff --git a/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs b/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs new file mode 100644 index 0000000000..5d5cdafa68 --- /dev/null +++ b/packages/query-codemods/src/v4/__tests__/key-transformation.test.cjs @@ -0,0 +1,38 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const defineTest = require('jscodeshift/dist/testUtils').defineTest + +defineTest(__dirname, 'key-transformation.cjs', null, 'default-import', { + parser: 'tsx', +}) + +defineTest(__dirname, 'key-transformation.cjs', null, 'named-import', { + parser: 'tsx', +}) + +defineTest(__dirname, 'key-transformation.cjs', null, 'namespaced-import', { + parser: 'tsx', +}) + +defineTest( + __dirname, + 'key-transformation.cjs', + null, + 'parameter-is-identifier', + { + parser: 'tsx', + }, +) + +defineTest( + __dirname, + 'key-transformation.cjs', + null, + 'parameter-is-object-expression', + { + parser: 'tsx', + }, +) + +defineTest(__dirname, 'key-transformation.cjs', null, 'type-arguments', { + parser: 'tsx', +}) diff --git a/packages/query-codemods/src/v4/__tests__/key-transformation.test.js b/packages/query-codemods/src/v4/__tests__/key-transformation.test.js deleted file mode 100644 index f66cd38204..0000000000 --- a/packages/query-codemods/src/v4/__tests__/key-transformation.test.js +++ /dev/null @@ -1,32 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const defineTest = require('jscodeshift/dist/testUtils').defineTest - -defineTest(__dirname, 'key-transformation', null, 'default-import', { - parser: 'tsx', -}) - -defineTest(__dirname, 'key-transformation', null, 'named-import', { - parser: 'tsx', -}) - -defineTest(__dirname, 'key-transformation', null, 'namespaced-import', { - parser: 'tsx', -}) - -defineTest(__dirname, 'key-transformation', null, 'parameter-is-identifier', { - parser: 'tsx', -}) - -defineTest( - __dirname, - 'key-transformation', - null, - 'parameter-is-object-expression', - { - parser: 'tsx', - }, -) - -defineTest(__dirname, 'key-transformation', null, 'type-arguments', { - parser: 'tsx', -}) diff --git a/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.js b/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs similarity index 86% rename from packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.js rename to packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs index f51ac94ee4..26b3418d68 100644 --- a/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.js +++ b/packages/query-codemods/src/v4/__tests__/replace-import-specifier.test.cjs @@ -3,7 +3,7 @@ const defineTest = require('jscodeshift/dist/testUtils').defineTest defineTest( __dirname, - 'replace-import-specifier', + 'replace-import-specifier.cjs', null, 'replace-import-specifier', { diff --git a/packages/query-codemods/src/v4/key-transformation.js b/packages/query-codemods/src/v4/key-transformation.cjs similarity index 96% rename from packages/query-codemods/src/v4/key-transformation.js rename to packages/query-codemods/src/v4/key-transformation.cjs index e6c6766d43..cdb20625c4 100644 --- a/packages/query-codemods/src/v4/key-transformation.js +++ b/packages/query-codemods/src/v4/key-transformation.cjs @@ -1,13 +1,13 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUtilsObject = require('../utils') +const createUtilsObject = require('../utils/index.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createKeyReplacer = require('./utils/replacers/key-replacer') +const createKeyReplacer = require('./utils/replacers/key-replacer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUseQueryLikeTransformer = require('../utils/transformers/use-query-like-transformer') +const createUseQueryLikeTransformer = require('../utils/transformers/use-query-like-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryClientTransformer = require('../utils/transformers/query-client-transformer') +const createQueryClientTransformer = require('../utils/transformers/query-client-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryCacheTransformer = require('../utils/transformers/query-cache-transformer') +const createQueryCacheTransformer = require('../utils/transformers/query-cache-transformer.cjs') const transformQueryClientUsages = ({ jscodeshift, diff --git a/packages/query-codemods/src/v4/replace-import-specifier.js b/packages/query-codemods/src/v4/replace-import-specifier.cjs similarity index 100% rename from packages/query-codemods/src/v4/replace-import-specifier.js rename to packages/query-codemods/src/v4/replace-import-specifier.cjs diff --git a/packages/query-codemods/src/v4/utils/replacers/key-replacer.js b/packages/query-codemods/src/v4/utils/replacers/key-replacer.cjs similarity index 100% rename from packages/query-codemods/src/v4/utils/replacers/key-replacer.js rename to packages/query-codemods/src/v4/utils/replacers/key-replacer.cjs diff --git a/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.js b/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs similarity index 57% rename from packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.js rename to packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs index 600e852553..b474bfa9a9 100644 --- a/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.js +++ b/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.cjs @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest -defineTest(__dirname, 'rename-hydrate', null, 'default-import', { +defineTest(__dirname, 'is-loading.cjs', null, 'default-import', { parser: 'tsx', }) -defineTest(__dirname, 'rename-hydrate', null, 'named-import', { +defineTest(__dirname, 'is-loading.cjs', null, 'named-import', { parser: 'tsx', }) diff --git a/packages/query-codemods/src/v5/is-loading/is-loading.js b/packages/query-codemods/src/v5/is-loading/is-loading.cjs similarity index 98% rename from packages/query-codemods/src/v5/is-loading/is-loading.js rename to packages/query-codemods/src/v5/is-loading/is-loading.cjs index ca1e98f5d4..acf7e3fa80 100644 --- a/packages/query-codemods/src/v5/is-loading/is-loading.js +++ b/packages/query-codemods/src/v5/is-loading/is-loading.cjs @@ -1,9 +1,9 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUtilsObject = require('../../utils') +const createUtilsObject = require('../../utils/index.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUseQueryLikeTransformer = require('../../utils/transformers/use-query-like-transformer') +const createUseQueryLikeTransformer = require('../../utils/transformers/use-query-like-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryClientTransformer = require('../../utils/transformers/query-client-transformer') +const createQueryClientTransformer = require('../../utils/transformers/query-client-transformer.cjs') const originalName = 'isLoading' const newName = 'isPending' diff --git a/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.js b/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs similarity index 56% rename from packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.js rename to packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs index 5394bb8cc6..433a46752e 100644 --- a/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.js +++ b/packages/query-codemods/src/v5/keep-previous-data/__tests__/keep-previous-data.test.cjs @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest -defineTest(__dirname, 'keep-previous-data', null, 'default', { +defineTest(__dirname, 'keep-previous-data.cjs', null, 'default', { parser: 'tsx', }) -defineTest(__dirname, 'keep-previous-data', null, 'named', { +defineTest(__dirname, 'keep-previous-data.cjs', null, 'named', { parser: 'tsx', }) diff --git a/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.js b/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs similarity index 98% rename from packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.js rename to packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs index 5b2a9553a9..7d438495ae 100644 --- a/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.js +++ b/packages/query-codemods/src/v5/keep-previous-data/keep-previous-data.cjs @@ -1,11 +1,11 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUtilsObject = require('../../utils') +const createUtilsObject = require('../../utils/index.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUseQueryLikeTransformer = require('../../utils/transformers/use-query-like-transformer') +const createUseQueryLikeTransformer = require('../../utils/transformers/use-query-like-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryClientTransformer = require('../../utils/transformers/query-client-transformer') +const createQueryClientTransformer = require('../../utils/transformers/query-client-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const AlreadyHasPlaceholderDataProperty = require('./utils/already-has-placeholder-data-property') +const AlreadyHasPlaceholderDataProperty = require('./utils/already-has-placeholder-data-property.cjs') /** * @param {import('jscodeshift')} jscodeshift diff --git a/packages/query-codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.js b/packages/query-codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.cjs similarity index 100% rename from packages/query-codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.js rename to packages/query-codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.cjs diff --git a/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.js b/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs similarity index 55% rename from packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.js rename to packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs index 0aaa7193d7..bb83a14035 100644 --- a/packages/query-codemods/src/v5/is-loading/__tests__/is-loading.test.js +++ b/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.cjs @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest -defineTest(__dirname, 'is-loading', null, 'default-import', { +defineTest(__dirname, 'remove-overloads.cjs', null, 'default-import', { parser: 'tsx', }) -defineTest(__dirname, 'is-loading', null, 'named-import', { +defineTest(__dirname, 'remove-overloads.cjs', null, 'bug-reports', { parser: 'tsx', }) diff --git a/packages/query-codemods/src/v5/remove-overloads/remove-overloads.js b/packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs similarity index 92% rename from packages/query-codemods/src/v5/remove-overloads/remove-overloads.js rename to packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs index 10ecd37dca..9c3ce67166 100644 --- a/packages/query-codemods/src/v5/remove-overloads/remove-overloads.js +++ b/packages/query-codemods/src/v5/remove-overloads/remove-overloads.cjs @@ -1,9 +1,9 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUtilsObject = require('../../utils') +const createUtilsObject = require('../../utils/index.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const transformFilterAwareUsages = require('./transformers/filter-aware-usage-transformer') +const transformFilterAwareUsages = require('./transformers/filter-aware-usage-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const transformQueryFnAwareUsages = require('./transformers/query-fn-aware-usage-transformer') +const transformQueryFnAwareUsages = require('./transformers/query-fn-aware-usage-transformer.cjs') module.exports = (file, api) => { const jscodeshift = api.jscodeshift diff --git a/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.js b/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs similarity index 97% rename from packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.js rename to packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs index 66e37b1e3f..f7056f94b1 100644 --- a/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.js +++ b/packages/query-codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs @@ -1,13 +1,13 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const createV5UtilsObject = require('../utils') +const createV5UtilsObject = require('../utils/index.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const UnknownUsageError = require('../utils/unknown-usage-error') +const UnknownUsageError = require('../utils/unknown-usage-error.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryClientTransformer = require('../../../utils/transformers/query-client-transformer') +const createQueryClientTransformer = require('../../../utils/transformers/query-client-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryCacheTransformer = require('../../../utils/transformers/query-cache-transformer') +const createQueryCacheTransformer = require('../../../utils/transformers/query-cache-transformer.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createUseQueryLikeTransformer = require('../../../utils/transformers/use-query-like-transformer') +const createUseQueryLikeTransformer = require('../../../utils/transformers/use-query-like-transformer.cjs') /** * @param {import('jscodeshift').api} jscodeshift diff --git a/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.js b/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs similarity index 96% rename from packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.js rename to packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs index 77238d2caa..d7fde1d4d7 100644 --- a/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.js +++ b/packages/query-codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs @@ -1,9 +1,9 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const createV5UtilsObject = require('../utils') +const createV5UtilsObject = require('../utils/index.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const UnknownUsageError = require('../utils/unknown-usage-error') +const UnknownUsageError = require('../utils/unknown-usage-error.cjs') // eslint-disable-next-line @typescript-eslint/no-var-requires -const createQueryClientTransformer = require('../../../utils/transformers/query-client-transformer') +const createQueryClientTransformer = require('../../../utils/transformers/query-client-transformer.cjs') /** * @param {import('jscodeshift').api} jscodeshift diff --git a/packages/query-codemods/src/v5/remove-overloads/utils/index.js b/packages/query-codemods/src/v5/remove-overloads/utils/index.cjs similarity index 98% rename from packages/query-codemods/src/v5/remove-overloads/utils/index.js rename to packages/query-codemods/src/v5/remove-overloads/utils/index.cjs index 88512fd61e..469964d1f4 100644 --- a/packages/query-codemods/src/v5/remove-overloads/utils/index.js +++ b/packages/query-codemods/src/v5/remove-overloads/utils/index.cjs @@ -1,5 +1,5 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires -const UnknownUsageError = require('./unknown-usage-error') +const UnknownUsageError = require('./unknown-usage-error.cjs') module.exports = ({ jscodeshift, utils }) => { /** diff --git a/packages/query-codemods/src/v5/remove-overloads/utils/unknown-usage-error.js b/packages/query-codemods/src/v5/remove-overloads/utils/unknown-usage-error.cjs similarity index 100% rename from packages/query-codemods/src/v5/remove-overloads/utils/unknown-usage-error.js rename to packages/query-codemods/src/v5/remove-overloads/utils/unknown-usage-error.cjs diff --git a/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.js b/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs similarity index 56% rename from packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.js rename to packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs index c37eef718e..53ed74a496 100644 --- a/packages/query-codemods/src/v5/remove-overloads/__tests__/remove-overloads.test.js +++ b/packages/query-codemods/src/v5/rename-hydrate/__tests__/rename-hydrate.test.cjs @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const defineTest = require('jscodeshift/dist/testUtils').defineTest -defineTest(__dirname, 'remove-overloads', null, 'default-import', { +defineTest(__dirname, 'rename-hydrate.cjs', null, 'default-import', { parser: 'tsx', }) -defineTest(__dirname, 'remove-overloads', null, 'bug-reports', { +defineTest(__dirname, 'rename-hydrate.cjs', null, 'named-import', { parser: 'tsx', }) diff --git a/packages/query-codemods/src/v5/rename-hydrate/rename-hydrate.js b/packages/query-codemods/src/v5/rename-hydrate/rename-hydrate.cjs similarity index 100% rename from packages/query-codemods/src/v5/rename-hydrate/rename-hydrate.js rename to packages/query-codemods/src/v5/rename-hydrate/rename-hydrate.cjs diff --git a/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs b/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs new file mode 100644 index 0000000000..8a214e85df --- /dev/null +++ b/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.cjs @@ -0,0 +1,16 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const defineTest = require('jscodeshift/dist/testUtils').defineTest + +defineTest(__dirname, 'rename-properties.cjs', null, 'rename-cache-time', { + parser: 'tsx', +}) + +defineTest( + __dirname, + 'rename-properties.cjs', + null, + 'rename-use-error-boundary', + { + parser: 'tsx', + }, +) diff --git a/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.js b/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.js deleted file mode 100644 index 31a14fdfa2..0000000000 --- a/packages/query-codemods/src/v5/rename-properties/__tests__/rename-properties.test.js +++ /dev/null @@ -1,10 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const defineTest = require('jscodeshift/dist/testUtils').defineTest - -defineTest(__dirname, 'rename-properties', null, 'rename-cache-time', { - parser: 'tsx', -}) - -defineTest(__dirname, 'rename-properties', null, 'rename-use-error-boundary', { - parser: 'tsx', -}) diff --git a/packages/query-codemods/src/v5/rename-properties/rename-properties.js b/packages/query-codemods/src/v5/rename-properties/rename-properties.cjs similarity index 100% rename from packages/query-codemods/src/v5/rename-properties/rename-properties.js rename to packages/query-codemods/src/v5/rename-properties/rename-properties.cjs