-
Notifications
You must be signed in to change notification settings - Fork 26.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linebreak-style makes it impossible for Windows users to contribute #1224
base: master
Are you sure you want to change the base?
Conversation
Any project that currently uses eslint-config-airbnb checked out on Windows results in thousands of linter errors since the line endings will be CRLF, making it impossible to contribute to these projects as a Windows user without nerfing the linter entirely. A better way to enforce this is not via a linter, but via a .gitattributes file (https://help.github.com/articles/dealing-with-line-endings). When you do this, Git will ensure the repo internally is LF, but on Win32 will check out files as CRLF (this is a builtin case of a clean/smudge filter) Refs vercel/hyper#1230, xojs/eslint-config-xo#35
Also, it should be set to |
Indeed, #1089 (comment) is the official response - all users should always only use LF, including on Windows. |
@ljharb This is not how Git works on Windows, can you please read https://help.github.com/articles/dealing-with-line-endings/#platform-windows and http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line? What you're asking is imposing a huge burden on Windows users. To contribute to any AirBnB repo, users will have to:
You're entirely correct that editors on Windows will be perfectly happy to work in LF, but this isn't an editor problem - this is a fundamental conflict with how Git works on Windows. I don't know why ESLint added this feature but imho I agree with @SimenB, the only thing ESLint should be checking for is inconsistent line endings. If I add this feature to ESLint, will you consider using it? Line Ending Purity isn't worth throwing 50%+ of node.js users under the bus. |
Certainly a What I'm suggesting is that every repo on their system, and that they work with, should be using LF, and not CRLF. I agree that it's highly inconvenient that they'd have to re-clone all their repos after setting their systemwide Git settings to What are the arguments (besides "legacy", which carries weight but isn't the best reason to make choices) why any project should ever use CRLF? |
Whether LF or CRLF is philosophically right or not doesn't actually matter, what matters is that this setting system-wide is both non-default (and relatively rare tbh), and will definitely corrupt repos that have CRLF encoded in the repo (also non-default, but far more common, from the last time I ran the statistics on the top 250 C# repos, as part of my work on the Windows GitHub client). So in the very best case scenario, you're asking every Windows user to reclone every repo on their system (and to understand all of these nuances around line endings), and in the worst case, you're encouraging users to set a setting that will corrupt every PR they submit to certain repos. In the meantime, I'm desperately trying to get Windows users to contribute to node.js projects - all I hear from JS maintainers are "Ugh, Windows people never contribute, they just complain". Help me fix that by getting this obstacle out of the way! |
If the "consistent" option were available, I'd be willing to conditionally set it to "unix" or "consistent, unix preferred" based on Do you think that would address the line endings footguns on Windows you're describing, without completely sacrificing the desired guarantees? |
That would do it, yeah - lemme work on an ESLint PR today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reopening this PR - pending an eslint rule change.
@ljharb eslint/eslint#7823 should get us what we need here, then we can write something like: "linebreak-style": ["error", process.platform === "win32" ? "consistent" : "unix"] |
See airbnb/javascript#1224, xojs/eslint-config-xo#35, and eslint/eslint#7823 for the sad details. This doesn't completely solve the greater issue, but should at least help a little bit to ensure new Electron projects can be used on Windows
See airbnb/javascript#1224, xojs/eslint-config-xo#35, and eslint/eslint#7823 for the sad details. This doesn't completely solve the greater issue, but should at least help a little bit to ensure new Electron projects can be used on Windows
I'm not interested in pursuing this further. Thanks all. |
I'm sorry to hear that. I'm going to reopen it, however, since it's still pending an eslint rule change. Feel free to unsubscribe from the thread if you're not interested in further participation. |
I'm not interested in having / starting a flame war, but to anyone who thinks there is no use case for allowing / supporting different EOL encodings, I can tell you that as embedded software engineer I have to work with it all the time as many devices (typically closed-source / black boxes) require it as part of their interface / API (e.g. data sent via USB/serial port or TCP). Just because you have the privilege of working in an environment where you can have control and can make things the way you want does not mean that all developers can or should. Having consistent code standards is great, but if it's taken too far the cost/benefit ratio can explode due to lost productivity dealing with minutia. |
@jacobq Unless you do your typing on those machines, I'm not sure I see the problem - you can always transform your code before you load it onto a device. |
The sanest way I've found to configure projects so that this rule is followed on Windows is: A
which will represent files as LF in the object database and write them with LF on checkout, and A
to cause many editors to initially create files with LF endings. |
An editorconfig is a great idea, as soon as you can hook up a tool that can enforce that the editorconfig doesn't drift - iow, that it matches (or is compatible with) your eslint config, and all your files comply with it. I'm not aware of a reliable one. |
Folks, what’s the status of this? I’d love to see this merged (do tell if I can help in any way!). A lot of projects use the AirBnB config, and it’s very annoying to constantly add |
@iamakulov at the moment, it's blocked by eslint's refusal to allow eslint/eslint#7823 to be merged. |
@ljharb Thanks! While ESLint is blocking this, what if we solve this issue with
? My thinking is as follows:
This would keep the majority of people that use the default settings happy. The power users receiving the error should understand why it’s happening. |
@iamakulov the concern there is then a repo might not add the .gitattributes file in the first place, and conflicts could arise between windows and linux developers using the airbnb config. |
@ljharb Could you elaborate on that please? AFAIK, the repo (not the local checked-out code, but the commits) would always be in LF, so there should be no conflicts. |
I.e.:
Here’s the related piece of docs: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration (Ctrl+F → “core.autocrlf”) So, the repo (as in the commits) are always kept in LF by default, and developers don’t have any Git conflicts. But local files use CRLF on Windows and LF on Unix, and this is what this rule matches:
|
@iamakulov my understanding is that the behavior you're describing only applies if windows users have set up their git properly using autocrlf; the documentation you linked doesn't say what the default is, but I'm relatively sure the motivation for eslint/eslint#7823 was that it's not the default behavior, and that once changed, you have to delete and re-clone any previously cloned repo to fix it. |
Any project that currently uses eslint-config-airbnb checked out on Windows results in thousands of linter errors since the line endings will be CRLF, making it impossible to contribute to these projects as a Windows user without nerfing the linter entirely.
A better way to enforce this is not via a linter, but via a .gitattributes file (https://help.github.com/articles/dealing-with-line-endings). When you do this, Git will ensure the repo internally is LF, but on Win32 will check out files as CRLF (this is a builtin case of a clean/smudge filter)
Refs vercel/hyper#1230, xojs/eslint-config-xo#35