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

如何消除这个错误?


当前回答

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

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

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

其他回答

NPM运行lint -- --fix

运行这个命令,这对我有用

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

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

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

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

我在我的nest js应用程序中也有同样的问题。将下面的代码添加到.eslintrc.jsrules中,然后运行yarn run lint——fix修复了这个问题。

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

我的.eslintrc.js规则看起来是这样的。

 rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': [
  'error',
  {
    endOfLine: 'auto',
  },
],

},

您需要在.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"
}

在.eslintrc文件中添加以下内容:

Extends: ['prettier']和plugins: ['prettier'] 规则:{'更漂亮/更漂亮':['错误',{endoline: 'auto'}]}

在. pretierrc中删除:

endOfLine:’auto’

这对我很管用。