Eslint-plugin-react: require-default-props does not detect properties in quotes

Created on 17 May 2017  路  2Comments  路  Source: yannickcr/eslint-plugin-react

Hi,

I've got an issue with code like this

DueEntryComponent.propTypes = {
    "isOverdue": PropTypes.bool
};

DueEntryComponent.defaultProps = {
    "isOverdue": false
};

triggers the message:

propType "isOverdue" is not required, but has no corresponding defaultProp declaration. (react/require-default-props)

changing the declaration to

DueEntryComponent.defaultProps = {
    isOverdue: false
};

omits the error.

I don't think quotes should have an effect on detecting defaultProps. Maybe I'm wrong ;-)

bug help wanted

Most helpful comment

Fixed it for quoted properties. I will add template literal support in another patch.

All 2 comments

While unnecessarily quoted keys isn't my preferred style, I agree this should work. I think it should also work as a computed template literal with no interpolations.

Fixed it for quoted properties. I will add template literal support in another patch.

Was this page helpful?
0 / 5 - 0 ratings