Skip to content

Commit

Permalink
[Fix] no-unknown-property: onError and onLoad both work on `img…
Browse files Browse the repository at this point in the history
…` and `script`

Fixes #3388
  • Loading branch information
ljharb committed Sep 4, 2022
1 parent 8116891 commit 51ec858
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## Unreleased

### Fixed
* [`no-unknown-property`]: `onError` and `onLoad` both work on `img` and `script` ([#3388][] @ljharb)

[#3388]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3388

## [7.31.5] - 2022.09.03

### Fixed
Expand All @@ -14,7 +19,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-unknown-property`]: `children` is always an acceptable prop; iframes have `scrolling`; video has `playsInline` ([#3385][] @ljharb)

[7.31.5]: https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.31.4...v7.31.5
[#3385]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3385
[#3385]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3385

## [7.31.4] - 2022.09.03

Expand Down
3 changes: 2 additions & 1 deletion lib/rules/no-unknown-property.js
Expand Up @@ -63,7 +63,8 @@ const ATTRIBUTE_TAGS_MAP = {
onEmptied: ['audio', 'video'],
onEncrypted: ['audio', 'video'],
onEnded: ['audio', 'video'],
onError: ['audio', 'video'],
onError: ['audio', 'video', 'img', 'script'],
onLoad: ['script', 'img'],
onLoadedData: ['audio', 'video'],
onLoadedMetadata: ['audio', 'video'],
onLoadStart: ['audio', 'video'],
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/rules/no-unknown-property.js
Expand Up @@ -57,6 +57,8 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<meta property="og:type" content="website" />' },
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
{ code: '<video playsInline />' },
{ code: '<img onError={foo} onLoad={bar} />' },
{ code: '<script onLoad={bar} onError={foo} />' },
{
code: '<div allowTransparency="true" />',
settings: {
Expand Down Expand Up @@ -383,7 +385,7 @@ ruleTester.run('no-unknown-property', rule, {
data: {
name: 'onError',
tagName: 'div',
allowedTags: 'audio, video',
allowedTags: 'audio, video, img, script',
},
},
],
Expand Down

0 comments on commit 51ec858

Please sign in to comment.