Skip to content

Fix no-node-access false positives for object literal properties#1319

Open
sjh9714 wants to merge 1 commit into
testing-library:mainfrom
sjh9714:fix-no-node-access-object-literal-properties
Open

Fix no-node-access false positives for object literal properties#1319
sjh9714 wants to merge 1 commit into
testing-library:mainfrom
sjh9714:fix-no-node-access-object-literal-properties

Conversation

@sjh9714
Copy link
Copy Markdown

@sjh9714 sjh9714 commented May 17, 2026

Summary

Fixes false positives in no-node-access when accessing data properties such as children or activeElement on plain object literals.

What changed

  • Added regression coverage for object literal properties whose names overlap with DOM node properties.
  • Updated the rule to skip these accesses when the object resolves to an object literal declaring that property.
  • Preserved existing reports for Testing Library DOM node access, including query results and render containers.

Why

Issue #683 reports that no-node-access can report regular data objects if their property names overlap with DOM node-returning properties. These object properties are not direct DOM node access and should not be reported.

Testing

  • pnpm test tests/rules/no-node-access.test.ts
  • pnpm run lint
  • pnpm run type-check
  • pnpm test

Fixes #683

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.

False positive for no-node-access when accessing variable declaration's property children, activeElement, firstChild etc

1 participant