From 51ec8581850afa32adf3438b7db0a39a4f24405c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 4 Sep 2022 00:38:42 -0700 Subject: [PATCH] [Fix] `no-unknown-property`: `onError` and `onLoad` both work on `img` and `script` Fixes #3388 --- CHANGELOG.md | 7 ++++++- lib/rules/no-unknown-property.js | 3 ++- tests/lib/rules/no-unknown-property.js | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c8ce36864..7f627147e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index a7bd0291ec..2867c5d5b1 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -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'], diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index d03179ef75..d25c3d7cb4 100644 --- a/tests/lib/rules/no-unknown-property.js +++ b/tests/lib/rules/no-unknown-property.js @@ -57,6 +57,8 @@ ruleTester.run('no-unknown-property', rule, { { code: '' }, { code: '' }, { code: '