Skip to content

5.0.0-alpha.26 - Codemod syntax error #5405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michaeljseiter opened this issue May 12, 2023 · 4 comments
Closed

5.0.0-alpha.26 - Codemod syntax error #5405

michaeljseiter opened this issue May 12, 2023 · 4 comments
Assignees
Labels
bug Something isn't working v5
Milestone

Comments

@michaeljseiter
Copy link

michaeljseiter commented May 12, 2023

Describe the bug

When running the codemod for js/jsx files via...

npx jscodeshift ./path/to/src/ \
  --extensions=js,jsx \
  --transform=./node_modules/@tanstack/react-query/build/codemods/v5/remove-overloads/remove-overloads.js

An error is thrown...

$ npx jscodeshift ./src/ --extensions=js,jsx --transform=./node_modules/@tanstack/react-query/build/codemods/v5/remove-overloads/remove-overloads.js
npx: installed 156 in 8.369s
Processing 1 files... 
Spawning 1 workers...
Sending 1 files to free worker...
/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/lib/transformation/index.js:31
    throw e;
    ^

SyntaxError: /rbd/pnpm-volume/6d6b10a6-845a-4673-801b-015e2bcd41f2/node_modules/@tanstack/react-query/build/codemods/v5/remove-overloads/utils/unknown-usage-error.js: Class private methods are not enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
  15 |    * @returns {string}
  16 |    */
> 17 |   #buildMessage(callExpression, filePath) {
     |   ^
  18 |     const location = callExpression.callee.loc
  19 |     const start = location.start.line
  20 |     const end = location.end.line
    at File.buildError [as buildCodeFrameError] (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/src/transformation/file/file.ts:279:12)
    at NodePath.buildCodeFrameError (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/path/index.ts:139:21)
    at shouldTransform (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/helper-create-class-features-plugin/src/features.ts:192:29)
    at PluginPass.call (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/helper-create-class-features-plugin/src/index.ts:120:29)
    at call (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/visitors.ts:258:21)
    at NodePath._call (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/path/context.ts:34:20)
    at NodePath.call (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/path/context.ts:19:17)
    at NodePath.visit (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/path/context.ts:92:31)
    at TraversalContext.visitQueue (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/context.ts:144:16)
    at TraversalContext.visitMultiple (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/context.ts:98:17)
    at TraversalContext.visit (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/context.ts:174:19)
    at traverseNode (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/traverse-node.ts:34:17)
    at NodePath.visit (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/path/context.ts:99:33)
    at TraversalContext.visitQueue (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/context.ts:144:16)
    at TraversalContext.visitSingle (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/context.ts:108:19)
    at TraversalContext.visit (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/context.ts:176:19)
    at traverseNode (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/traverse-node.ts:34:17)
    at traverse (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/traverse/src/index.ts:71:15)
    at transformFile (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/src/transformation/index.ts:120:13)
    at transformFile.next (<anonymous>)
    at run (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/src/transformation/index.ts:47:12)
    at run.next (<anonymous>)
    at transform (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/src/transform.ts:29:20)
    at transform.next (<anonymous>)
    at evaluateSync (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/gensync/index.js:251:28)
    at fn (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/gensync/index.js:89:14)
    at stopHiding - secret - don\'t use this - v1 (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:97:14)
    at Object.transformSync (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/core/src/transform.ts:66:52)
    at transformSync (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/register/src/worker/transform.js:94:33)
    at Function.handleMessage (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/register/src/worker/handle-message.js:15:16)
    at LocalClient.<anonymous> (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/register/src/worker-client.js:103:27)
    at LocalClient.transform (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/register/src/worker-client.js:40:16)
    at compile (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/register/src/hook.js:57:25)
    at compileBabel7 (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/@babel/register/src/hook.js:48:14)
    at Module._compile (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:130:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.newLoader [as .js] (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:141:7)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/rbd/pnpm-volume/6d6b10a6-845a-4673-801b-015e2bcd41f2/node_modules/@tanstack/react-query/build/codemods/v5/remove-overloads/utils/index.js:2:27)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Module._compile (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:136:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.newLoader [as .js] (/tmp/npm-cache/14.19.1/_npx/2098/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:141:7)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18) {
  code: 'BABEL_TRANSFORM_ERROR'
}
All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.844seconds 

Your minimal, reproducible example

🐟 https://glitch.com/edit/#!/concise-mewing-baryonyx

Glitch was the only place I could think of where we could get to a shell.
If you'd like edit access and the ability to open a terminal click the "Request to Join" button.

[UPDATED 12May2023]: Codesandbox has terminal access after all! Woo! (thx @TkDodo )

Steps to reproduce

Run codemod against js/jsx files with:

npx jscodeshift ./path/to/src/ \
  --extensions=js,jsx \
  --transform=./node_modules/@tanstack/react-query/build/codemods/v5/remove-overloads/remove-overloads.js

Expected behavior

Codemod successfully runs and completes.

How often does this bug happen?

Every time

Screenshots or Videos

Codemod error

Platform

Ran into this locally on macOS and duplicated on Linux via Glitch.

  • macOS: Node v16.17.0 (npm v8.19.3)
  • Linux: Node v14.19.1 (npm v6.14.16)

Tanstack Query adapter

react-query

TanStack Query version

5.0.0-alpha.26

TypeScript version

No response

Additional context

No response

@TkDodo
Copy link
Collaborator

TkDodo commented May 13, 2023

Best way to reproduce would be to create an open source repo that we can checkout locally please. codesandbox projects also have access to terminals.

@balazsmatepetro fyi

@balazsmatepetro
Copy link
Contributor

I will take care of it.

@michaeljseiter
Copy link
Author

michaeljseiter commented May 14, 2023

Ah! Thank you @TkDodo ! I totally missed that when I was thumbing through codesandbox. TIL :)

Codesandbox made it easy to create a repo from the code too so doing both was quick.
You all might be well past this by now but for posterity (also updated above submission):

Thank you all for your hard work. Five is looking awesome!!!

@TkDodo TkDodo added bug Something isn't working v5 labels May 15, 2023
@TkDodo TkDodo added this to the v5 milestone May 15, 2023
@balazsmatepetro
Copy link
Contributor

@TkDodo TkDodo closed this as completed Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v5
Projects
None yet
Development

No branches or pull requests

3 participants