Eslint-plugin-react: forEach missing in props validation

Created on 12 Mar 2016  路  3Comments  路  Source: yannickcr/eslint-plugin-react

Plugin version - 4.2.1
forEach is considered as a prop that I need to validate instead of being recognised as an inbuilt function.
Sample code below

import React, { PropTypes } from 'react';
function JobList(props) {
  const jobs = [];
  props
  .jobs
  .forEach(() => {}); // error here saying 'forEach missing in props validation'

  return (
    <div></div>
  );
}

JobList.propTypes = {
  jobs: PropTypes.arrayOf(
    PropTypes.shape({
      id: PropTypes.string.isRequired,
    })
  ),
};
bug

Most helpful comment

Same thing for .map just fyi

All 3 comments

Same thing for .map just fyi

Seems like any propType that is annotated as array or arrayOf should ignore all of the Array.prototype methods.

They are already ignored, but I seems there is a bug with line-breaks.

props
.jobs
.forEach(() => {}); // forEach missing in props validation

props.jobs.forEach(() => {}); // No warning
Was this page helpful?
0 / 5 - 0 ratings