next.js icon indicating copy to clipboard operation
next.js copied to clipboard

[next-codemod] codemod changes all line endings to carriage returns on windows

Open timmywil opened this issue 3 years ago • 3 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: win32
Arch: x64 Version: Windows 10 Pro Binaries: Node: 18.12.0 npm: N/A Yarn: N/A pnpm: N/A Relevant packages:
next: 13.0.1 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Running either of the following commands on windows results in all newlines in all files to be changed to carriage returns.

$ npx @next/codemod@latest new-link
$ npx @next/codemod@canary new-link
image

Expected Behavior

Running codemod does not alter line endings one way or the other.

Link to reproduction

This can be reproduced in any project, but only on Windows

To Reproduce

Run npx @next/codemod@latest new-link on Windows.

timmywil avatar Nov 03 '22 19:11 timmywil

I encountered this with bash on windows 11. Please don't mess with my line endings.

$ npx @next/codemod@latest --version
13.0.2

dopry avatar Nov 09 '22 19:11 dopry

Here's how to temporarily resolve the issue: (Passing arguments to jscodeshift)

npx @next/codemod@latest next-image-to-legacy-image . --jscodeshift="--lineTerminator=\"\n\""

but I don't know why under code not working

npx @next/codemod@latest new-link . --jscodeshift="--lineTerminator=\"\n\""

oh.. next-image-to-legacy-image vs new-link

https://github.com/facebook/jscodeshift/issues/262

sacru2red avatar Mar 13 '24 03:03 sacru2red

works only for certain transformations, but there are still some unwanted changes made by codemod, e.g. adding semicolons at the end of line when i have them disabled in my code, removing React.Fragment etc.

sKopheK avatar Oct 25 '24 09:10 sKopheK