10

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
Leinil
  • 113
  • 1
  • 6

2 Answers2

4

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.

Walliski
  • 55
  • 7
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 03 '21 at 10:57
  • Thanks for the answer @Walliski! I think I did have Eslint installed globally. However, the following command didn't work for me: npm set-script lint "eslint .". It seems there's something wrong, npm doesn't recognize this. – Leinil Dec 07 '21 at 19:00
  • I had this problem, and fixed mine by changing the package version resolution of `@eslint/eslintrc` to a lower version (1.0.5) than it was naturally resolving to (had to specify this in `resolutions` because it was a peer dependency from another package) – Geoff Davids Aug 23 '22 at 15:31
0

Make sure that u have configured the schema property in meta of that rule.

Refer this documentation to know about schema options https://eslint.org/docs/latest/extend/custom-rules#options-schemas

This fixed my problem which the same u had!!

Praveen V
  • 1
  • 1