Skip to content
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 @@ -13,7 +13,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-unknown-property`]: add more capture event properties ([#3402][] @sjarva)
* [`no-unknown-property`]: Add more one word properties found in DefinitelyTyped's react/index.d.ts ([#3402][] @sjarva)
* [`no-unknown-property`]: Mark onLoad/onError as supported on iframes ([#3398][] @maiis, [#3406][] @akx)
* [`no-unknown-property`]: allow `imageSrcSet` and `imageSizes` attributes on `<link>` ([#3407][] @terrymun)

[#3407]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3407
[#3406]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3406
[#3402]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3402
[#3398]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3398
Expand Down
4 changes: 3 additions & 1 deletion lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const ATTRIBUTE_TAGS_MAP = {
'animateTransform',
'set',
],
imageSizes: ['link'],
imageSrcSet: ['link'],
property: ['meta'],
viewBox: ['svg'],
as: ['link'],
Expand Down Expand Up @@ -230,7 +232,7 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
// To be considered if these should be added also to ATTRIBUTE_TAGS_MAP
'acceptCharset', 'autoComplete', 'autoPlay', 'cellPadding', 'cellSpacing', 'classID', 'codeBase',
'colSpan', 'contextMenu', 'dateTime', 'encType', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget',
'frameBorder', 'hrefLang', 'httpEquiv', 'isMap', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
'frameBorder', 'hrefLang', 'httpEquiv', 'imageSizes', 'imageSrcSet', 'isMap', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
'maxLength', 'mediaGroup', 'minLength', 'noValidate', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart',
'onBlur', 'onChange', 'onClick', 'onContextMenu', 'onCopy', 'onCompositionEnd', 'onCompositionStart',
'onCompositionUpdate', 'onCut', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave',
Expand Down
27 changes: 27 additions & 0 deletions tests/lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<script onLoad={bar} onError={foo} />' },
{ code: '<source onError={foo} />' },
{ code: '<link onLoad={bar} onError={foo} />' },
{ code: '<link rel="preload" as="image" href="someHref" imageSrcSet="someImageSrcSet" imageSizes="someImageSizes" />' },
{ code: '<div allowFullScreen webkitAllowFullScreen mozAllowFullScreen />' },
{
code: '<div allowTransparency="true" />',
Expand Down Expand Up @@ -483,5 +484,31 @@ ruleTester.run('no-unknown-property', rule, {
},
],
},
{
code: '<div imageSrcSet="someImageSrcSet" />',
errors: [
{
messageId: 'invalidPropOnTag',
data: {
name: 'imageSrcSet',
tagName: 'div',
allowedTags: 'link',
},
},
],
},
{
code: '<div imageSizes="someImageSizes" />',
errors: [
{
messageId: 'invalidPropOnTag',
data: {
name: 'imageSizes',
tagName: 'div',
allowedTags: 'link',
},
},
],
},
]),
});