Skip to content
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

[Bug?]: Seems like codemod has some problems with certain bits of legal jsx syntax #866

Open
1 task
Swolebrain opened this issue Apr 30, 2024 · 1 comment
Labels
bug Something isn't working p3 This is a minor priority issue

Comments

@Swolebrain
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

Getting a lot of errors in .tsx files that say:

SyntaxError: Unexpected token, expected "," (32:27)

Steps to reproduce

Seems to happen when:

  • JSX properties with single quotes
  • JSX styles with no trailing commas
  • JSX property split into a newline. Example:
 <SomeComponent
   someProp={  // <-- this line errors
     ...
  }
/>

There's others too.

Observed behavior

An example stack trace is:

 ERR app/components/ConfirmationModal.tsx Transformation error (Unexpected token, expected "," (32:12))
SyntaxError: Unexpected token, expected "," (32:12)
    at constructor (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:351:19)
    at TypeScriptParserMixin.raise (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:3281:19)
    at TypeScriptParserMixin.unexpected (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:3301:16)
    at TypeScriptParserMixin.expect (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:3605:28)
    at TypeScriptParserMixin.tsParseDelimitedListWorker (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:7677:14)
    at TypeScriptParserMixin.tsParseDelimitedList (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:7654:25)
    at TypeScriptParserMixin.tsParseBracketedList (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:7694:25)
    at TypeScriptParserMixin.tsParseTypeParameters (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:7796:24)
    at /Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:9433:29
    at TypeScriptParserMixin.tryParse (/Users/morevct/.npm/_npx/c10ddf24489924c3/node_modules/@babel/parser/lib/index.js:3612:20)

So it seems like maybe we're using too old a version of babel?

Expected behavior

should run with no errors

Environment

aws-sdk-js-codemod: 1.4.0
- jscodeshift: 0.15.2
- recast: 0.23.6

Additional context

No response

@Swolebrain Swolebrain added bug Something isn't working triage Triaging bugs labels Apr 30, 2024
@trivikr trivikr added p3 This is a minor priority issue and removed triage Triaging bugs labels May 21, 2024
@trivikr
Copy link
Member

trivikr commented May 21, 2024

The codemod is not tested on JSX/TSX, and this appears to be issue with dependency jscodeshift which mostly unmaintained https://github.com/search?q=repo%3Afacebook%2Fjscodeshift+%22Transformation+error%22&type=issues

Assigning p3 label as of now. It can be prioritized if this is a blocker for more folks.
If you're affected, please 👍 the comment above, and provide additional details on how you're impacted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants