Skip to content

Commit

Permalink
[New] no-unknown-property: Allow crossOrigin on image tag (SVG)
Browse files Browse the repository at this point in the history
Fixes #3250
  • Loading branch information
zpao authored and ljharb committed Mar 21, 2022
1 parent 567bc7d commit 2145e29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,11 +7,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

### Added
* [`destructuring-assignment`]: add option `destructureInSignature` ([#3235][] @golopot)
* [`no-unknown-property`]: Allow crossOrigin on image tag (SVG) ([#3251][] @zpao)

### Fixed
* [`hook-use-state`]: Allow UPPERCASE setState setter prefixes ([#3244][] @duncanbeevers)
* `propTypes`: add `VFC` to react generic type param map ([#3230][] @dlech)

[#3251]: https://github.com/yannickcr/eslint-plugin-react/pull/3251
[#3244]: https://github.com/yannickcr/eslint-plugin-react/pull/3244
[#3235]: https://github.com/yannickcr/eslint-plugin-react/pull/3235
[#3230]: https://github.com/yannickcr/eslint-plugin-react/issues/3230
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/no-unknown-property.js
Expand Up @@ -27,7 +27,8 @@ const DOM_ATTRIBUTE_NAMES = {
};

const ATTRIBUTE_TAGS_MAP = {
crossOrigin: ['script', 'img', 'video', 'audio', 'link'],
// image is required for SVG support, all other tags are HTML.
crossOrigin: ['script', 'img', 'video', 'audio', 'link', 'image'],
};

const SVGDOM_ATTRIBUTE_NAMES = {
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/rules/no-unknown-property.js
Expand Up @@ -53,6 +53,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<script crossOrigin />' },
{ code: '<audio crossOrigin />' },
{ code: '<div hasOwnProperty="should not be allowed tag" />' },
{ code: '<svg><image crossOrigin /></svg>' },
]),
invalid: parsers.all([
{
Expand Down Expand Up @@ -220,7 +221,7 @@ ruleTester.run('no-unknown-property', rule, {
data: {
name: 'crossOrigin',
tagName: 'div',
allowedTags: 'script, img, video, audio, link',
allowedTags: 'script, img, video, audio, link, image',
},
},
],
Expand Down

0 comments on commit 2145e29

Please sign in to comment.