Content-Length: 345179 | pFad | https://redirect.github.com/jsx-eslint/eslint-plugin-react/issues/1047

76 `prop-types` rule reports for Array.prototype.length is missing · Issue #1047 · jsx-eslint/eslint-plugin-react · GitHub
Skip to content

prop-types rule reports for Array.prototype.length is missing #1047

@ashleahhill

Description

@ashleahhill

h2. Expected

When a propType React.PropTypes.arrayOf(<something>), you shouldn't be prompted to add
length by eslint.

h2. What happens

You get '.length' is missing in props validation (react/prop-types) from eslint

h2. Example

class MyClass extends React.Component {
    static propTypes = {
        results: PropTypes.arrayOf(
            PropTypes.shape({
                items: PropTypes.arrayOf(PropTypes.shape(<Shape definition>))
            })
        )
    };

    get hasItems() {
        this.props.results && this.props.results.items && this.props.results.items.length > 0; 
    }
}

Results in this:
'results.items.length' is missing in props validation (react/prop-types)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://redirect.github.com/jsx-eslint/eslint-plugin-react/issues/1047

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy