Skip to content

feat: add transform to remove forward ref#3

Merged
ntltd merged 4 commits intomainfrom
feat/transform-forward-ref
May 14, 2024
Merged

feat: add transform to remove forward ref#3
ntltd merged 4 commits intomainfrom
feat/transform-forward-ref

Conversation

@hymced
Copy link
Contributor

@hymced hymced commented May 13, 2024

No description provided.

@hymced hymced requested a review from ntltd May 13, 2024 17:24
@hymced hymced self-assigned this May 13, 2024
@hymced
Copy link
Contributor Author

hymced commented May 13, 2024

jscodeshift's "print" method is:

root.toSource(printOptions)

it calls recast's default print method:

recast.print(root.__paths[0], printOptions).code

https://github.com/facebook/jscodeshift/blob/main/src/Collection.js#L173
https://github.com/facebook/jscodeshift/blob/4851fc8a01036868efb4cf9676f3e97836097376/src/Collection.js#L173

recast also has another method:

recast.prettyPrint(root.__paths[0], printOptions).code

Printing a modified or new ObjectPattern will always print each property on different lines: https://stackoverflow.com/questions/42753294/jscodeshift-recast-objectexpression-is-always-pretty-printed-how-can-i-prevent
recast implementation:
https://github.com/benjamn/recast/blob/master/lib/printer.ts
https://github.com/benjamn/recast/blob/aff2dead1b1c7c9cf25f5cc8c6794936d6b23d35/lib/printer.ts#L709

Hard coded trailing semi colon for import declarations here:
https://github.com/benjamn/recast/blob/master/lib/printer.ts#L618
https://github.com/benjamn/recast/blob/aff2dead1b1c7c9cf25f5cc8c6794936d6b23d35/lib/printer.ts#L618

@ntltd ntltd merged commit aa227e0 into main May 14, 2024
ntltd pushed a commit that referenced this pull request May 14, 2024
* fix: remove prettier for test fixtures

* fix: review

* fix: review

* docs: clean README
@ntltd ntltd deleted the feat/transform-forward-ref branch May 14, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants