Skip to content

Commit 32119f9

Browse files
sjarvaljharb
authored andcommitted
[Fix] no-unknown-property: add more capture event properties
Fixes #3400.
1 parent c59ad4a commit 32119f9

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1010
* [`no-unknown-property`]: add `download` property support for `a` and `area` ([#3394][] @HJain13)
1111
* [`no-unknown-property`]: allow `webkitAllowFullScreen` and `mozAllowFullScreen` ([#3396][] @ljharb)
1212
* [`no-unknown-property`]: `controlsList`, not `controlList` ([#3397][] @ljharb)
13+
* [`no-unknown-property`]: add more capture event properties ([#3402][] @sjarva)
1314

15+
[#3402]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3402
1416
[#3397]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3397
1517
[#3396]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3396
1618
[#3394]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3394

lib/rules/no-unknown-property.js

+28-3
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,27 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
270270
'autoCorrect', // https://stackoverflow.com/questions/47985384/html-autocorrect-for-text-input-is-not-working
271271
'autoSave', // https://stackoverflow.com/questions/25456396/what-is-autosave-attribute-supposed-to-do-how-do-i-use-it
272272
// React specific attributes https://reactjs.org/docs/dom-elements.html#differences-in-attributes
273-
'className', 'dangerouslySetInnerHTML', 'defaultValue', 'defaultChecked', 'htmlFor', 'onChange',
273+
'className', 'dangerouslySetInnerHTML', 'defaultValue', 'defaultChecked', 'htmlFor',
274+
// Events' capture events
275+
'onBeforeInput', 'onChange',
274276
'onInvalid', 'onReset', 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'suppressContentEditableWarning', 'suppressHydrationWarning',
275277
'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded',
276278
'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange',
277279
'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting',
278-
'onMouseMoveCapture',
279-
// Video specific,
280+
'onCopyCapture', 'onCutCapture', 'onPasteCapture', 'onCompositionEndCapture', 'onCompositionStartCapture', 'onCompositionUpdateCapture',
281+
'onFocusCapture', 'onBlurCapture', 'onChangeCapture', 'onBeforeInputCapture', 'onInputCapture', 'onResetCapture', 'onSubmitCapture',
282+
'onInvalidCapture', 'onLoadCapture', 'onErrorCapture', 'onKeyDownCapture', 'onKeyPressCapture', 'onKeyUpCapture',
283+
'onAbortCapture', 'onCanPlayCapture', 'onCanPlayThroughCapture', 'onDurationChangeCapture', 'onEmptiedCapture', 'onEncryptedCapture',
284+
'onEndedCapture', 'onLoadedDataCapture', 'onLoadedMetadataCapture', 'onLoadStartCapture', 'onPauseCapture', 'onPlayCapture',
285+
'onPlayingCapture', 'onProgressCapture', 'onRateChangeCapture', 'onSeekedCapture', 'onSeekingCapture', 'onStalledCapture', 'onSuspendCapture',
286+
'onTimeUpdateCapture', 'onVolumeChangeCapture', 'onWaitingCapture', 'onSelectCapture', 'onTouchCancelCapture', 'onTouchEndCapture',
287+
'onTouchMoveCapture', 'onTouchStartCapture', 'onScrollCapture', 'onWheelCapture', 'onAnimationEndCapture', 'onAnimationIteration',
288+
'onAnimationStartCapture', 'onTransitionEndCapture',
289+
'onAuxClick', 'onAuxClickCapture', 'onClickCapture', 'onContextMenuCapture', 'onDoubleClickCapture',
290+
'onDragCapture', 'onDragEndCapture', 'onDragEnterCapture', 'onDragExitCapture', 'onDragLeaveCapture',
291+
'onDragOverCapture', 'onDragStartCapture', 'onDropCapture', 'onMouseDown', 'onMouseDownCapture',
292+
'onMouseMoveCapture', 'onMouseOutCapture', 'onMouseOverCapture', 'onMouseUpCapture',
293+
// Video specific
280294
'autoPictureInPicture', 'controlsList', 'disablePictureInPicture', 'disableRemotePlayback',
281295
];
282296

@@ -301,15 +315,26 @@ const ARIA_PROPERTIES = [
301315

302316
const REACT_ON_PROPS = [
303317
'onGotPointerCapture',
318+
'onGotPointerCaptureCapture',
319+
'onLostPointerCapture',
304320
'onLostPointerCapture',
321+
'onLostPointerCaptureCapture',
305322
'onPointerCancel',
323+
'onPointerCancelCapture',
306324
'onPointerDown',
325+
'onPointerDownCapture',
307326
'onPointerEnter',
327+
'onPointerEnterCapture',
308328
'onPointerLeave',
329+
'onPointerLeaveCapture',
309330
'onPointerMove',
331+
'onPointerMoveCapture',
310332
'onPointerOut',
333+
'onPointerOutCapture',
311334
'onPointerOver',
335+
'onPointerOverCapture',
312336
'onPointerUp',
337+
'onPointerUpCapture',
313338
];
314339

315340
function getDOMPropertyNames(context) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ruleTester.run('no-unknown-property', rule, {
7373
// React related attributes
7474
{ code: '<div onPointerDown={this.onDown} onPointerUp={this.onUp} />' },
7575
{ code: '<input type="checkbox" defaultChecked={this.state.checkbox} />' },
76-
{ code: '<div onTouchStart={this.startAnimation} onTouchEnd={this.stopAnimation} onTouchCancel={this.cancel} onTouchMove={this.move} onMouseMoveCapture={this.capture} />' },
76+
{ code: '<div onTouchStart={this.startAnimation} onTouchEnd={this.stopAnimation} onTouchCancel={this.cancel} onTouchMove={this.move} onMouseMoveCapture={this.capture} onTouchCancelCapture={this.log} />' },
7777
// Case ignored attributes, for `charset` discussion see https://github.com/jsx-eslint/eslint-plugin-react/pull/1863
7878
{ code: '<meta charset="utf-8" />;' },
7979
{ code: '<meta charSet="utf-8" />;' },

0 commit comments

Comments
 (0)