Skip to content

Commit

Permalink
Merge branch 'master' into prop-types-componentpropswithref
Browse files Browse the repository at this point in the history
  • Loading branch information
corydeppen authored Jan 18, 2025
2 parents 76a0e35 + e6b5b41 commit b87bf7c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## Unreleased

## [7.37.4] - 2025.01.12

### Fixed
* [`no-unknown-property`]: support `onBeforeToggle`, `popoverTarget`, `popoverTargetAction` attributes ([#3865][] @acusti)
* [types] fix types of flat configs ([#3874][] @ljharb)

[7.37.4]: https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.37.3...v7.37.4
[#3874]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3874
[#3865]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3865

## [7.37.3] - 2024.12.23

### Fixed
Expand Down
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,21 @@ const configs = {
'react/jsx-uses-react': SEVERITY_OFF,
},
},
flat: /** @type {Record<string, ReactFlatConfig>} */ ({
__proto__: null,
}),
};

/** @typedef {{ plugins: { react: typeof plugin }, rules: import('eslint').Linter.RulesRecord, languageOptions: { parserOptions: import('eslint').Linter.ParserOptions } }} ReactFlatConfig */

/** @type {{ deprecatedRules: typeof deprecatedRules, rules: typeof allRules, configs: typeof configs & { flat?: Record<string, ReactFlatConfig> }}} */
/** @type {{ deprecatedRules: typeof deprecatedRules, rules: typeof allRules, configs: typeof configs & { flat: Record<string, ReactFlatConfig> }}} */
const plugin = {
deprecatedRules,
rules: allRules,
configs,
};

/** @type {Record<string, ReactFlatConfig>} */
configs.flat = {
Object.assign(configs.flat, {
recommended: {
plugins: { react: plugin },
rules: configs.recommended.rules,
Expand All @@ -118,6 +120,6 @@ configs.flat = {
rules: configs['jsx-runtime'].rules,
languageOptions: { parserOptions: configs['jsx-runtime'].parserOptions },
},
};
});

module.exports = plugin;
8 changes: 5 additions & 3 deletions lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
'onCompositionUpdate', 'onCut', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave',
'onError', 'onFocus', 'onInput', 'onKeyDown', 'onKeyPress', 'onKeyUp', 'onLoad', 'onWheel', 'onDragOver',
'onDragStart', 'onDrop', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver',
'onMouseUp', 'onPaste', 'onScroll', 'onSelect', 'onSubmit', 'onToggle', 'onTransitionEnd', 'radioGroup', 'readOnly', 'referrerPolicy',
'rowSpan', 'srcDoc', 'srcLang', 'srcSet', 'useMap', 'fetchPriority',
'onMouseUp', 'onPaste', 'onScroll', 'onSelect', 'onSubmit', 'onBeforeToggle', 'onToggle', 'onTransitionEnd', 'radioGroup',
'readOnly', 'referrerPolicy', 'rowSpan', 'srcDoc', 'srcLang', 'srcSet', 'useMap', 'fetchPriority',
// SVG attributes
// See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
'crossOrigin', 'accentHeight', 'alignmentBaseline', 'arabicForm', 'attributeName',
Expand Down Expand Up @@ -317,9 +317,11 @@ const DOM_PROPERTY_NAMES_TWO_WORDS = [
'onMouseMoveCapture', 'onMouseOutCapture', 'onMouseOverCapture', 'onMouseUpCapture',
// Video specific
'autoPictureInPicture', 'controlsList', 'disablePictureInPicture', 'disableRemotePlayback',
// popovers
'popoverTarget', 'popoverTargetAction',
];

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

const ARIA_PROPERTIES = [
// See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react",
"version": "7.37.3",
"version": "7.37.4",
"author": "Yannick Croissant <[email protected]>",
"description": "React specific linting rules for ESLint",
"main": "index.js",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/eslint-parser": "^7.26.5",
"@babel/plugin-syntax-decorators": "^7.25.9",
"@babel/plugin-syntax-do-expressions": "^7.25.9",
"@babel/plugin-syntax-function-bind": "^7.25.9",
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ ruleTester.run('no-unknown-property', rule, {
</div>
`,
},
{
code: `
<div>
<button popoverTarget="my-popover" popoverTargetAction="toggle">Open Popover</button>
<div id="my-popover" onBeforeToggle={this.onBeforeToggle} popover>Greetings, one and all!</div>
</div>
`,
},
]),
invalid: parsers.all([
{
Expand Down

0 comments on commit b87bf7c

Please sign in to comment.