我正在將 VS Code 與 Prettier 1.7.2 和 ESLint 1.7.0 結(jié)合使用。 在每個(gè)換行之后我得到:
[eslint] Delete `CR` [prettier/prettier]
這是 .eslintrc.json
:
{ "extends": ["airbnb", "plugin:prettier/recommended"], "env": { "jest": true, "browser": true }, "rules": { "import/no-extraneous-dependencies": "off", "import/prefer-default-export": "off", "no-confusing-arrow": "off", "linebreak-style": "off", "arrow-parens": ["error", "as-needed"], "comma-dangle": [ "error", { "arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "ignore" } ], "no-plusplus": "off" }, "parser": "babel-eslint", "plugins": ["react"], "globals": { "browser": true, "$": true, "before": true, "document": true } }
.prettierrc
文件:
{ "printWidth": 80, "tabWidth": 2, "semi": true, "singleQuote": true, "trailingComma": "es5", "bracketSpacing": true, "jsxBracketSameLine": false, }
如何消除這個(gè)錯(cuò)誤?
嘗試在 .prettierrc(或 .prettierrc.json)文件(對(duì)象內(nèi)部)中設(shè)置 "endOfLine":"auto"
或者設(shè)置
"prettier/prettier": [ "error", { "endOfLine": "auto" } ]
在 eslintrc 文件的 rules
對(duì)象內(nèi)。
如果您使用的是 Windows 機(jī)器,endOfLine
可以根據(jù)您的 git 配置為“crlf”。