-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Support read-only props in Flow for no-unused-prop-types #1390
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
Merged
yannickcr
merged 6 commits into
jsx-eslint:master
from
jseminck:no-unused-prop-types-flow-read-only-v2
Sep 5, 2017
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
217d33e
Add support for prefixes in flow prop-types
jseminck cf5e8a3
Use the same logic for determinign the key between prop-types and no-…
jseminck c7c7191
Move stripQuotes logic to no-unused-prop-types as well and add a test…
jseminck 2fcba06
indexOf instead of includes
jseminck 7f1c9b3
use regex for stripping quotes
jseminck 44f03b7
Explicitely check for + and - prefixes
jseminck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2032,27 +2032,50 @@ ruleTester.run('no-unused-prop-types', rule, { | |
}, { | ||
// issue #106 | ||
code: ` | ||
import React from 'react'; | ||
import SharedPropTypes from './SharedPropTypes'; | ||
import React from 'react'; | ||
import SharedPropTypes from './SharedPropTypes'; | ||
|
||
export default class A extends React.Component { | ||
render() { | ||
return ( | ||
<span | ||
a={this.props.a} | ||
b={this.props.b} | ||
c={this.props.c}> | ||
{this.props.children} | ||
</span> | ||
); | ||
export default class A extends React.Component { | ||
render() { | ||
return ( | ||
<span | ||
a={this.props.a} | ||
b={this.props.b} | ||
c={this.props.c}> | ||
{this.props.children} | ||
</span> | ||
); | ||
} | ||
} | ||
} | ||
|
||
A.propTypes = { | ||
a: React.PropTypes.string, | ||
...SharedPropTypes // eslint-disable-line object-shorthand | ||
}; | ||
`, | ||
A.propTypes = { | ||
a: React.PropTypes.string, | ||
...SharedPropTypes // eslint-disable-line object-shorthand | ||
}; | ||
`, | ||
parser: 'babel-eslint' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reformatted this test - that's why it's in the PR... |
||
}, { | ||
// issue #933 | ||
code: ` | ||
type Props = { | ||
+foo: number | ||
} | ||
class MyComponent extends React.Component { | ||
render() { | ||
return <div>{this.props.foo}</div> | ||
} | ||
} | ||
`, | ||
parser: 'babel-eslint' | ||
}, { | ||
code: ` | ||
type Props = { | ||
\'completed?\': boolean, | ||
}; | ||
const Hello = (props: Props): React.Element => { | ||
return <div>{props[\'completed?\']}</div>; | ||
} | ||
`, | ||
parser: 'babel-eslint' | ||
} | ||
], | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this repeated function be extracted out into a shared file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - that's what I mentioned in the other PR:
prop-types
andno-unused-prop-types
on first sight seem to share quite a bit of logic that deals with extracting the declared prop types for a component. And currently, the logic is not in sync (e.g. props in TypedArgument for Flow is not supported at all forno-unused-prop-types
.I'll try to deal with extracting as much of the shared logic as possible this weekend. Created an issue: #1393