简体   繁体   中英

Eslint error: Value [{"disallowRedundantWrapping":true}] should NOT have more than 0 items

I'm coding on a small personal project to develop my skills in React and I'm having a lot of issues with eslint and prettier to the point that half my time on the project I'm looking at eslint stuff because it stops auto formatting my code. Usually I can solve the problem, but this time I didn't. I'm getting this: Value [{"disallowRedundantWrapping":true}] should NOT have more than 0 items . I'm not really sure why, I don't even have this rule in my eslint configuration file.

The full error I get from VS Code is this

[Error - 6:30:09 PM] Request textDocument/formatting failed.
  Message: Request textDocument/formatting failed with message: .eslintrc.json » eslint-config-airbnb » /media/{my_path_here}/node_modules/eslint-config-airbnb-base/index.js » /media/{my_path}/node_modules/eslint-config-airbnb-base/rules/best-practices.js:
    Configuration for rule "prefer-regex-literals" is invalid:
    Value [{"disallowRedundantWrapping":true}] should NOT have more than 0 items.

  Code: -32603 

my eslint file:

  "env": {
    "browser": true,
    "es2020": true
  },
  "extends": ["plugin:react/recommended", "airbnb"],
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "sourceType": "module"
  },
  "plugins": ["react", "react-hooks"],
  "rules": {
    "indent": ["error", 2],
    "linebreak-style": 0,
    "quotes": ["error", "single"],
    "semi": ["error", "always"],
    "complexity": ["off", 11],
    "jsx-a11y/label-has-associated-control": "off",
    "jsx-a11y/label-has-for": "off",
    "no-magic-numbers": [
      "error",
      {
        "ignore": [0, 1],
        "ignoreArrayIndexes": true,
        "enforceConst": true,
        "detectObjects": false
      }
    ],
    "react/jsx-curly-spacing": [
      2,
      { "when": "always", "allowMultiline": false }
    ],
    "arrow-parens": [2, "always"],
    "class-methods-use-this": ["off"],
    "react/button-has-type": [
      "error",
      {
        "button": true,
        "submit": true,
        "reset": true
      }
    ],
    "no-console": ["off"],
    "no-underscore-dangle": ["off"],
    "no-param-reassign": ["off"],
    "consistent-return": ["off"],
    "no-undef": ["off"],
    "max-len": [
      "error",
      {
        "code": 90,
        "ignoreComments": true,
        "ignoreUrls": true
      }
    ],
    "object-curly-newline": ["off"],
    "import/no-extraneous-dependencies": ["off"],
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
    "react/default-props-match-prop-types": [
      "error",
      { "allowRequiredDefaults": false }
    ],
    "react/no-array-index-key": ["off"],
    "react/destructuring-assignment": ["error", "always"],
    "react/forbid-component-props": ["error"],
    "react/forbid-prop-types": ["error"],
    "react/no-did-mount-set-state": ["error"],
    "react/no-did-update-set-state": ["error"],
    "react/jsx-props-no-spreading": ["off"],
    "react/no-multi-comp": ["error", { "ignoreStateless": false }],
    "react/prefer-stateless-function": ["off"],
    "react/no-access-state-in-setstate": ["error"],
    "react/no-redundant-should-component-update": ["error"],
    "react/no-this-in-sfc": ["error"],
    "react/no-typos": ["error"],
    "react/no-unsafe": ["error"],
    "react/no-unused-state": ["error"],
    "react/no-will-update-set-state": ["error"],
    "react/prefer-es6-class": ["error", "always"],
    "react/self-closing-comp": ["error"],
    "react/state-in-constructor": ["error", "always"],
    "react/void-dom-elements-no-children": ["error"],
    "react/jsx-closing-bracket-location": ["error"],
    "react/jsx-closing-tag-location": ["error"],
    "react/jsx-curly-newline": ["error"],
    "react/jsx-fragments": ["error"],
    "react/jsx-max-depth": ["error", { "max": 8 }],
    "react/jsx-no-useless-fragment": ["error"],
    "react/jsx-equals-spacing": ["error", "never"],
    "react/jsx-first-prop-new-line": ["error", "multiline"],
    "react/jsx-indent": [
      "error",
      2,
      { "checkAttributes": true, "indentLogicalExpressions": true }
    ],
    "react/jsx-indent-props": ["error", 2],
    "react/jsx-key": ["error"],
    "react/jsx-max-props-per-line": [
      "error",
      { "maximum": 1, "when": "multiline" }
    ],
    "react/jsx-tag-spacing": [
      "error",
      {
        "closingSlash": "never",
        "beforeSelfClosing": "always",
        "afterOpening": "never",
        "beforeClosing": "never"
      }
    ],
    "react/jsx-wrap-multilines": [
      "error",
      {
        "declaration": "parens",
        "assignment": "parens",
        "return": "parens",
        "arrow": "parens",
        "condition": "ignore",
        "logical": "ignore",
        "prop": "ignore"
      }
    ],
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": 0,
    "react/function-component-definition": [
      2,
      {
        "namedComponents": "arrow-function",
        "unnamedComponents": "arrow-function"
      }
    ],
    "prefer-regex-literals": ["error", { "disallowRedundantWrapping": false }]
  }
}```

I've tried to turn this rule off as shown on the last line above, but it didn't work. Can you help me?

edit: remove out of context sentence

A GitHub issue in the airbnb repositories suggests that this error can come from having an old version of ESLint installed globally. That could be the case for you as well?

https://github.com/airbnb/javascript/issues/2521

I am also seeing this issue due to what I have tracked down to be the gulp-eslint package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM