question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

endOfLine changed from auto to LF in v2.0.0 doesn't take effect

See original GitHub issue

Summary

Line endings was changed from auto to LF in prettier v2.0.0. However this doesn’t change CRLF files to LF when formatting.

Github Repository to Reproduce Issue

Any CRLF file prettier supports will do

Steps To Reproduce:

Use prettier v2 default config

  1. Open a CRLF file (ie .ts) that is otherwise correctly formatted
  2. Observe that vscode doesn’t report line ending errors
  3. Open command pallet and run “Format document with…” select “prettier”
  4. Observe that line endings are still CRLF and prettier still doesn’t report errors

Expected result

Prettier should report line ending errors. Prettier should change line endings to LF on format.

Actual result

Line endings are still CRLF after formatting.

Additional information

VS Code Version: 1.44.1

Prettier Extension Version: 4.4.0

OS and version: Windows 1909

.prettierrc

{
  "singleQuote": true,
  "printWidth": 200
}

.editorconfig

# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false

Prettier Log Output

["INFO" - 02.27.47] Formatting ~\Repos\akita\libs\akita\src\lib\updateEntities.ts
["INFO" - 02.27.47] Using ignore file (if present) at ~\Repos\akita\.prettierignore
["INFO" - 02.27.47] Loaded module 'prettier@2.0.4' from '~\Repos\akita\node_modules\prettier\index.js'
["INFO" - 02.27.47] File Info:
{
  "ignored": false,
  "inferredParser": "typescript"
}
["INFO" - 02.27.47] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 02.27.47] Prettier Options:
{
  "filepath": "~\\Repos\\akita\\libs\\akita\\src\\lib\\updateEntities.ts",
  "parser": "typescript",
  "useTabs": false,
  "tabWidth": 2,
  "singleQuote": true,
  "printWidth": 200
}
["INFO" - 02.27.47] Formatting completed in 26.475699ms.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
vasilii-kovalevcommented, Oct 31, 2020

It seems that even "endOfLine": "lf" doesn’t work in VS Code automatically (without running Prettier via CLI).

6reactions
xulonccommented, Apr 15, 2021

add .editorconfig file can work image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I keep getting "[eslint] Delete `CR` [prettier/prettier]"?
If you do not make any changes to the file, eslint delete CR by pre-commit since git automatically convert CRLF to LF ....
Read more >
No option to specify end of line (EOL) to be LF rather than CRLF
Almost everything has an option to specify which line endings to use, but Visual Studio does not. vscode added this option about a...
Read more >
Options - Prettier
Prettier's printWidth option does not work the same way. ... End of Line. First available in v1.15.0, default value changed from auto to...
Read more >
Introducing extended line endings support in Notepad
May 8th, 20185 0. For many years, Windows Notepad only supported text documents containing Windows End of Line (EOL) characters – Carriage Return...
Read more >
How to Get Consistent Line Breaks in vs Code (LF vs CRLF)
Unix systems like Linux and macOS use LF , the line feed character, ... Unless you work on a Windows-only team, the answer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found