Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] no-unknown-property: allow abbr on <th> and <td> #3419

Merged
merged 1 commit into from Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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',
},
},
],
},
]),
});