Skip to content

Fix/ast review issues#1662

Merged
Rel1cx merged 2 commits intomainfrom
fix/ast-review-issues
Mar 30, 2026
Merged

Fix/ast review issues#1662
Rel1cx merged 2 commits intomainfrom
fix/ast-review-issues

Conversation

@Rel1cx
Copy link
Copy Markdown
Owner

@Rel1cx Rel1cx commented Mar 30, 2026

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Perf
  • Docs
  • Test
  • Chore
  • Enhancement
  • 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

- fix(node-equality): handle JSXNamespacedName in JSXAttribute comparison
- fix(function-init-path): support ClassExpression in addition to ClassDeclaration
- docs: add clarifying comments for various utility functions
- test: add test cases to rule specs for the fixed issues
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

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

Project Deployment Actions Updated (UTC)
eslint-react Ready Ready Preview, Comment Mar 30, 2026 5:52am

Request Review

Copy link
Copy Markdown
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 updates the AST utilities and React-X rule test suite to address review feedback, including clarifying documentation, extending AST pattern support, and refreshing dependencies/lockfile entries.

Changes:

  • Bump tsl dependency across workspaces and update pnpm-lock.yaml accordingly.
  • Refine AST utilities (docs/notes, traversal behavior, init-path patterns, and node equality logic).
  • Add/extend rule tests to cover class expressions and JSX namespaced attribute scenarios.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Updates lockfile for the tsl bump and resulting dependency graph changes
package.json Bumps root tsl version
apps/website/package.json Bumps website workspace tsl version
.pkgs/configs/package.json Bumps configs workspace tsl version
packages/utilities/ast/src/function-init-path.ts Extends function init-path typing/logic to include ClassExpression patterns
packages/utilities/ast/src/node-equality.ts Adjusts JSXAttribute name equality comparison
packages/utilities/ast/src/node-traverse.ts Changes findParent to stop at Program (excludes Program from matches)
packages/utilities/ast/src/property-traverse.ts Clarifies spread handling limitations in docs/comments
packages/utilities/ast/src/node-types.ts Adds documentation clarifying JSX type vs runtime guard differences
packages/utilities/ast/src/node-is.ts Adds documentation note about isJSX coverage
packages/utilities/ast/src/identifier-name.ts Clarifies ASCII-only identifier heuristic in docs
packages/utilities/ast/src/file-directive.ts Updates docstring to match file-directive-only behavior
packages/utilities/ast/src/expression-nested.ts Adds clarifying comment about boundary behavior
packages/utilities/ast/src/directive-name.ts Clarifies heuristic nature of directive-name check
packages/core/src/component/component-flag.ts Reorders flag constants (no functional change)
packages/plugins/eslint-plugin-react-x/src/rules/no-unused-class-component-members/no-unused-class-component-members.spec.ts Adds coverage for class-expression class components
packages/plugins/eslint-plugin-react-x/src/rules/no-nested-component-definitions/no-nested-component-definitions.spec.ts Adds coverage for nested class-expression components
packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-key/no-duplicate-key.spec.ts Adds valid SVG namespaced-attribute case
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/utilities/ast/src/node-equality.ts:70

  • isNodeEqual now compares JSXAttribute.name via isNodeEqual(a.name, b.name), but this helper currently has no cases for JSX name node types (e.g. JSXIdentifier, JSXNamespacedName, JSXMemberExpression). As a result, JSX attribute name comparisons will always return false unless the nodes are the same reference, which breaks structural equality for JSXAttribute nodes. Add explicit handling for JSX name node types (and, if needed, JSXNamespacedName namespace+name) or revert to a correct name comparison implementation.
    case a.type === AST.JSXAttribute
      && b.type === AST.JSXAttribute: {
      if (!isNodeEqual(a.name, b.name)) {
        return false;
      }
      if (a.value == null || b.value == null) {
        return a.value === b.value;
      }
      return isNodeEqual(a.value, b.value);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Rel1cx Rel1cx merged commit 09df627 into main Mar 30, 2026
16 checks passed
@Rel1cx Rel1cx deleted the fix/ast-review-issues branch March 30, 2026 06:51
Rel1cx added a commit that referenced this pull request Mar 31, 2026
Cover the following changes introduced in PR #1660:
- find-import-source: circular reference guard with visited Set
- is-react-api: correct suffix matching with endsWith
- component-detection-legacy: isRenderMethodLike covers ClassExpression,
  isClassComponent with optional context, isThisSetState -> isThisSetStateCall
- hook-is: isHook -> isHookDefinition rename, isHookCallWithName un-exported

Cover the following changes introduced in PR #1662:
- function-init-path: support ClassExpression in addition to ClassDeclaration
- node-equality: handle JSXNamespacedName in JSXAttribute comparison

New test files:
- packages/core/src/api/find-import-source.test.ts (6 tests)
- packages/core/src/api/is-react-api.test.ts (32 tests)
- packages/core/src/component/component-detection-legacy.test.ts (13 tests)
- packages/core/src/hook/hook-is.test.ts (20 tests)
- packages/utilities/ast/src/function-init-path.test.ts (6 tests)
- packages/utilities/ast/src/node-equality.test.ts (16 tests)
Rel1cx added a commit that referenced this pull request Mar 31, 2026
…n cases to isNodeEqual

PR #1662 changed JSXAttribute name comparison from direct string
comparison to recursive isNodeEqual(a.name, b.name), but did not
add handling for JSX name node types. This caused JSXAttribute
structural equality to always return false for non-reference-equal
nodes, as JSXIdentifier / JSXNamespacedName / JSXMemberExpression
all fell through to the default case.
Rel1cx added a commit that referenced this pull request Mar 31, 2026
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