From d690f841d826b88788c0076358c83c68d1f11d20 Mon Sep 17 00:00:00 2001 From: Hasegawa-Yukihiro Date: Fri, 13 Jun 2025 21:40:40 +0900 Subject: [PATCH 1/2] fix: remove 'blur' from EVENT_HANDLER_METHODS to streamline event handling --- lib/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/index.ts b/lib/utils/index.ts index f5e094ea..299d4c36 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -114,7 +114,7 @@ const METHODS_RETURNING_NODES = [ 'querySelectorAll', ] as const; -const EVENT_HANDLER_METHODS = ['click', 'blur', 'select', 'submit'] as const; +const EVENT_HANDLER_METHODS = ['click', 'select', 'submit'] as const; const ALL_RETURNING_NODES = [ ...PROPERTIES_RETURNING_NODES, From f812c8fbdd1d150f20405997465d60a762f79aa4 Mon Sep 17 00:00:00 2001 From: Hasegawa-Yukihiro Date: Fri, 13 Jun 2025 21:45:05 +0900 Subject: [PATCH 2/2] docs: update doc --- docs/rules/no-node-access.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/no-node-access.md b/docs/rules/no-node-access.md index 0bb5d5a8..3ae667b7 100644 --- a/docs/rules/no-node-access.md +++ b/docs/rules/no-node-access.md @@ -11,7 +11,7 @@ Disallow direct access or manipulation of DOM nodes in favor of Testing Library' This rule aims to disallow direct access and manipulation of DOM nodes using native HTML properties and methods — including traversal (e.g. `closest`, `lastChild`) as well as direct actions (e.g. `click()`, `select()`). Use Testing Library’s queries and userEvent APIs instead. > [!NOTE] -> This rule does not report usage of `focus()`, because imperative focus (e.g. `getByText('focus me').focus()`) is recommended over `fireEvent.focus()`. +> This rule does not report usage of `focus()` or `blur()`, because imperative usage (e.g. `getByText('focus me').focus()` or .`blur()`) is recommended over `fireEvent.focus()` or `fireEvent.blur()`. > If an element is not focusable, related assertions will fail, leading to more robust tests. See [Testing Library Events Guide](https://testing-library.com/docs/guide-events/) for more details. Examples of **incorrect** code for this rule: