From fd90b0e35a91d1e19849086a073a500fc66040c9 Mon Sep 17 00:00:00 2001 From: OleksiiKachan Date: Wed, 7 Sep 2022 09:08:42 -0400 Subject: [PATCH] [Fix] `no-unknown-property`: allow `abbr` on `` and `` Fixes #3418. --- CHANGELOG.md | 2 ++ lib/rules/no-unknown-property.js | 1 + tests/lib/rules/no-unknown-property.js | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5c9253d18..1d5324d10b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [`no-unknown-property`]: add `noModule` on `script` ([#3414][] @ljharb) * [`no-unknown-property`]: allow `onLoad` on `` ([#3415][] @OleksiiKachan) * [`no-multi-comp`]: do not detect a function property returning only null as a component ([#3412][] @ljharb) +* [`no-unknown-property`]: allow `abbr` on `` and `` ([#3419][] @OleksiiKachan) ### Changed * [Meta] npmignore markdownlint config ([#3413][] @jorrit) +[#3419]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3419 [#3416]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3416 [#3415]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3415 [#3414]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3414 diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 26e39fd24f..92f0257fe3 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -28,6 +28,7 @@ const DOM_ATTRIBUTE_NAMES = { }; const ATTRIBUTE_TAGS_MAP = { + abbr: ['th', 'td'], checked: ['input'], // image is required for SVG support, all other tags are HTML. crossOrigin: ['script', 'img', 'video', 'audio', 'link', 'image'], diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index 911d28179b..0006041371 100644 --- a/tests/lib/rules/no-unknown-property.js +++ b/tests/lib/rules/no-unknown-property.js @@ -69,6 +69,8 @@ ruleTester.run('no-unknown-property', rule, { { code: '' }, { code: '
' }, { code: '' }, + { code: '
' }, + { code: '' }, { code: '
', settings: { @@ -549,5 +551,18 @@ ruleTester.run('no-unknown-property', rule, { }, ], }, + { + code: '
', + errors: [ + { + messageId: 'invalidPropOnTag', + data: { + name: 'abbr', + tagName: 'div', + allowedTags: 'th, td', + }, + }, + ], + }, ]), });