Skip to content

Commit 4a1cc5a

Browse files
committed
[Fix] #3400 add more capture event properties
1 parent 072d8e1 commit 4a1cc5a

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

lib/rules/no-unknown-property.js

Lines changed: 28 additions & 3 deletions
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',
304319
'onLostPointerCapture',
305320
'onPointerCancel',
321+
'onPointerCancelCapture',
306322
'onPointerDown',
323+
'onPointerDownCapture',
307324
'onPointerEnter',
325+
'onPointerEnterCapture',
308326
'onPointerLeave',
327+
'onPointerLeaveCapture',
309328
'onPointerMove',
329+
'onPointerMoveCapture',
310330
'onPointerOut',
331+
'onPointerOutCapture',
311332
'onPointerOver',
333+
'onPointerOverCapture',
312334
'onPointerUp',
335+
'onPointerUpCapture',
336+
'onLostPointerCapture',
337+
'onLostPointerCaptureCapture',
313338
];
314339

315340
function getDOMPropertyNames(context) {

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

Lines changed: 1 addition & 1 deletion
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)