Skip to content

Commit

Permalink
no-unknown-property: add download property support for a and `a…
Browse files Browse the repository at this point in the history
…rea`

fixes #3393
  • Loading branch information
HJain13 committed Sep 5, 2022
1 parent d2c9bef commit 05cb29a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](https://keepachangelog.com).

## Unreleased
* [`no-unknown-property`]: add `download` property support for `a` and `area`

### Fixed
* [`no-unknown-property`]: avoid warning on `fbt` nodes entirely ([#3391][] @ljharb)
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',
},
},
],
},
]),
});

0 comments on commit 05cb29a

Please sign in to comment.