Skip to content

Commit

Permalink
[Fix] no-unknown-property: allow abbr on <th> and <td>
Browse files Browse the repository at this point in the history
Fixes #3418.
  • Loading branch information
OleksiiKachan authored and ljharb committed Sep 7, 2022
1 parent 8aa023a commit fd90b0e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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 `<object>` ([#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 `<th>` and `<td>` ([#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
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-unknown-property.js
Expand Up @@ -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'],
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/rules/no-unknown-property.js
Expand Up @@ -69,6 +69,8 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<object onLoad={bar} />' },
{ code: '<div allowFullScreen webkitAllowFullScreen mozAllowFullScreen />' },
{ code: '<table border="1" />' },
{ code: '<th abbr="abbr" />' },
{ code: '<td abbr="abbr" />' },
{
code: '<div allowTransparency="true" />',
settings: {
Expand Down Expand Up @@ -549,5 +551,18 @@ ruleTester.run('no-unknown-property', rule, {
},
],
},
{
code: '<div abbr="abbr" />',
errors: [
{
messageId: 'invalidPropOnTag',
data: {
name: 'abbr',
tagName: 'div',
allowedTags: 'th, td',
},
},
],
},
]),
});

0 comments on commit fd90b0e

Please sign in to comment.