Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Investigate usage of 'react/require-default-props' & 'react/default-props-match-prop-types' #2194

Open
jackcmeyer opened this issue Jun 30, 2020 · 5 comments
Assignees
Labels
ci/cd in progress indicates that issue/pull request is currently being worked on
Projects
Milestone

Comments

@jackcmeyer
Copy link
Member

Recently, the following was added to the .eslintrc.js file to warn about new linting rules.

    'react/require-default-props': ['warn'],
    'react/default-props-match-prop-types': ['warn']

It seems like these should be errors, however, more research should be done. This issue is to investigate the new rules.

If the rules should be errors, then this issue will require code changes to conform to the new lint rules.

If the rules should be turned off, then only configuration changes will be necessary.

@jackcmeyer jackcmeyer added help wanted indicates that an issue is open for contributions ci/cd labels Jun 30, 2020
@jackcmeyer jackcmeyer added this to the v2.0 milestone Jun 30, 2020
@jackcmeyer jackcmeyer added this to To do in Version 2.0 via automation Jun 30, 2020
@matteovivona
Copy link
Contributor

Link FE-494

@YimniChan
Copy link

Could I get assign to work on this?

@jackcmeyer
Copy link
Member Author

@YimniChan I've assigned this to you.

@jackcmeyer jackcmeyer added in progress indicates that issue/pull request is currently being worked on and removed help wanted indicates that an issue is open for contributions labels Jul 8, 2020
@YimniChan
Copy link

YimniChan commented Jul 20, 2020

The react/require-default-props rule should be an error.
If we do not set any default props, the undefined display should take place of the props that are not sent by the parent component. In execution, an undefined variable may cause the application to break if it is used and there are no safety precautions in place. We do not want that to occur. Furthermore, we should set a defaultProps value, and when a prop is missing, the defaultProps value will replace the undefined.

The react/default-props-match-prop-types rule should be turned off.
In the naming convention used in code, variable names usually have the same name as its props variable, even if they are not in the same file. PropTypes exports are for validating the data type is match and valid. Look like the default-props-match-prop-types is a kind of fixed shape. It seems not necessary in this case. Furthermore, projects have interfaces that provide the benefit of type-checking values shape. The props that are passed around normally follow interface rules. Interface set or applies the requirement properties and their type. When we try to use the properties for the variable, the system just checks did the object we pass to the function meets the requirements listed. The interface can be extended and changed to fit the need of the application, Prop types of the default drop might be changing while calling by different functions.

@matteovivona
Copy link
Contributor

@fox1t

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ci/cd in progress indicates that issue/pull request is currently being worked on
Projects
Version 2.0
  
To do
Development

No branches or pull requests

3 participants