Code Monkey home page Code Monkey logo

Comments (9)

eugenious avatar eugenious commented on May 9, 2024 1

Ah the fun of platform line endings.

The issue is, some people (including me) have the setting for git line endings doing automatic conversions to CRLF on Windows.

I have revisited my decision and now I have git settings to checkout line endings as LF no matter what, which seems like a saner way to go.

from node-typescript-boilerplate.

jsynowiec avatar jsynowiec commented on May 9, 2024

Thank you for reporting. I don't have Windows to test this so I'm going to fix it on a separate branch and ask you to validate before merging.

from node-typescript-boilerplate.

eugenious avatar eugenious commented on May 9, 2024

I will be happy to do that. Thank you for a great project.

from node-typescript-boilerplate.

jsynowiec avatar jsynowiec commented on May 9, 2024

@eugenious I've read about linebreak-style check and I'm against setting it to false as the default for this starter. Line breaks should be consistent in source files.

If you're mixing CRLFs with LFs, then in my opinion you should correct those files and settle for one style with either "linebreak-style": [true, "LF"] or "linebreak-style": [true, "CRLF"].

from node-typescript-boilerplate.

jsynowiec avatar jsynowiec commented on May 9, 2024

@eugenious Please check if #7 fixes npm run lint on Windows.

from node-typescript-boilerplate.

jsynowiec avatar jsynowiec commented on May 9, 2024

Git can handle line endings by auto-converting CRLF into LF when you add a file to the index, and vice versa when it checks out code onto your filesystem. You can enable this with the core.autocrlf setting.

On Windows, set it to true – this converts LF endings into CRLF on checkout

$ git config --global core.autocrlf true

On Mac and Linux you may want Git to fix files with CRLF endings that were accidentally introduced. To convert CRLF to LF on commit but not the other way around, set core.autocrlf to input

from node-typescript-boilerplate.

eugenious avatar eugenious commented on May 9, 2024

Yes I know, and that's exactly the problem!

By setting core.autocrlf to true, projects will be cloned into Windows with CRLF.

And running "npm run lint" locally on Windows will fail, as it expects line endings to be LF, not CRLF.

Of course, I could then in my project enforce: "linebreak-style": [true, "CRLF"].

But then that makes my project ONLY work under Windows. It's no longer cross platform.

from node-typescript-boilerplate.

jsynowiec avatar jsynowiec commented on May 9, 2024

I still think that enforcing unified line endings across files is a safe default option (and a desired one). It's possible to opt-out - disable this setting or change it to CRLF if you want to.

from node-typescript-boilerplate.

eugenious avatar eugenious commented on May 9, 2024

I think I'm still not being clear enough.

Unified line endings across files is normal and expected.

Unified line endings across PLATFORMS, for the same git repository, isn't a universal practice.

Anyway, my solution for this is working fine: I've now adopted the practice of using only LF regardless of platform, and probably this is what everybody should be doing.

Thanks!

from node-typescript-boilerplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.