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.
The warning "Props spreading is forbidden" is caused when we use the spread syntax to unpack a props object when passing props to a component. To get around the warning, disable the eslint rule.
To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console. /* eslint-disable */ console.
If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.
disable warnings eslint Use /* eslint-disable */ to ignore all warnings in a file. You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file.
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
}
};
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With