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

no-unknown-property: add download property support for a and area #3394

Merged
merged 1 commit into from Sep 5, 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 @@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

### Fixed
* [`no-unknown-property`]: avoid warning on `fbt` nodes entirely ([#3391][] @ljharb)
* [`no-unknown-property`]: add `download` property support for `a` and `area` ([#3394][] @HJain13)

[#3394]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3394
[#3391]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3391

## [7.31.6] - 2022.09.04
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/no-unknown-property.js
Expand Up @@ -30,6 +30,8 @@ const ATTRIBUTE_TAGS_MAP = {
checked: ['input'],
// image is required for SVG support, all other tags are HTML.
crossOrigin: ['script', 'img', 'video', 'audio', 'link', 'image'],
// https://html.spec.whatwg.org/multipage/links.html#downloading-resources
download: ['a', 'area'],
fill: [ // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill
// Fill color
'altGlyph',
Expand Down
16 changes: 15 additions & 1 deletion tests/lib/rules/no-unknown-property.js
Expand Up @@ -44,7 +44,8 @@ ruleTester.run('no-unknown-property', rule, {
// Some HTML/DOM elements with common attributes should work
{ code: '<div className="bar"></div>;' },
{ code: '<div onMouseDown={this._onMouseDown}></div>;' },
{ code: '<a href="someLink">Read more</a>' },
{ code: '<a href="someLink" download="foo">Read more</a>' },
{ code: '<area download="foo" />' },
{ code: '<img src="cat_keyboard.jpeg" alt="A cat sleeping on a keyboard" />' },
{ code: '<input type="password" required />' },
{ code: '<input ref={this.input} type="radio" />' },
Expand Down Expand Up @@ -466,5 +467,18 @@ ruleTester.run('no-unknown-property', rule, {
},
],
},
{
code: '<div download="foo" />',
errors: [
{
messageId: 'invalidPropOnTag',
data: {
name: 'download',
tagName: 'div',
allowedTags: 'a, area',
},
},
],
},
]),
});