Skip to content

[Bug]: no-unknown-property is missing some valid global properties (event handlers) #3505

Open
@zandermax

Description

@zandermax

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

Brief description

Several global event handler properties that are valid on all HTML elements are being limited to only a few by this rule.

See the "event handler" section in the MDN documentation on global attributes, and the HTML specification on global event handlers here.

Show example of your code (as text format), add images/videos/gifs to help explain example
and/or Link of repo to where issue is occurring

<svg>
  <image onLoad={() => console.log("Loaded!")} />
</svg>

What is happening? / What is the error?

In the above example, the error is "Invalid property 'onLoad' found on tag 'image', but it is only allowed on: script img, link, picture, iframe, object".

What command(s) did you run to reproduce issue?

Enabled the rule and the above code will show an error.

Expected Behavior

Brief description

Any global event handler should be able to be defined for any HTML element. (Note that most of these are already in @types/react).

Show example of code (as text format), add images/videos/gifs to help explain expected behavior

This code should not show an error for defining onLoad:

<svg>
  <image onLoad={() => console.log("Loaded!")} />
</svg>

eslint-plugin-react version

7.31.11

eslint version

8.28.0

node version

16.14.2

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