Victoria Diro
Victoria Diro

Reputation: 183

Disable in EsLint "react / jsx-props-no-spreading" error in Reactjs

After installing EsLint one of the errors that appears to me is the following:

Prop spreading is forbiddeneslint(react/jsx-props-no-spreading)

I want to create a rule in the EsLint configuration to ignore this error but the examples I found do not work.

This is the format to create a global exception:

...
"react/jsx-props-no-spreading": [{
    "html": "ignore" / "enforce",
    "custom": "ignore" / "enforce",
    "exceptions": [<string>]
}]
...

And this is the format to create an exception in a specific file:

{
  "rules": {...},
  "overrides": [
    {
      "files": ["*-test.js","*.spec.js"],
      "rules": {
        "no-unused-expressions": "off"
      }
    }
  ]
}

And here, the code that I currently have:

module.exports = {
  extends: "../../.eslintrc.js",
  rules: {
    "import/no-extraneous-dependencies": ["error",  {"devDependencies": true}]
  },
  env: {
    "jest": true
  }
};

At the moment, I just keep giving the same error continuously.

Thank you.

Upvotes: 17

Views: 44654

Answers (2)

Sabit Rakhim
Sabit Rakhim

Reputation: 458

As an example if there is not so much errors you can ignore them by // eslint-disable-next-line

Or you can write for concrete error like

// eslint-disable jsx-props-no-spreading

Upvotes: 5

uneet7
uneet7

Reputation: 3075

Try turning off the "react/jsx-props-no-spreading" rule:

module.exports = {
  extends: "../../.eslintrc.js",
  rules: {
    "import/no-extraneous-dependencies": ["error",  {"devDependencies": true}],
    "react/jsx-props-no-spreading": "off",
  },
  env: {
    "jest": true
  }
};

Upvotes: 48

Related Questions