我使用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,
}

如何消除这个错误?


当前回答

修正-我的.eslintrc.js看起来像这样:

module.exports = {
  root: true,
  extends: '@react-native-community',
  rules: {'prettier/prettier': ['error', {endOfLine: 'auto'}]},
};

其他回答

上面所有的答案都是正确的,但当我使用窗口并禁用更漂亮的ESLint扩展投资。Vs-code-prettier-eslint的问题将被修复。

执行eslint进行检测和修复解决了我的问题。

eslint。, ext .vue . js .jsx、.cjs .mjs, .ts, .tsx .cts,。MTS—fix—ignore-path .gitignore

或者如果你有lint脚本:NPM运行lint

从. pretierrc文件中删除这一行

 "endOfLine": "crlf"

对我有用的是:

按照Roberto LL的建议,更新到2.2.1版本(目前的最新版本)。要执行它

NPM更新更漂亮

按照Hakan的建议执行lint修复(这将修改项目中的所有文件,将行结束转换为LF)。

NPM运行lint -- --fix

没有必要更改.eslintrc和.prettierrc文件!

修正-我的.eslintrc.js看起来像这样:

module.exports = {
  root: true,
  extends: '@react-native-community',
  rules: {'prettier/prettier': ['error', {endOfLine: 'auto'}]},
};