Skip to content

[Bug]: jsx-key could not be triggered when using a custom mapping function #3541

Open
@meteorlxy

Description

@meteorlxy

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

When using a custom array mapping function like lodash.map, the jsx-key rule won't be triggered

import map from 'lodash/map';

// not triggered
const Comp1 = () => {
  return map([1, 2, 3], (item) => {
    return <div>{item}</div>;
  });
};

// triggered
const Comp2 = () => {
  return [1, 2, 3].map((item) => {
    return <div>{item}</div>;
  });
};

Expected Behavior

Is it possible to add a config to support custom mapping function?

eslint-plugin-react version

v7.32.2

eslint version

v8.35.0

node version

v18.14.0

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