Skip to content

Commit 38572e8

Browse files
sjarvaljharb
authored andcommitted
[Fix] no-unknown-property: fill works on line, mask, and use elements
1 parent 487ef70 commit 38572e8

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1010
* [`no-unknown-property`]: data-* attributes can have numbers ([#3390][] @sjarva)
1111
* [`no-unknown-property`]: add more audio/video attributes ([#3390][] @sjarva)
1212
* [`no-unknown-property`]: move allowfullscreen to case ignored attributes ([#3390][] @sjarva)
13+
* [`no-unknown-property`]: fill works on line, mask, and use elements ([#3390][] @sjarva)
1314

1415
[#3390]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3390
1516
[#3388]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3388

lib/rules/no-unknown-property.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const ATTRIBUTE_TAGS_MAP = {
3636
'circle',
3737
'ellipse',
3838
'g',
39+
'line',
40+
'mask',
3941
'path',
4042
'polygon',
4143
'polyline',
@@ -45,6 +47,7 @@ const ATTRIBUTE_TAGS_MAP = {
4547
'textPath',
4648
'tref',
4749
'tspan',
50+
'use',
4851
// Animation final state
4952
'animate',
5053
'animateColor',

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ ruleTester.run('no-unknown-property', rule, {
5454
{ code: '<button disabled>You cannot click me</button>;' },
5555
{ code: '<svg key="lock" viewBox="box" fill={10} d="d" stroke={1} strokeWidth={2} strokeLinecap={3} strokeLinejoin={4} transform="something" clipRule="else" x1={5} x2="6" y1="7" y2="8"></svg>' },
5656
{ code: '<g fill="#7B82A0" fillRule="evenodd"></g>' },
57+
{ code: '<mask fill="#7B82A0"></mask>' },
5758
{ code: '<meta property="og:type" content="website" />' },
5859
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
5960
{ code: '<video playsInline />' },
@@ -101,6 +102,7 @@ ruleTester.run('no-unknown-property', rule, {
101102
{ code: '<svg><image crossOrigin /></svg>' },
102103
{ code: '<details onToggle={this.onToggle}>Some details</details>' },
103104
{ code: '<path fill="pink" d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z"></path>' },
105+
{ code: '<line fill="pink" x1="0" y1="80" x2="100" y2="20"></line>' },
104106
{ code: '<link as="audio">Audio content</link>' },
105107
{ code: '<video controls={this.controls} loop={true} muted={false} src={this.videoSrc} playsInline={true}></video>' },
106108
{ code: '<audio controls={this.controls} crossOrigin="anonymous" disableRemotePlayback loop muted preload="none" src="something" onAbort={this.abort} onDurationChange={this.durationChange} onEmptied={this.emptied} onEnded={this.end} onError={this.error}></audio>' },
@@ -392,6 +394,19 @@ ruleTester.run('no-unknown-property', rule, {
392394
},
393395
],
394396
},
397+
{
398+
code: '<div fill="pink" />',
399+
errors: [
400+
{
401+
messageId: 'invalidPropOnTag',
402+
data: {
403+
name: 'fill',
404+
tagName: 'div',
405+
allowedTags: 'altGlyph, circle, ellipse, g, line, mask, path, polygon, polyline, rect, svg, text, textPath, tref, tspan, use, animate, animateColor, animateMotion, animateTransform, set',
406+
},
407+
},
408+
],
409+
},
395410
{
396411
code: '<div controls={this.controls} loop={true} muted={false} src={this.videoSrc} playsInline={true} allowFullScreen></div>',
397412
errors: [

0 commit comments

Comments
 (0)