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
fix: support union type in React react-only props rule #477
Merged
gajus
merged 1 commit into
gajus:master
from
mrtnzlml:react_react_only_props_union_type
Apr 16, 2021
Merged
fix: support union type in React react-only props rule #477
gajus
merged 1 commit into
gajus:master
from
mrtnzlml:react_react_only_props_union_type
Apr 16, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change fixes the following (simplified) example from our application: ``` type Props = | { +children: React$Node, +title: React$Node, +withHiddenTitle?: false, } | { +children: React$Node, +title?: React$Node, +withHiddenTitle: true, }; const props: Props = {children:"", withHiddenTitle: true} props.title = ""; // correct Flow error ``` Flow correctly throws the following error: ``` 14: props.title = ""; ^ Cannot assign empty string to `props.title` because property `title` is not writable. [cannot-write] ``` However, `flowtype/require-readonly-react-props` Eslint rule throws the following (incorrect) error: ``` Props must be $ReadOnly ``` For simplification, all of the objects in the union must be readonly even though it's probably not a strict requirement in Flow. This can be improved later when needed.
🎉 This PR is included in version 5.7.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
mrtnzlml
added a commit
to adeira/universe
that referenced
this pull request
Apr 16, 2021
This release includes some fixes for our codebase, see: - gajus/eslint-plugin-flowtype#477 - gajus/eslint-plugin-flowtype#478
kodiakhq bot
pushed a commit
to adeira/universe
that referenced
this pull request
Apr 17, 2021
This release includes some fixes for our codebase, see: - gajus/eslint-plugin-flowtype#477 - gajus/eslint-plugin-flowtype#478
adeira-github-bot
pushed a commit
to adeira/eslint-config-adeira
that referenced
this pull request
Apr 17, 2021
This release includes some fixes for our codebase, see: - gajus/eslint-plugin-flowtype#477 - gajus/eslint-plugin-flowtype#478 adeira-source-id: a16fb4f4e7da1a952452a75cb4c4cc58f92e69bf
adeira-github-bot
pushed a commit
to adeira/sx-design
that referenced
this pull request
Apr 17, 2021
This release includes some fixes for our codebase, see: - gajus/eslint-plugin-flowtype#477 - gajus/eslint-plugin-flowtype#478 adeira-source-id: a16fb4f4e7da1a952452a75cb4c4cc58f92e69bf
mrtnzlml
added a commit
to mrtnzlml-archive/kochka.com.mx
that referenced
this pull request
May 4, 2021
This release includes some fixes for our codebase, see: - gajus/eslint-plugin-flowtype#477 - gajus/eslint-plugin-flowtype#478 adeira-source-id: a16fb4f4e7da1a952452a75cb4c4cc58f92e69bf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change fixes the following (simplified) example from our application:
Flow correctly throws the following error:
However,
flowtype/require-readonly-react-props
Eslint rule throws the following (incorrect) error:For simplification, all of the objects in the union must be readonly even though it's probably not a strict requirement in Flow. This can be improved later when needed.