reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11k stars 7.51k forks source link

fix: implement `.editorconfig` to enforce LF line endings #7003

Closed lumirlumir closed 3 months ago

lumirlumir commented 3 months ago

Hello 😊

For general Windows users, when cloning the react.dev repository, LF often automatically changes to CRLF if no special settings are made in the editor. Typically, this changes back to LF during commits.

However,

  1. In some cases, due to bugs or conflicts, the conversion back to LF does not occur properly.
  2. To prevent CRLF automatic conversion on Windows, users must use commands like git config --global core.autocrlf false, which is a drawback as it relies on personal settings of the user.
  3. Due to the execution of pre-commit hooks, CRLF is changed back to LF during commits. However, since all file line endings are changed to CRLF after cloning the repository on Windows, there is a major drawback where all files are marked as modified.

Example of an error situation:

On windows, After adding a comment // add test to the 404.js file and entering git commit -m "test", all files with CRLF are changed to LF, resulting in over 100 files showing changes.

스크린샷 2024-06-30 225655

스크린샷 2024-06-30 225754

Therefore, to ensure smooth compatibility between Windows and Linux/Mac users, I propose the adoption of .editorconfig, which is used in various repositories like 'react', 'eslint' and 'prettier'. By enforcing the use of LF, it is expected that Windows users will experience less confusion due to CRLF/LF issues during development.

Furthermore, I would like to tell you that after adopting .editorconfig, all the above-mentioned errors have been resolved. Thank you for your attention to this matter :)

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
19-react-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 3:43am
react-dev ✅ Ready (Inspect) Visit Preview Jul 1, 2024 3:43am
facebook-github-bot commented 3 months ago

Hi @lumirlumir!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

github-actions[bot] commented 3 months ago

Size changes

## 📦 Next.js Bundle Analysis for react-dev This analysis was generated by the [Next.js Bundle Analysis action](https://github.com/hashicorp/nextjs-bundle-analysis). 🤖 This PR introduced no changes to the JavaScript bundle! 🙌
facebook-github-bot commented 3 months ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!