Skip to content

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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,7 @@ module.exports = {
* @param {string} the identifier to strip
*/
function stripQuotes(string) {
if (string[0] === '\'' || string[0] === '"' && string[0] === string[string.length - 1]) {
return string.slice(1, string.length - 1);
}
return string;
return string.replace(/^\'|\'$/g, '');
}

/**
Expand Down
5 changes: 1 addition & 4 deletions lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,7 @@ module.exports = {
* @param {string} the identifier to strip
*/
function stripQuotes(string) {
Copy link
Member

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?

Copy link
Contributor Author

@jseminck jseminck Aug 23, 2017

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 and no-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 for no-unused-prop-types.

I'll try to deal with extracting as much of the shared logic as possible this weekend. Created an issue: #1393

if (string[0] === '\'' || string[0] === '"' && string[0] === string[string.length - 1]) {
return string.slice(1, string.length - 1);
}
return string;
return string.replace(/^\'|\'$/g, '');
}

/**
Expand Down