我在Prettier 1.7.2和Eslint 1.7.0中使用vscode。在我得到的每一个换行符之后:
[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
}
}
The .prettierrc
文件:
{
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
}
我怎样才能摆脱这个错误呢?
发布于 2018-12-14 03:57:10
尝试设置"endOfLine":"auto"
在.prettierrc文件中(在对象内部)
或设置
"prettier/prettier": ["error", {
..
"endOfLine":"auto"
..
}],
在eslintrc文件的rules对象中。
如果你使用的是windows机器,根据你的git配置,endOfLine可以是"crlf“。
发布于 2019-01-16 11:19:21
在VSCode上更改此设置。
发布于 2020-08-30 14:21:41
在我的windows机器中,我通过添加下面的代码片段解决了这个问题。rules
对象.eslintrc.js
文件存在于我当前项目的目录中。
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
},
],
这在我的Mac上也能用
https://stackoverflow.com/questions/53516594
复制相似问题