From 32119f908da4577f8f6c752b5f9002ac79c0ca9a Mon Sep 17 00:00:00 2001 From: Senja Jarva Date: Mon, 5 Sep 2022 14:19:45 +0300 Subject: [PATCH] [Fix] `no-unknown-property`: add more capture event properties Fixes #3400. --- CHANGELOG.md | 2 ++ lib/rules/no-unknown-property.js | 31 +++++++++++++++++++++++--- tests/lib/rules/no-unknown-property.js | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3e3aac813..6df9c7c6fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [`no-unknown-property`]: add `download` property support for `a` and `area` ([#3394][] @HJain13) * [`no-unknown-property`]: allow `webkitAllowFullScreen` and `mozAllowFullScreen` ([#3396][] @ljharb) * [`no-unknown-property`]: `controlsList`, not `controlList` ([#3397][] @ljharb) +* [`no-unknown-property`]: add more capture event properties ([#3402][] @sjarva) +[#3402]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3402 [#3397]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3397 [#3396]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3396 [#3394]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3394 diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 09236d5ca9..4ef0304ab1 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', 'onLostPointerCapture', + 'onLostPointerCaptureCapture', 'onPointerCancel', + 'onPointerCancelCapture', 'onPointerDown', + 'onPointerDownCapture', 'onPointerEnter', + 'onPointerEnterCapture', 'onPointerLeave', + 'onPointerLeaveCapture', 'onPointerMove', + 'onPointerMoveCapture', 'onPointerOut', + 'onPointerOutCapture', 'onPointerOver', + 'onPointerOverCapture', 'onPointerUp', + 'onPointerUpCapture', ]; function getDOMPropertyNames(context) { diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index 38d42118bc..c713ec9239 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: ';' },