rome / tools

Unified developer tools for JavaScript, TypeScript, and the web
https://docs.rome.tools/
MIT License
23.77k stars 663 forks source link

🐛 EOL (End-Of-Line) | Format behaviour is not consistent #4196

Closed himaanshu24 closed 1 year ago

himaanshu24 commented 1 year ago

Environment information

CLI:
  Version:              11.0.0
  Color support:        true

Platform:
  CPU Architecture:     x86_64
  OS:                   windows

Environment:
  ROME_LOG_DIR:         unset
  NO_COLOR:             unset
  TERM:                 "xterm-256color"

Rome Configuration:
  Status:               loaded
  Formatter disabled:   false
  Linter disabled:      false

Workspace:
  Open Documents:       0

Discovering running Rome servers...

What happened?

image

Expected result

The eol should be consistent on running npx format . and does not change from mac-windows-mac. This creates an issue every time the code is pushed/pulled to/from mac and windows creating chaos and wasting a lot of time.

Code of Conduct

ematipico commented 1 year ago

We have had contributors with different operating systems and we used Rome formatter for a while, and we haven't had issues concerning the EOL on different OSs.

Is there any chance you'll be able to create a repo where it's possible to reproduce the issue?

himaanshu24 commented 1 year ago

We have had contributors with different operating systems and we used Rome formatter for a while, and we haven't had issues concerning the EOL on different OSs.

Is there any chance you'll be able to create a repo where it's possible to reproduce the issue?

Hi @ematipico,

I have created the following repo on my mac machine

https://github.com/himaanshu24/rome-test

ematipico commented 1 year ago

I believe this is the expected behaviour and it's not an issue related to Rome.

Have you tried fix the issue using git? https://github.com/rome/tools/blob/main/.gitattributes#L1

himaanshu24 commented 1 year ago

Actually, I do have .gitattributes file at the root of my project. It has the following entry

# Autodetect text files
* text=auto

# Force all text file types to have unix line endings
*.* text eol=lf

Let me try to add the same exact line provided by you in the given test repo above.

himaanshu24 commented 1 year ago

Hi @ematipico, I tried the exact entry in .gitattributes, but the issue still persists. Can you please check the given repo - https://github.com/himaanshu24/rome-test

I think this file only affects the git actions which is working fine. I don't know if the rome format is also using the same file for file-attributes or does it has some default config for EOL.

Thanks

himaanshu24 commented 1 year ago

@ematipico, This issue is resolved when using the .gitattributes file. But I have to reset using the following command since this is an existing/old project.

git rm --cached -r .
git reset --hard

Thanks for your help.