Skip to content

[Bug]: no-unknown-property gives false-positives on data-* attributes, but React gives warnings on them #3643

Closed
@HermanBilous

Description

@HermanBilous

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

There was an #3395 issue raised, which resulted in the rule being updated to support passing data-* attributes with any casing, but even the sandbox the reporter provided included a warning from react: "Warning: React does not recognize the data-testID prop on a DOM element.". This is still an issue right now with react 18, as seen in this sandbox.

https://codesandbox.io/s/adoring-robinson-2z75gh

Expected Behavior

Expected behaviour: data-* attributes are reported, when they have any capital letters.

Actual behaviour: data-* attributes with uppercase letters are not reported by rule, react dumps warnings into console.

eslint-plugin-react version

v7.33.2

eslint version

v8.51.0

node version

v20

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