Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/oxlint-plugin-react-doctor/src/plugin/constants/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ export const EXTERNAL_SYNC_OBSERVER_CONSTRUCTORS = new Set([
]);

export const STORAGE_OBJECTS = new Set(["localStorage", "sessionStorage"]);

export const KEYBOARD_EVENT_NAMES = new Set(["keydown", "keyup", "keypress"]);

export const KEYBIND_LIBRARY_PACKAGES: ReadonlyArray<string> = [
"react-hotkeys-hook",
"react-hotkeys",
"@mantine/hooks",
"tinykeys",
"hotkeys-js",
"mousetrap",
"@react-hook/hotkey",
"use-hotkeys",
"@invoke-ai/ui-library",
];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Broad package names in KEYBIND_LIBRARY_PACKAGES may cause per-file false negatives

@mantine/hooks and @invoke-ai/ui-library are general-purpose packages that happen to include keybind functionality. If a file imports any hook/component from these packages (e.g., import { useDebouncedValue } from '@mantine/hooks'), the rule suppresses all keyboard listener warnings for that file, even if the import is unrelated to keybinds. This is a per-file check (not per-project), so the impact is limited to files that both import from one of these broad packages AND have manual keyboard listeners. The design choice is defensible — the user already has the keybind tool available — but it does mean some real cases will be silently skipped.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will produce edge cases we should detect. imo this list isn''t even needed if the purpose is to tell people not use manual keyboard listneerr,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just flag all manual impls, better to have false positives than false negatives

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — removed KEYBIND_LIBRARY_PACKAGES entirely and the library-detection skip. The rule now flags all manual keyboard listener implementations unconditionally. Better to have false positives than false negatives here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already addressed in ed5221bKEYBIND_LIBRARY_PACKAGES and the library-detection skip were removed entirely. The rule now flags all manual keyboard listeners unconditionally, so this false-negative scenario no longer applies.

15 changes: 15 additions & 0 deletions packages/oxlint-plugin-react-doctor/src/plugin/rule-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { checkedRequiresOnchangeOrReadonly } from "./rules/react-builtins/checke
import { clickEventsHaveKeyEvents } from "./rules/a11y/click-events-have-key-events.js";
import { clientLocalstorageNoVersion } from "./rules/client/client-localstorage-no-version.js";
import { clientPassiveEventListeners } from "./rules/client/client-passive-event-listeners.js";
import { clientPreferKeybindLibrary } from "./rules/client/client-prefer-keybind-library.js";
import { controlHasAssociatedLabel } from "./rules/a11y/control-has-associated-label.js";
import { noBoldHeading } from "./rules/react-ui/no-bold-heading.js";
import { noEmDashInJsxText } from "./rules/react-ui/no-em-dash-in-jsx-text.js";
Expand Down Expand Up @@ -562,6 +563,20 @@ export const reactDoctorRules = [
category: "Performance",
},
},
{
key: "react-doctor/client-prefer-keybind-library",
id: "client-prefer-keybind-library",
source: "react-doctor",
originallyExternal: false,
framework: "global",
category: "Performance",
severity: "warn",
rule: {
...clientPreferKeybindLibrary,
framework: "global",
category: "Performance",
},
},
{
key: "react-doctor/control-has-associated-label",
id: "control-has-associated-label",
Expand Down
Loading
Loading