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

[New] no-unknown-property: Allow crossOrigin on image tag (SVG) #3251

Merged
merged 1 commit into from
Mar 21, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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