-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default-props-match-prop-types not working with flow #1593
Comments
hmm - in flow, do you just use default arguments? This rule isn't actually checking types; it's just checking that |
I know that it is not about checking types, I actually want what you've described, but instead of checking if there is a matching entry in type Props = {
size: number,
value: Point,
active: boolean,
onClick?: (value: Point) => void,
arrowDirection?: 'left' | 'top-left' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left',
};
export default class ImageFocusPointCell extends React.PureComponent<Props> {
static defaultProps = {
active: false,
showArrow: true,
};
// other code not important for this rule
} The |
Gotcha. That seems like a reasonable enhancement for this rule. |
@PoliakovMaksym the stateful component error seems correct to me; you're not using anything there that requires it be stateful. |
@ljharb the issue is not with the |
gotcha, thanks for clarifying. |
what's the status of this issue? |
Is there any progress on this? We use this quite extensively in our projects. |
Any updates? This would really help us. Thanks. |
it would be really nice to have this feature. thanks ;) |
may i ask how everyone is getting around this issue? Are you guys still using flow for stateless components? |
Still no movement here? |
The status of this issue is that it's labeled "help wanted", and nobody has submitted a PR for it yet. For all those folks that'd like to see this land, please feel free to take a crack at fixing it :-) The maintainers of this project are humans and do not have infinite time at their disposal. |
@ritchieanesco I just disable that eslint rule 🤣 |
You could just use this configuration for rule: This will allow you to have defaultProps for not optional (required) props without warning and also this will work fine with flow, because for flow prop which has corresponding default prop is not optional prop. |
One note on the suggestion by @Elf2707 - that appears to work so long as your flow types are in the same file as your component; it does not appear to work if you have flow PropType in another file (like a |
works in most cases for me, but it doesn't expand type spreads, e.g.
eslint produces the following error:
|
@kevinbarabash your code example doesn't parse in babel-eslint; but when i fix the invalid |
We are using flow in our project, also for typing the properties. And it seems as if the default-props-match-prop-types rule doesn't recognize flow types. Is that possible? Is that something that could be easily implemented?
The text was updated successfully, but these errors were encountered: