Skip to content

[Bug]: disallowedFor in forbid-component-props not working #3567

@v-mec

Description

@v-mec

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

The error is shown for all components where the prop is used, not just in the component in disallowedFor.

{
 propName: 'key',
 disallowedFor: ['Component'],
 message: 'Do not use key on Component.',
}

<AnotherComponent key={} /> -> Shows error

Expected Behavior

Error not showing for components that are not in the disallowedFor array.

<AnotherComponent key={} /> -> No error

Error only showing for the disallowed component.
<Component key={} /> -> Shows error

eslint-plugin-react version

7.31.8

eslint version

8.15.0

node version

16.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions