neoclide/coc-prettier

No reaction to endOfLine settings

kaykhancheckpoint opened this issue · 1 comments

Hi friends, i am having an issue in vim in which prettier asks me to delete the extra/empty line at the end of a file, however vscode correctly enforces the need for an empty line at the end of a file.

To be clear im on linux and i do prefer my files to have an empty ending line at the bottom of the file.

coc-settings.json

{ 
    "coc.preferences.formatOnSaveFiletypes": ["javascript", "typescript", "python"],
    "prettier.requireConfig": true
}

.prettierrc

{
    "semi": true,
    "tabWidth": 4,
    "endOfLine": "auto"
}

.eslintrc.json

{
    "env": {
        "browser": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "prettier",
        "plugin:prettier/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
        "@typescript-eslint/no-explicit-any": "off",
        "@typescript-eslint/explicit-module-boundary-types": "off",
        "@typescript-eslint/no-unused-vars": "off",
        "no-useless-catch": "off",
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "double"
        ],
        "semi": [
            "error",
            "always"
        ],
        "prettier/prettier": [
            "error",
            { "endOfLine": "auto" }
        ]
    }
}

vim

image

vscode

image

vscode has it correct in this case, what is happening with vim?

Unlike vscode, vim doesn't show the last end of line, when you have extra empty line at the end, it means you will have \n\n at the end of file (when you have eol option enabled).