What is the problem with the propTypes object, string and array which makes eslint to have this rule: react/forbid-prop-types?

Reacting

I've been programming on React for about a year and I always see this react/forbid-prop-types coming, so I have this rule out: // eslint-disable-next-line react/forbid-prop-types, like:

SigninSubmitButton.propTypes = {
  signInAsync: PropTypes.func.isRequired,
  disabledProp: PropTypes.oneOfType([PropTypes.bool, PropTypes.number])
    .isRequired,
  // eslint-disable-next-line react/forbid-prop-types
  style: PropTypes.array,
};

What is the problem with those types?

Randy Casburn

From the docs:

By default this rule prevents vague prop types with more specific alternatives available (any, array, object)

So either type your array as its real type or turn off the rule

This rule is a formatting/documenting preference and not following it won't negatively affect the quality of your code. This rule encourages prop types that more specifically document their usage.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the ESLint rule to prevent newline after an object prop colon

(ESLint) Definition for rule 'react/jsx-sort-prop-types' was not found

How to disable ESLint react/prop-types rule in a file?

What to do when ESLint rule "prefer-destructuring" makes no sense

ESLint React PropTypes, 'prop' is missing in prop validation

I have changed to PropTypes to "prop-types" but still get Error evaluating React.PropTypes

Object Destructuring eslint throws react/prop-types

eslint `forbid-prop-types` rule cause a warning in firefox console window

Is there an eslint rule to enforce types for useState()?

React PropTypes : Allow different types of PropTypes for one prop

Is there eslint rule for array multiline checking?

check if the key in an object is string or not when using prop-types

I have problem with adding my object to array

What does the number in eslint rule arrays mean?

What is the first argument to eslint "indent" rule

ESLint rule forbidding Object Literals in JSX

What is the meaning of the following rule in JLS if another rule makes it redundant?

What should be react default prop type for PropTypes.shape?

What is the problem with appending arbitrary object to the array?

Which rule does the string match?

In Go what is the best way to convert an array of string types to an array of string

react/prop-types eslint error in typescript react component

Eslint - 'match' is missing in props validation (react/prop-types)

Problem to convert Array of a string to ruby object

Using forwardRef with proptypes and eslint

What if a finalizer makes an object reachable?

What makes something a "trait object"?

Convert single string which has an array of individual mixed data types

eslint rule to required imported objects to have the same name as file?