Skip to content

Commit 73a1461

Browse files
authored
[Fix] no-unknown-property: support onBeforeToggle, popoverTarget, popoverTargetAction attributes
1 parent 66ae4c1 commit 73a1461

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
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-danger`]: avoid a crash on a nested component name ([#3833][] @ljharb)
1212
* [Fix] types: correct generated type declaration ([#3840][] @ocavue)
1313
* [`no-unknown-property`]: support `precedence` prop in react 19 ([#3829][] @acusti)
14+
* [`no-unknown-property`]: support `onBeforeToggle`, `popoverTarget`, `popoverTargetAction` attributes ([#3865][] @acusti)
1415

1516
### Changed
1617
* [Tests] [`jsx-no-script-url`]: Improve tests ([#3849][] @radu2147)
@@ -21,6 +22,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2122
[#3840]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3840
2223
[#3833]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3833
2324
[#3829]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3829
25+
[#3865]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3865
2426

2527
## [7.37.2] - 2024.10.22
2628

lib/rules/no-unknown-property.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ const DOM_PROPERTY_NAMES_ONE_WORD = [
240240
// Video specific
241241
'controls',
242242
// popovers
243-
'popover', 'popovertarget', 'popovertargetaction',
243+
'popover',
244244
];
245245

246246
const DOM_PROPERTY_NAMES_TWO_WORDS = [
@@ -259,8 +259,8 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
259259
'onCompositionUpdate', 'onCut', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave',
260260
'onError', 'onFocus', 'onInput', 'onKeyDown', 'onKeyPress', 'onKeyUp', 'onLoad', 'onWheel', 'onDragOver',
261261
'onDragStart', 'onDrop', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver',
262-
'onMouseUp', 'onPaste', 'onScroll', 'onSelect', 'onSubmit', 'onToggle', 'onTransitionEnd', 'radioGroup', 'readOnly', 'referrerPolicy',
263-
'rowSpan', 'srcDoc', 'srcLang', 'srcSet', 'useMap', 'fetchPriority',
262+
'onMouseUp', 'onPaste', 'onScroll', 'onSelect', 'onSubmit', 'onBeforeToggle', 'onToggle', 'onTransitionEnd', 'radioGroup',
263+
'readOnly', 'referrerPolicy', 'rowSpan', 'srcDoc', 'srcLang', 'srcSet', 'useMap', 'fetchPriority',
264264
// SVG attributes
265265
// See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
266266
'crossOrigin', 'accentHeight', 'alignmentBaseline', 'arabicForm', 'attributeName',
@@ -317,6 +317,8 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
317317
'onMouseMoveCapture', 'onMouseOutCapture', 'onMouseOverCapture', 'onMouseUpCapture',
318318
// Video specific
319319
'autoPictureInPicture', 'controlsList', 'disablePictureInPicture', 'disableRemotePlayback',
320+
// popovers
321+
'popoverTarget', 'popoverTargetAction',
320322
];
321323

322324
const DOM_PROPERTIES_IGNORE_CASE = ['charset', 'allowFullScreen', 'webkitAllowFullScreen', 'mozAllowFullScreen', 'webkitDirectory'];

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,14 @@ ruleTester.run('no-unknown-property', rule, {
182182
{
183183
code: `
184184
<div>
185-
<button popovertarget="my-popover" popovertargetaction="toggle">Open Popover</button>
185+
<button popoverTarget="my-popover" popoverTargetAction="toggle">Open Popover</button>
186186
187-
<div popover id="my-popover">Greetings, one and all!</div>
187+
<div id="my-popover" onBeforeToggle={this.onBeforeToggle} popover>Greetings, one and all!</div>
188188
</div>
189189
`,
190+
settings: {
191+
react: { version: '19.0.0' },
192+
},
190193
},
191194
]),
192195
invalid: parsers.all([

0 commit comments

Comments
 (0)