Skip to content

Commit 3b30527

Browse files
HJain13ljharb
authored andcommitted
[Fix] no-unknown-property: add download property support for a and area
Fixes #3393
1 parent d2c9bef commit 3b30527

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
77

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

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

1315
## [7.31.6] - 2022.09.04

lib/rules/no-unknown-property.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const ATTRIBUTE_TAGS_MAP = {
3030
checked: ['input'],
3131
// image is required for SVG support, all other tags are HTML.
3232
crossOrigin: ['script', 'img', 'video', 'audio', 'link', 'image'],
33+
// https://html.spec.whatwg.org/multipage/links.html#downloading-resources
34+
download: ['a', 'area'],
3335
fill: [ // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill
3436
// Fill color
3537
'altGlyph',

tests/lib/rules/no-unknown-property.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ ruleTester.run('no-unknown-property', rule, {
4444
// Some HTML/DOM elements with common attributes should work
4545
{ code: '<div className="bar"></div>;' },
4646
{ code: '<div onMouseDown={this._onMouseDown}></div>;' },
47-
{ code: '<a href="someLink">Read more</a>' },
47+
{ code: '<a href="someLink" download="foo">Read more</a>' },
48+
{ code: '<area download="foo" />' },
4849
{ code: '<img src="cat_keyboard.jpeg" alt="A cat sleeping on a keyboard" />' },
4950
{ code: '<input type="password" required />' },
5051
{ code: '<input ref={this.input} type="radio" />' },
@@ -466,5 +467,18 @@ ruleTester.run('no-unknown-property', rule, {
466467
},
467468
],
468469
},
470+
{
471+
code: '<div download="foo" />',
472+
errors: [
473+
{
474+
messageId: 'invalidPropOnTag',
475+
data: {
476+
name: 'download',
477+
tagName: 'div',
478+
allowedTags: 'a, area',
479+
},
480+
},
481+
],
482+
},
469483
]),
470484
});

0 commit comments

Comments
 (0)