Skip to content

Conversation

@Rel1cx
Copy link
Owner

@Rel1cx Rel1cx commented Oct 1, 2025

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"

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • Test
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • I have added a convincing reason for adding this feature, if necessary

Other information

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"
@Rel1cx Rel1cx requested a review from Copilot October 1, 2025 10:15
@vercel
Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
eslint-react Ready Ready Preview Comment Oct 1, 2025 10:20am

@Rel1cx Rel1cx marked this pull request as ready for review October 1, 2025 10:15
Copy link
Contributor

Copilot AI left a 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 getJsxAttribute to accept JSXElement node and automatically extract attributes
  • Removes hasJsxAttribute function since it can be replaced with getJsxAttribute(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.

@Rel1cx Rel1cx merged commit 0552d24 into main Oct 1, 2025
11 of 12 checks passed
@Rel1cx Rel1cx deleted the refactor-get-jsx-attribute-utility-function branch October 1, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants