简体   繁体   中英

How important is to enforce the “linebreak-style” rule in ESlint? Can I just turn it off?

I've created a Node.js module which I'm gonna be open-sourcing soon. I originally developed it on Linux and I decided to test it on Windows before publishing it. When I ran ESLint on Windows I noticed I had a huge amount of linting errors which were all the same:

error  Expected linebreaks to be 'LF' but found 'CRLF'  linebreak-style

I read in a couple of places that these linebreaks were inserted by Git when I cloned the repo on Windows. I also read that it is possible to turn off this rule in the eslint config file. Is it safe to do this? or is there a "best practice" regarding this rule? (considering this will be an open source project and hopefully others will be contributing to it)

Any advice or feedback will be appreciated.

Try to re-clone your repo after typing:

git config --global core.autocrlf false

That should avoid Git converting your eol (end of lines) from LF to CRLF automatically on checkout.
Then your linter should find the expected eol.

Note: I have been advocating for that setting to be false by default for years: see " Git: Unix or DOS line termination ".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM