When Prettier is used in conjunction with ESLint, ESlint detects the crlf and cr differences between the code runtime and the project creator to the point where all ends of lines errors are reported.

Reason

For historical reasons, windows and linux have different line feeds for text files.

  • Windows uses both the carriage-return character (CR) and the linefeed character (LF) for line breaks.
  • Mac and Linux use only the linefeed character (LF).
  • Older Macs use a carriage return (CR).

But Git in windows environment, by default, will automatically converted the pull-downed code line breaks to CRLF, which leads to prettier’s error.

Solution

  1. This can be solved by modifying the git configuration and then pulling it again.
git config --global core.autocrlf false 
  1. Edit prettier/prettier rules in .eslintrc.js and restart
"prettier/prettier": [
    "error",
    {
        "endOfLine": "auto"
    },
],
 

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

Table of Contents

Catalogue