Skip to content

Commit 0c5a8a3

Browse files
committed
fix: allow imageSrcSet and imageSizes attributes on link element
1 parent 7ba7ec4 commit 0c5a8a3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/rules/no-unknown-property.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const ATTRIBUTE_TAGS_MAP = {
5757
'animateTransform',
5858
'set',
5959
],
60+
imageSizes: ['link'],
61+
imageSrcSet: ['link'],
6062
property: ['meta'],
6163
viewBox: ['svg'],
6264
as: ['link'],
@@ -228,7 +230,7 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
228230
// To be considered if these should be added also to ATTRIBUTE_TAGS_MAP
229231
'acceptCharset', 'autoComplete', 'autoPlay', 'cellPadding', 'cellSpacing', 'classID', 'codeBase',
230232
'colSpan', 'contextMenu', 'dateTime', 'encType', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget',
231-
'frameBorder', 'hrefLang', 'httpEquiv', 'isMap', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
233+
'frameBorder', 'hrefLang', 'httpEquiv', 'imageSizes', 'imageSrcSet', 'isMap', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
232234
'maxLength', 'mediaGroup', 'minLength', 'noValidate', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart',
233235
'onBlur', 'onChange', 'onClick', 'onContextMenu', 'onCopy', 'onCompositionEnd', 'onCompositionStart',
234236
'onCompositionUpdate', 'onCut', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave',

tests/lib/rules/no-unknown-property.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ ruleTester.run('no-unknown-property', rule, {
6363
{ code: '<script onLoad={bar} onError={foo} />' },
6464
{ code: '<source onError={foo} />' },
6565
{ code: '<link onLoad={bar} onError={foo} />' },
66+
{ code: '<link rel="preload" as="image" href="someHref" imageSrcSet="someImageSrcSet" imageSizes="someImageSizes" />' },
6667
{ code: '<div allowFullScreen webkitAllowFullScreen mozAllowFullScreen />' },
6768
{
6869
code: '<div allowTransparency="true" />',
@@ -481,5 +482,31 @@ ruleTester.run('no-unknown-property', rule, {
481482
},
482483
],
483484
},
485+
{
486+
code: '<div imageSrcSet="someImageSrcSet" />',
487+
errors: [
488+
{
489+
messageId: 'invalidPropOnTag',
490+
data: {
491+
name: 'imageSrcSet',
492+
tagName: 'div',
493+
allowedTags: 'link',
494+
},
495+
},
496+
],
497+
},
498+
{
499+
code: '<div imageSizes="someImageSizes" />',
500+
errors: [
501+
{
502+
messageId: 'invalidPropOnTag',
503+
data: {
504+
name: 'imageSizes',
505+
tagName: 'div',
506+
allowedTags: 'link',
507+
},
508+
},
509+
],
510+
},
484511
]),
485512
});

0 commit comments

Comments
 (0)