-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
verifyTypeScriptSetup.js writes mixed line endings into tsconfig.json #6566
Comments
If anybody from the
|
I think |
@ianschmitz I believe that A PR for that and then (if I or someone else cares enough) a separate Issue and discussion as to whether or not it's worth doing anything at all about the small class of Windows users who have Git set to check out Unix linefeeds, would make sense. |
Dear Ian, I've put up a PR as requested, I'd obviously be happy to change it to use the more defensive coding you've suggested, if you'd all prefer.
|
Just wanted to leave a note that the fix as applied works for users using native linefeeds (i.e. most people!), so many thanks! But still won't work for users using Unix linefeeds on Windows (or any other weird combination, but this is probably much the most likely one, and is even the recommended setting by eslint!). |
In verifyTypeScriptSetup.js:
the code uses a combination of
JSON.stringify
andos.EOL
- however JSON.stringify is specified to (and does) always use0x000A
as its linefeed, even on Windows.The net result is that after building a
create-react-app
project on Windows, thentsconfig.json
contains LFs all down the file until the last line, which is CRLF, as shown here:verifyTypeScriptSetup.js
rewrites this file on Windowstsconfig.json
ends up with linebreaks as shown above regardless of whether it was initially pure LF or initially pure CRLFIt is possible to achieve (what seems to be fairly evidently) the intent of the code by replacing all LF characters in the
JSON.stringify
output withos.EOL
as follows:NB Even this is NOT necessarily what the user actually wants (for a Windows user, it depends on whether they are working with Windows linefeeds, or perhaps in Unix linefeeds because it is a cross-platform project).
I'd be happy to do a PR, but suspect there may well be other places where this approach is used, and also note that there are two other uses of
os.EOL
in the same file (which again may or may not be what the user really wants for the reason just mentioned).The text was updated successfully, but these errors were encountered: