4

I am currently trying to standardize my line endings to LF, whilst working in Windows. I have eslint and prettier set up in my project. These extensions are enforcing the consistent line endings in all files. However, when I save a particular file, that file gets changed to CRLF for some reason. Here is a gif demonstrating the issue:

Saving in VSCode

I have added the option "files.eol": "\n" to my settings.json, as some other posts suggested. But it still doesn't work. Here is my entire settings.json if it helps.

{
    "editor.suggestSelection": "first",
    "workbench.colorTheme": "Dracula",
    "workbench.iconTheme": "material-icon-theme",
    "editor.fontFamily": "Fira Code",
    "editor.fontLigatures": true,
    "editor.fontSize": 14,
    "editor.rulers": [80, 120],
    "editor.renderLineHighlight": "gutter",
    "editor.tabSize": 2,
    "terminal.integrated.fontSize": 14,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    },
    "emmet.syntaxProfiles": {
        "javascript": "jsx"
    },
    "editor.parameterHints.enabled": true,
    "breadcrumbs.enabled": true,
    "javascript.suggest.autoImports": false,

    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },

    "files.associations": {
        ".sequelizerc": "javascript",
        ".stylelintrc": "json",
        ".prettierrc": "json",
        "*.pl": "prolog"
    },

    "[dart]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
        "editor.rulers": [
            80
        ],
        "editor.selectionHighlight": false,
        "editor.suggest.snippetsPreventQuickSuggestions": false,
        "editor.suggestSelection": "first",
        "editor.tabCompletion": "onlySnippets",
        "editor.wordBasedSuggestions": false
    },
    "dart.openDevTools": "flutter",
    "window.zoomLevel": 1,
    "files.eol": "\n"
}

Thank you in advance for any help provided. :)

David Jentjens
  • 567
  • 7
  • 18
  • 1
    https://prettier.io/docs/en/options.html#end-of-line – Lance Sep 22 '21 at 19:24
  • My prettier already has endOfLine defined as "lf". – David Jentjens Sep 26 '21 at 23:25
  • In my case, it was an `.editorconfig` file in the project overriding VS Code's settings. I'm not sure if this should be an answer instead of a comment, to be honest. – Charmander Mar 22 '22 at 11:14
  • What about the previous comment? Do you have a `.editorconfig` file? ~ * ~ If not, check [this answer](https://stackoverflow.com/a/73698638). – Henke Oct 04 '22 at 11:38

0 Answers0