From dc45803d13cf7b9a276398f3e8e585276ec04b53 Mon Sep 17 00:00:00 2001 From: Hasegawa-Yukihiro Date: Thu, 19 Mar 2026 12:29:29 +0900 Subject: [PATCH 1/2] fix: prevent duplicate errors for chained property access --- src/rules/no-node-access.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rules/no-node-access.ts b/src/rules/no-node-access.ts index f711267e..ba195cb0 100644 --- a/src/rules/no-node-access.ts +++ b/src/rules/no-node-access.ts @@ -65,6 +65,12 @@ export default createTestingLibraryRule({ return; } + // Skip if this MemberExpression is the object of another MemberExpression + // to avoid duplicate reports for chained property access + if (isMemberExpression(node.parent) && node.parent.object === node) { + return; + } + const propertyName = ASTUtils.isIdentifier(node.property) ? node.property.name : null; From 547177ca23cf8a316b6050667189dba7d8e9717e Mon Sep 17 00:00:00 2001 From: Hasegawa-Yukihiro Date: Thu, 19 Mar 2026 12:29:37 +0900 Subject: [PATCH 2/2] test: add test --- tests/rules/no-node-access.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/rules/no-node-access.test.ts b/tests/rules/no-node-access.test.ts index fe39f57f..2c82251e 100644 --- a/tests/rules/no-node-access.test.ts +++ b/tests/rules/no-node-access.test.ts @@ -527,6 +527,33 @@ ruleTester.run(rule.name, rule, { }, { code: ` + import { screen } from '${testingFramework}'; + + const rowHeader = screen.getByRole('rowheader'); + const radioContainer = + (rowHeader.parentElement && rowHeader.parentElement.nextElementSibling) || + rowHeader.parentElement; + `, + errors: [ + { + line: 6, + column: 24, + messageId: 'noNodeAccess', + }, + { + line: 6, + column: 65, + messageId: 'noNodeAccess', + }, + { + line: 7, + column: 23, + messageId: 'noNodeAccess', + }, + ], + }, + { + code: ` import { render } from '${testingFramework}'; const { getByText } = render()