Skip to content

Commit

Permalink
[Fix] no-unknown-property: fill works on line, mask, and use elements
Browse files Browse the repository at this point in the history
  • Loading branch information
sjarva authored and ljharb committed Sep 4, 2022
1 parent 487ef70 commit 38572e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-unknown-property`]: data-* attributes can have numbers ([#3390][] @sjarva)
* [`no-unknown-property`]: add more audio/video attributes ([#3390][] @sjarva)
* [`no-unknown-property`]: move allowfullscreen to case ignored attributes ([#3390][] @sjarva)
* [`no-unknown-property`]: fill works on line, mask, and use elements ([#3390][] @sjarva)

[#3390]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3390
[#3388]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3388
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const ATTRIBUTE_TAGS_MAP = {
'circle',
'ellipse',
'g',
'line',
'mask',
'path',
'polygon',
'polyline',
Expand All @@ -45,6 +47,7 @@ const ATTRIBUTE_TAGS_MAP = {
'textPath',
'tref',
'tspan',
'use',
// Animation final state
'animate',
'animateColor',
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<button disabled>You cannot click me</button>;' },
{ 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>' },
{ code: '<g fill="#7B82A0" fillRule="evenodd"></g>' },
{ code: '<mask fill="#7B82A0"></mask>' },
{ code: '<meta property="og:type" content="website" />' },
{ code: '<input type="checkbox" checked={checked} disabled={disabled} id={id} onChange={onChange} />' },
{ code: '<video playsInline />' },
Expand Down Expand Up @@ -101,6 +102,7 @@ ruleTester.run('no-unknown-property', rule, {
{ code: '<svg><image crossOrigin /></svg>' },
{ code: '<details onToggle={this.onToggle}>Some details</details>' },
{ 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>' },
{ code: '<line fill="pink" x1="0" y1="80" x2="100" y2="20"></line>' },
{ code: '<link as="audio">Audio content</link>' },
{ code: '<video controls={this.controls} loop={true} muted={false} src={this.videoSrc} playsInline={true}></video>' },
{ 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>' },
Expand Down Expand Up @@ -392,6 +394,19 @@ ruleTester.run('no-unknown-property', rule, {
},
],
},
{
code: '<div fill="pink" />',
errors: [
{
messageId: 'invalidPropOnTag',
data: {
name: 'fill',
tagName: 'div',
allowedTags: 'altGlyph, circle, ellipse, g, line, mask, path, polygon, polyline, rect, svg, text, textPath, tref, tspan, use, animate, animateColor, animateMotion, animateTransform, set',
},
},
],
},
{
code: '<div controls={this.controls} loop={true} muted={false} src={this.videoSrc} playsInline={true} allowFullScreen></div>',
errors: [
Expand Down

0 comments on commit 38572e8

Please sign in to comment.