Skip to content

Commit b95a059

Browse files
caesar1030ljharb
authored andcommitted
[New] no-unknown-property: support onResize on audio/video tags
1 parent 48318fa commit b95a059

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1111
* [`no-unknown-property`]: add requireDataLowercase option ([#3645][] @HermanBilous)
1212
* [`no-unknown-property`]: add `displaystyle` on `<math>` ([#3652][] @lounsbrough)
1313
* [`prefer-read-only-props`], [`prop-types`], component detection: allow components to be async functions ([#3654][] @pnodet)
14+
* [`no-unknown-property`]: support `onResize` on audio/video tags ([#3662][] @caesar1030)
1415

1516
### Fixed
1617
* [`jsx-no-leaked-render`]: preserve RHS parens for multiline jsx elements while fixing ([#3623][] @akulsr0)
@@ -24,6 +25,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2425
* [Refactor] [`jsx-props-no-multi-spaces`]: extract type parameters to var ([#3634][] @HenryBrown0)
2526
* [Docs] [`jsx-key`]: fix correct example ([#3656][] @developer-bandi)
2627

28+
[#3662]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3662
2729
[#3656]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3656
2830
[#3654]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3654
2931
[#3652]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3652

lib/rules/no-unknown-property.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const ATTRIBUTE_TAGS_MAP = {
9393
onPlaying: ['audio', 'video'],
9494
onProgress: ['audio', 'video'],
9595
onRateChange: ['audio', 'video'],
96+
onResize: ['audio', 'video'],
9697
onSeeked: ['audio', 'video'],
9798
onSeeking: ['audio', 'video'],
9899
onStalled: ['audio', 'video'],
@@ -296,7 +297,7 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
296297
'onBeforeInput', 'onChange',
297298
'onInvalid', 'onReset', 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'suppressContentEditableWarning', 'suppressHydrationWarning',
298299
'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded',
299-
'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange',
300+
'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange', 'onResize',
300301
'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting',
301302
'onCopyCapture', 'onCutCapture', 'onPasteCapture', 'onCompositionEndCapture', 'onCompositionStartCapture', 'onCompositionUpdateCapture',
302303
'onFocusCapture', 'onBlurCapture', 'onChangeCapture', 'onBeforeInputCapture', 'onInputCapture', 'onResetCapture', 'onSubmitCapture',

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ ruleTester.run('no-unknown-property', rule, {
128128
{ 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>' },
129129
{ code: '<line fill="pink" x1="0" y1="80" x2="100" y2="20"></line>' },
130130
{ code: '<link as="audio">Audio content</link>' },
131-
{ code: '<video controlsList="nodownload" controls={this.controls} loop={true} muted={false} src={this.videoSrc} playsInline={true}></video>' },
132-
{ code: '<audio controlsList="nodownload" 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>' },
131+
{ code: '<video controlsList="nodownload" controls={this.controls} loop={true} muted={false} src={this.videoSrc} playsInline={true} onResize={this.onResize}></video>' },
132+
{ code: '<audio controlsList="nodownload" 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} onResize={this.onResize}></audio>' },
133133
{ code: '<marker id={markerId} viewBox="0 0 2 2" refX="1" refY="1" markerWidth="1" markerHeight="1" orient="auto" />' },
134134
{ code: '<pattern id="pattern" viewBox="0,0,10,10" width="10%" height="10%" />' },
135135
{ code: '<symbol id="myDot" width="10" height="10" viewBox="0 0 2 2" />' },
@@ -413,7 +413,7 @@ ruleTester.run('no-unknown-property', rule, {
413413
],
414414
},
415415
{
416-
code: '<div onAbort={this.abort} onDurationChange={this.durationChange} onEmptied={this.emptied} onEnded={this.end} onError={this.error} />',
416+
code: '<div onAbort={this.abort} onDurationChange={this.durationChange} onEmptied={this.emptied} onEnded={this.end} onResize={this.resize} onError={this.error} />',
417417
errors: [
418418
{
419419
messageId: 'invalidPropOnTag',
@@ -447,6 +447,14 @@ ruleTester.run('no-unknown-property', rule, {
447447
allowedTags: 'audio, video',
448448
},
449449
},
450+
{
451+
messageId: 'invalidPropOnTag',
452+
data: {
453+
name: 'onResize',
454+
tagName: 'div',
455+
allowedTags: 'audio, video',
456+
},
457+
},
450458
{
451459
messageId: 'invalidPropOnTag',
452460
data: {

0 commit comments

Comments
 (0)