Why do I keep getting Delete 'cr' [prettier/prettier]?

笑着哭i 提交于 2019-12-04 08:05:05

问题


I am using vscode with Prettier 1.7.2 and Eslint 1.7.0. After every newline I get:

[eslint] Delete 'cr' [prettier/prettier]

This is the .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,
}

How can I get rid of this error?


回答1:


Try setting the "endOfLine":"auto" in your .prettierrc file (inside the object)

Or set

"prettier/prettier": ["error", {
     ..
    "endOfLine":"auto"
     ..
  }],

inside the rules object of the eslintrc file.

If you are using windows machine endOfLine can be "crlf" basing on your git config.




回答2:


change this setting on VSCode.




回答3:


I am using git+vscode+windows+vue, and after read the eslint document: https://eslint.org/docs/rules/linebreak-style

Finally fix it by:

add *.js text eol=lf to .gitattributes

then run vue-cli-service lint --fix



来源:https://stackoverflow.com/questions/53516594/why-do-i-keep-getting-delete-cr-prettier-prettier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!