我使用VS Code与漂亮的1.7.2和ESLint 1.7.0。 在每个换行符之后:

[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
  }
}

. pretierrc文件:

{
  "printWidth": 80,
  "tabWidth": 2,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "es5",
  "bracketSpacing": true,
  "jsxBracketSameLine": false,
}

如何消除这个错误?


当前回答

解决方案

1. 禁用自动转换git设置

Git——全局配置核心。autocrlf假

2. 删除旧的缓存数据

Git rm——cached -r。

3.重置git文件

Git重置——很难

其他回答

您需要在.eslintrc文件中添加规则

"extends": ["plugin:prettier/recommended"],
"plugins": ["prettier"],
"rules": {
 "prettier/prettier": ["error"],
 "@typescript-eslint/no-unsafe-call": "off",
 "@typescript-eslint/unbound-method": "off",
 "@typescript-eslint/no-explicit-any": "off",
 "@typescript-eslint/no-unsafe-member-access": "off",
 "@typescript-eslint/no-unsafe-assignment": "off",
 "@typescript-eslint/no-empty-function": "off",
 "@angular-eslint/no-empty-lifecycle-method": "off",
 "@typescript-eslint/no-unused-vars": ["off"],
 "@typescript-eslint/require-await": "off",
 "@typescript-eslint/ban-types": "off"
}

我使用git+vscode+windows+vue,阅读eslint文档后:https://eslint.org/docs/rules/linebreak-style

最后通过以下方法进行修复:

添加*.js文本eol=lf到.gitattributes

然后运行vue-cli-service lint——fix

试试这个。这对我来说很管用:

纱线跑线——固定

or

NPM运行lint -- --fix

正如你所看到的,将此添加到.eslintrc工作!

检查VS Code底部状态栏的右侧,在那里它显示了诸如行和列,空格,文本编码(UTF-8等)等信息。您应该看到一个Select End Of Line Sequence状态显示(LF或CRLF),您可以单击它进行更改。请确保您没有手动更改它,使其与您希望pretty使用的内容冲突。