From 4a1cc5a7a433f6665e58cfdac90dfa53c06bcb0f Mon Sep 17 00:00:00 2001 From: Senja Jarva Date: Mon, 5 Sep 2022 14:19:45 +0300 Subject: [PATCH] [Fix] #3400 add more capture event properties --- lib/rules/no-unknown-property.js | 31 +++++++++++++++++++++++--- tests/lib/rules/no-unknown-property.js | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index e6cc3304df..6de2fc096f 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -270,13 +270,27 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [ 'autoCorrect', // https://stackoverflow.com/questions/47985384/html-autocorrect-for-text-input-is-not-working 'autoSave', // https://stackoverflow.com/questions/25456396/what-is-autosave-attribute-supposed-to-do-how-do-i-use-it // React specific attributes https://reactjs.org/docs/dom-elements.html#differences-in-attributes - 'className', 'dangerouslySetInnerHTML', 'defaultValue', 'defaultChecked', 'htmlFor', 'onChange', + 'className', 'dangerouslySetInnerHTML', 'defaultValue', 'defaultChecked', 'htmlFor', + // Events' capture events + 'onBeforeInput', 'onChange', 'onInvalid', 'onReset', 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded', 'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange', 'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting', - 'onMouseMoveCapture', - // Video specific, + 'onCopyCapture', 'onCutCapture', 'onPasteCapture', 'onCompositionEndCapture', 'onCompositionStartCapture', 'onCompositionUpdateCapture', + 'onFocusCapture', 'onBlurCapture', 'onChangeCapture', 'onBeforeInputCapture', 'onInputCapture', 'onResetCapture', 'onSubmitCapture', + 'onInvalidCapture', 'onLoadCapture', 'onErrorCapture', 'onKeyDownCapture', 'onKeyPressCapture', 'onKeyUpCapture', + 'onAbortCapture', 'onCanPlayCapture', 'onCanPlayThroughCapture', 'onDurationChangeCapture', 'onEmptiedCapture', 'onEncryptedCapture', + 'onEndedCapture', 'onLoadedDataCapture', 'onLoadedMetadataCapture', 'onLoadStartCapture', 'onPauseCapture', 'onPlayCapture', + 'onPlayingCapture', 'onProgressCapture', 'onRateChangeCapture', 'onSeekedCapture', 'onSeekingCapture', 'onStalledCapture', 'onSuspendCapture', + 'onTimeUpdateCapture', 'onVolumeChangeCapture', 'onWaitingCapture', 'onSelectCapture', 'onTouchCancelCapture', 'onTouchEndCapture', + 'onTouchMoveCapture', 'onTouchStartCapture', 'onScrollCapture', 'onWheelCapture', 'onAnimationEndCapture', 'onAnimationIteration', + 'onAnimationStartCapture', 'onTransitionEndCapture', + 'onAuxClick', 'onAuxClickCapture', 'onClickCapture', 'onContextMenuCapture', 'onDoubleClickCapture', + 'onDragCapture', 'onDragEndCapture', 'onDragEnterCapture', 'onDragExitCapture', 'onDragLeaveCapture', + 'onDragOverCapture', 'onDragStartCapture', 'onDropCapture', 'onMouseDown', 'onMouseDownCapture', + 'onMouseMoveCapture', 'onMouseOutCapture', 'onMouseOverCapture', 'onMouseUpCapture', + // Video specific 'autoPictureInPicture', 'controlsList', 'disablePictureInPicture', 'disableRemotePlayback', ]; @@ -301,15 +315,26 @@ const ARIA_PROPERTIES = [ const REACT_ON_PROPS = [ 'onGotPointerCapture', + 'onGotPointerCaptureCapture', 'onLostPointerCapture', 'onPointerCancel', + 'onPointerCancelCapture', 'onPointerDown', + 'onPointerDownCapture', 'onPointerEnter', + 'onPointerEnterCapture', 'onPointerLeave', + 'onPointerLeaveCapture', 'onPointerMove', + 'onPointerMoveCapture', 'onPointerOut', + 'onPointerOutCapture', 'onPointerOver', + 'onPointerOverCapture', 'onPointerUp', + 'onPointerUpCapture', + 'onLostPointerCapture', + 'onLostPointerCaptureCapture', ]; function getDOMPropertyNames(context) { diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index 81484022f3..e14f7cb82e 100644 --- a/tests/lib/rules/no-unknown-property.js +++ b/tests/lib/rules/no-unknown-property.js @@ -73,7 +73,7 @@ ruleTester.run('no-unknown-property', rule, { // React related attributes { code: '
' }, { code: '' }, - { code: '
' }, + { code: '
' }, // Case ignored attributes, for `charset` discussion see https://github.com/jsx-eslint/eslint-plugin-react/pull/1863 { code: ';' }, { code: ';' },