diff --git a/CHANGELOG.md b/CHANGELOG.md index 95cfb36652..6145af952b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 6a8c18db41..70cdcf26de 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -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', diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index bb4105eb0c..9512887edd 100644 --- a/tests/lib/rules/no-unknown-property.js +++ b/tests/lib/rules/no-unknown-property.js @@ -44,7 +44,8 @@ ruleTester.run('no-unknown-property', rule, { // Some HTML/DOM elements with common attributes should work { code: '
;' }, { code: '
;' }, - { code: 'Read more' }, + { code: 'Read more' }, + { code: '' }, { code: 'A cat sleeping on a keyboard' }, { code: '' }, { code: '' }, @@ -466,5 +467,18 @@ ruleTester.run('no-unknown-property', rule, { }, ], }, + { + code: '
', + errors: [ + { + messageId: 'invalidPropOnTag', + data: { + name: 'download', + tagName: 'div', + allowedTags: 'a, area', + }, + }, + ], + }, ]), });