aws / aws/aws-sdk-js-codemod

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

Open
#866 1 comment 5 reactions 0 assignees View on GitHub
bug p3
Dominant language
TypeScript
Stars
89
Forks
13
Avg merge
9h 59m
Merged PRs (30d)
1

Description

### 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:
```

```

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

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

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the transformation error in app/components/ConfirmationModal.tsx using the listed JSX and TypeScript syntax cases. Read the Babel parser stack trace and the jscodeshift, recast, and aws-sdk-js-codemod versions in the report; done means the codemod runs without errors on these inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.