-
-
Notifications
You must be signed in to change notification settings - Fork 29
Refactor getJsxAttribute utility function
#1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The commit consolidates attribute lookup functionality by removing the redundant hasJsxAttribute function and improving the getJsxAttribute API. The main changes: - Change getJsxAttribute to accept JSXElement node instead of attributes array - Add JSDoc comments explaining the function purpose and params - Remove the separate hasJsxAttribute function since it can be replaced with getJsxAttribute(ctx, node)(name) != null - Update all usage sites to use the new API - Use consistent "prop" terminology instead of mixing "attribute" and "prop"
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the getJsxAttribute utility function to improve its API design by accepting a JSXElement node instead of an attributes array, while removing the redundant hasJsxAttribute function. The refactor standardizes terminology by consistently using "prop" instead of mixing "attribute" and "prop".
- Changes
getJsxAttributeto accept JSXElement node and automatically extract attributes - Removes
hasJsxAttributefunction since it can be replaced withgetJsxAttribute(ctx, node)(name) != null - Updates all usage sites across multiple rule files to use the simplified API
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/jsx/jsx-attribute.ts | Refactors getJsxAttribute function API and removes hasJsxAttribute |
| packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-x/src/rules/no-missing-key.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-x/src/rules/no-implicit-key.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-x/src/rules/no-children-prop.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-dom/src/utils/create-jsx-element-resolver.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-void-elements-with-children.ts | Updates to use new getJsxAttribute API and terminology |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-target-blank.ts | Updates to use new getJsxAttribute API and terminology |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-unsafe-iframe-sandbox.ts | Updates to use new getJsxAttribute API and terminology |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-string-style-prop.ts | Updates to use new getJsxAttribute API and terminology |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-iframe-sandbox.ts | Updates to use new getJsxAttribute API and terminology |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-button-type.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml.ts | Updates to use new getJsxAttribute API |
| packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts | Updates to use new getJsxAttribute API |
| packages/core/docs/functions/hasJsxAttribute.md | Removes documentation for deleted hasJsxAttribute function |
| packages/core/docs/functions/getJsxAttribute.md | Updates documentation for new getJsxAttribute API |
| packages/core/docs/README.md | Removes hasJsxAttribute from function list |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts
Outdated
Show resolved
Hide resolved
…agment.ts Co-authored-by: Copilot <[email protected]> Signed-off-by: REL1CX <[email protected]>
The commit consolidates attribute lookup functionality by removing the redundant hasJsxAttribute function and improving the getJsxAttribute API.
The main changes:
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___)Other information