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

如何消除这个错误?


当前回答

没有必要忽视林特法则。只需要自动修复

npm install -g prettier
prettier -w .\webpack.config.js # or other file

其他回答

对我有用的是:

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

NPM更新更漂亮

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

NPM运行lint -- --fix

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

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

步骤1:

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

步骤2:

删除当前文件夹

步骤3:

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

我在这里尝试了所有的东西,对我来说,我需要管理更漂亮的配置扩展通过图标扩展>更漂亮>小引擎>扩展设置>更漂亮:结束>设置为自动。

在我的settings.json中添加这两行之后

"eslint.run": "onSave",
"editor.formatOnSave": true,

我可以在.eslintrc.js规则中使用下面的配置。

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

在.eslintrc文件中添加以下规则,然后重新启动项目。

rules: {
    'prettier/prettier': ['error', { "endOfLine": "auto"}, { usePrettierrc: true }],  
}

对于那些使用@vue/prettier的人来说,它和eslint之间可能存在冲突,从而导致此错误。尽管@vue/prettier是与vue cli一起安装的,但它只是一个临时解决方案,直到prettier原生地接受vue,而这已经完成了。问题可以通过“更漂亮”来解决。