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

如何消除这个错误?


当前回答

错误出现时,我拉代码从git,这为我工作:

步骤1:

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

步骤2:

删除当前文件夹

步骤3:

再次从git中提取代码 尝试再次运行命令

其他回答

如果你需要使用.prettierrc.js:

module.exports = {
    ...[config params],
    endOfLine: 'auto',
};

注意!不是在规则或更漂亮。

信息在这里https://prettier.io/docs/en/options.html#end-of-line

编辑.eslintrc.json文件并更新如下所示的"prettier/prettier"值。

我也面临同样的问题,并修改了使用下面的更改。

"prettier/prettier": [
    "error", {
         "singleQuote": true,
         "parser": "flow" 
    }
],

在我的情况下,我使用windows操作系统和git代码支持Mac和转换为CRLF 在cmd提示符下运行命令停止文件转换为CRLF:

git config --global core.autocrlf input

再次签出代码并再次打开Visual Studio code并再次运行脚本。这对我很管用。

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

纱线跑线——固定

or

NPM运行lint -- --fix

如果您已经签出了代码

git config --global core.autocrlf input 


git rm --cached -r . 


git reset --hard