`styles` prop validation
See original GitHub issueI, with many of us, use your ESLint config preset, which is great. It happens there are rules I don’t like and I override them.
I am not sure about react/forbid-prop-types
rule and its setting, which is following:
'react/forbid-prop-types': ['error', { forbid: ['any', 'array', 'object'] }],
I find it very useful, but hate it when it comes to styles
prop. This is no-go with default preset:
Label.propTypes = {
styles: PropTypes.object.isRequired,
};
To validate (and satisfy ESLint) I have to use shape
validation rule and write down rules for all styles passed by decorator function - repeated work here. Since styles
is defined in very same file and there is very little that could go wrong, I don’t feel like paying special attention to that prop.
How do you validate styles
prop at AirBnb?
Thanks for answer!
Okay, to be honest I often abuse vague shape
validator function, without specifying actual shape of styles
prop.
Label.propTypes = {
styles: PropTypes.shape().isRequired,
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:12
Top GitHub Comments
Actually this is now done;
import { withStylesPropTypes } from 'react-with-styles'
- now you never need to (nor should) explicitly specify thestyles
ortheme
props in your code.Will take a look into this. Are you open to PRs?