fix(eslint-plugin-react-dom): add React 19 precedence and blocking attributes, closes #1789 - #1790
Merged
Merged
Conversation
…tributes - Add precedence and blocking to tag-specific attribute checks - Version-gate these attributes behind React >= 19.0.0-rc.0 - Update tests and changelog
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the react-dom/no-unknown-property rule to recognize React 19’s new tag-specific attributes (precedence, blocking) and apply tag-allowlist checks to avoid false positives on <style>, <link>, and <script> when targeting React 19+.
Changes:
- Added React 19 tag-specific attribute allowlists (
precedence,blocking) gated behind React>= 19.0.0-rc.0. - Updated the rule to use a React-version-aware attribute→allowed-tags map instead of the static map.
- Added/updated rule tests and documented the fix in the rule changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| plugins/eslint-plugin-react-dom/src/rules/no-unknown-property/no-unknown-property.ts | Switches to a version-aware attribute-tags map when validating tag-specific attributes. |
| plugins/eslint-plugin-react-dom/src/rules/no-unknown-property/lib.ts | Introduces React 19 tag-specific attribute map and an accessor to return the correct map per React version. |
| plugins/eslint-plugin-react-dom/src/rules/no-unknown-property/no-unknown-property.spec.ts | Adds coverage for precedence/blocking, including React 18 gating cases and new valid examples. |
| plugins/eslint-plugin-react-dom/src/rules/no-unknown-property/CHANGELOG.md | Documents the React 19 attribute fix under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
165
to
169
| // Check if attribute is allowed only on specific tags | ||
| const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) | ||
| ? ATTRIBUTE_TAGS_MAP[name] | ||
| const attributeTagsMap = getAttributeTagsMap(context); | ||
| const allowedTags = has(attributeTagsMap, name) | ||
| ? attributeTagsMap[name] | ||
| : null; |
Comment on lines
+914
to
+918
| export const REACT_19_PROPS: string[] = [ | ||
| ...POPOVER_API_PROPS, | ||
| ]; | ||
|
|
||
| /** |
Comment on lines
+653
to
656
| { code: '<link rel="stylesheet" href="styles.css" precedence="medium" />' }, | ||
| { code: '<style href="style.css" precedence="default">{`body { color: red; }`}</style>' }, | ||
| { code: '<script async src="script.js" blocking="render" />' }, | ||
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___)Other information
Added React 19
precedenceandblockingattributes to the tag-specific attribute checks inno-unknown-property, preventing false positives on<style>,<link>, and<script>elements when using React 19 or later.