Skip to content

Commit 500112b

Browse files
committed
[Fix] no-unknown-property support new precedence prop
Fixes #3827
1 parent 9668ee0 commit 500112b

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
66

77
## Unreleased
88

9+
### Fixed
10+
* [`no-unknown-property`]: support `precedence` prop ([#3829][] @acusti)
11+
12+
[#3829]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3829
13+
914
## [7.36.1] - 2024.09.12
1015

1116
### Fixed

lib/rules/no-unknown-property.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const DOM_PROPERTY_NAMES_ONE_WORD = [
234234
// OpenGraph meta tag attributes
235235
'property',
236236
// React specific attributes
237-
'ref', 'key', 'children',
237+
'ref', 'key', 'children', 'precedence',
238238
// Non-standard
239239
'results', 'security',
240240
// Video specific
@@ -363,16 +363,20 @@ const REACT_ON_PROPS = [
363363
];
364364

365365
function getDOMPropertyNames(context) {
366-
const ALL_DOM_PROPERTY_NAMES = DOM_PROPERTY_NAMES_TWO_WORDS.concat(DOM_PROPERTY_NAMES_ONE_WORD);
366+
let domPropertyNames = DOM_PROPERTY_NAMES_TWO_WORDS.concat(DOM_PROPERTY_NAMES_ONE_WORD);
367367
// this was removed in React v16.1+, see https://github.com/facebook/react/pull/10823
368368
if (!testReactVersion(context, '>= 16.1.0')) {
369-
return ALL_DOM_PROPERTY_NAMES.concat('allowTransparency');
369+
return domPropertyNames.concat('allowTransparency');
370370
}
371371
// these were added in React v16.4.0, see https://reactjs.org/blog/2018/05/23/react-v-16-4.html and https://github.com/facebook/react/pull/12507
372372
if (testReactVersion(context, '>= 16.4.0')) {
373-
return ALL_DOM_PROPERTY_NAMES.concat(REACT_ON_PROPS);
373+
domPropertyNames = domPropertyNames.concat(REACT_ON_PROPS);
374+
// precedence was added in React v19, see https://react.dev/blog/2024/04/25/react-19#support-for-stylesheets
375+
if (testReactVersion(context, '>= 19.0.0-0')) {
376+
domPropertyNames = domPropertyNames.concat('precedence');
377+
}
374378
}
375-
return ALL_DOM_PROPERTY_NAMES;
379+
return domPropertyNames;
376380
}
377381

378382
// ------------------------------------------------------------------------------

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ruleTester.run('no-unknown-property', rule, {
8989
{ code: '<div onPointerDown={this.onDown} onPointerUp={this.onUp} />' },
9090
{ code: '<input type="checkbox" defaultChecked={this.state.checkbox} />' },
9191
{ code: '<div onTouchStart={this.startAnimation} onTouchEnd={this.stopAnimation} onTouchCancel={this.cancel} onTouchMove={this.move} onMouseMoveCapture={this.capture} onTouchCancelCapture={this.log} />' },
92+
{ code: '<link precedence="medium" href="https://foo.bar" rel="canonical" />' },
9293
// Case ignored attributes, for `charset` discussion see https://github.com/jsx-eslint/eslint-plugin-react/pull/1863
9394
{ code: '<meta charset="utf-8" />;' },
9495
{ code: '<meta charSet="utf-8" />;' },

0 commit comments

Comments
 (0)