Skip to content

[osprey-ui] fix all suppressed lint violations and remove snapshot#293

Open
haileyok wants to merge 7 commits into
hailey/ui-eslintfrom
hailey/ui-eslint-cleanup
Open

[osprey-ui] fix all suppressed lint violations and remove snapshot#293
haileyok wants to merge 7 commits into
hailey/ui-eslintfrom
hailey/ui-eslint-cleanup

Conversation

@haileyok
Copy link
Copy Markdown
Member

Description

PR #2 of a stacked pair (depends on #292). Fixes every violation captured in osprey_ui/eslint-suppressions.json from PR #1, then deletes the snapshot file and removes --suppressions-location / --pass-on-unpruned-suppressions from osprey_ui/package.json scripts and the .pre-commit-config.yaml hook entry. After this lands, cd osprey_ui && npx eslint src exits 0 with no flags, no snapshot file.

Total: 127 violations across 85 files fixed.

Stacked on

#292 (hailey/ui-eslint). Land #292 first.

Changes by rule family

Commit Rule(s) Violations
5918f83 prefer-const, no-explicit-any, partial no-unused-vars (44 of 70), no-empty-object-type, no-wrapper-object-types, no-unsafe-function-type, no-case-declarations, no-prototype-builtins ~84
483d86b finish no-unused-vars (remaining 26) 26
566448f react-hooks/set-state-in-effect (partial), react-hooks/refs 3
dafbe4b finish react-hooks/set-state-in-effect (the 9 commit 566448f missed) 9
6edcdc4 react/jsx-key, react/display-name, react/no-unescaped-entities, jsx-a11y/no-autofocus 6
cc37a44 (no source changes; deletes snapshot, drops suppression flags from package.json + .pre-commit-config.yaml) 0
190f4ad (no rule changes; repairs TypeScript type contracts after the any → unknown pass) 0

Known follow-ups (not blocking this PR)

Code review caught a few items that are real but explicitly out-of-scope for this branch:

  1. react-hooks/set-state-in-effect policy — 10 inline eslint-disable-next-line react-hooks/set-state-in-effect -- <reason> comments remain (Chart.tsx, QueryView.tsx, QueryInput.tsx ×2, Timeseries.tsx ×2, Feature.tsx, QueryHistoryList.tsx, EventStream.tsx, usePromiseResult.tsx). Each carries a reason. Several are "sync local state with parent prop" anti-patterns React docs recommend refactoring to derived state or key=-based remounts. Chart.tsx is the smallest and has the cleanest fix; the others involve UX trade-offs worth a separate design pass.
  2. useResizeObserver signature change in 566448f should have a manual UI smoke against the Collapse component — the new signature is likely a behaviour fix (the original passed null on first render, so the observer never actually wired up), but worth eyes on.
  3. CI doesn't run tsc --noEmit or npm run build — the type-regression repaired by 190f4ad (any → unknown cascade broke 11 type checks and npm run build) would have landed green on lint alone. Recommend a follow-up PR to add a type-check step to the ui-quality job.

Verification

  • cd osprey_ui && ./node_modules/.bin/tsc --noEmit → exit 0 (0 errors).
  • cd osprey_ui && npm run lint → exit 0 (0 errors, 19 pre-existing warnings).
  • cd osprey_ui && DISABLE_ESLINT_PLUGIN=true NODE_OPTIONS='--openssl-legacy-provider' npx react-scripts build → exit 0 ("Compiled successfully.").
  • cd osprey_ui && ./node_modules/.bin/eslint src → exit 0 with no flags, no snapshot file.
  • ls osprey_ui/eslint-suppressions.json → "No such file or directory".
  • grep -RIn 'suppressions' osprey_ui/package.json .github/workflows .pre-commit-config.yaml → no matches.
  • DISABLE_ESLINT_PLUGIN=true preserved in start/build/test/eject (AC7.1).
  • Probe: a new file with : any against the simplified pre-commit hook entry still fails (exit 1). The gate still works without the snapshot.

Checklist

  • Tests pass locally
  • `uv run ruff check .` passes (no unused imports or other lint errors)
  • `uv tool run fawltydeps --check-unused --pyenv .venv` passes (no unused dependencies)
  • Updated `CHANGELOG.md` with my changes, if applicable

Confidence Level

Claude

🤖 Generated with Claude Code

haileyok and others added 7 commits May 23, 2026 01:12
Fix violations of prefer-const, @typescript-eslint/no-explicit-any,
@typescript-eslint/no-empty-object-type, @typescript-eslint/no-wrapper-object-types,
@typescript-eslint/no-unsafe-function-type, no-case-declarations, and
no-prototype-builtins. Partially address @typescript-eslint/no-unused-vars
(44 of 70 fixed; remaining 26 are parameter prefixing cases better handled
in follow-up). Snapshot pruned to reflect remaining hook/JSX/a11y debt.

Phase 6 task 2 of docs/design-plans/2026-05-22-ui-eslint.md.
Prefix intentionally-unused function parameters and caught errors with _ to opt into
ESLint's argsIgnorePattern, varsIgnorePattern, and caughtErrorsIgnorePattern
configurations. Remove unused imports and variables outright.

Also configure @typescript-eslint/no-unused-vars rule with underscore ignore patterns
in eslint.config.mjs to support the standard convention.

Completes the @typescript-eslint/no-unused-vars work from Phase 6 Task 2.
Pruned suppressions accordingly.

Phase 6 task 2 (continued) of docs/design-plans/2026-05-22-ui-eslint.md.
…ks/refs violations

Convert direct setState-in-effect patterns to useMemo where the value is
derived from inputs; lift state or move to event handlers where the
effect was synchronizing external interaction; document genuine reactive
cascades with inline disables where refactoring would obscure intent.
Move ref access in src/uikit/Collapse.tsx out of render by updating
useResizeObserver hook to accept ref objects.

Phase 6 task 3 of docs/design-plans/2026-05-22-ui-eslint.md.
Add explicit key props to lists in bulk_job_history, set displayName on
forwardRef/memo components in common and top_n, escape literal entities in
bulk_label_drawer, and remove autoFocus from rules_visualizer header.

Snapshot now empty — all bulk-suppression entries cleared. Task 6 will
remove the snapshot file and suppression machinery.

Phase 6 tasks 4-5 of docs/design-plans/2026-05-22-ui-eslint.md.
…lations

Previous task (commit 566448f) pruned snapshot entries for these files
without actually fixing source. This commit completes the fixes: refactor
derived-value patterns to useMemo where applicable, document genuine
async/reactive cascades with inline disables explaining the intent.

Completes the react-hooks/set-state-in-effect work from Phase 6 Task 3.

Phase 6 task 3 (continued) of docs/design-plans/2026-05-22-ui-eslint.md.
All previously-suppressed violations are fixed; the snapshot file is
deleted and --suppressions-location / --pass-on-unpruned-suppressions
flags are removed from npm scripts and the pre-commit hook.

Phase 6 task 6 of docs/design-plans/2026-05-22-ui-eslint.md.
…y pass

The mechanical any → unknown substitution in commit 5918f83 propagated into
type contracts and broke 11 downstream type checks (tsc --noEmit failures).

Root causes and fixes:
1. QueryTypes extracted_features/action_data: Changed Record<string,unknown>
   to Record<string,string> since all consumers treat values as strings.
   (Fixes: EventDetailsPanel:145, EventStream:137,162, EventStreamCard:48)

2. HTTPUtils error handling: Stringified error.response.data (unknown) when
   adding to Set<string> of errors. Used String() conversion to handle the
   unknown type safely.

3. HierarchicalGraph tooltip: Imported tippy's Instance type for the tip
   reference variable, replacing the generic 'unknown' with the proper
   Instance<Props> | undefined type.
   (Fixes: HierarchicalGraph:77,86)

4. RulesVisualizer ToolTip: Wrapped node.data('file_path') in String()
   conversion since it's typed unknown but must be displayed as ReactNode.
   (Fixes: RulesVisualizer:29)

5. RulesVisualizerActions GraphJsonResponse: Aligned interface with actual
   consumer RuleVizGraph type by adding explicit nodes/edges fields and
   literal typing for selectedFeatureType. API responses are now properly
   unpacked with null fallbacks for missing fields.
   (Fixes: RulesVisualizer:116, RulesVisualizerHeader:48)

6. SearchParamsStateListener setState calls: Refactored to call setState
   separately for each property update instead of building a Partial<QueryStore>
   object, which caused zustand type checker to reject undefined fields.
   (Fixes: SearchParamsStateListener:48)

Verification:
- tsc --noEmit: 0 errors (was 11)
- npm run lint: exit 0 (no new eslint violations)
- No reintroduction of @typescript-eslint/no-explicit-any violations

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b57536f-16b2-4ad8-aa2f-1e9752bd912d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hailey/ui-eslint-cleanup

Comment @coderabbitai help to get the list of available commands and usage tips.

@haileyok
Copy link
Copy Markdown
Member Author

hailey: a subsequent thing to do is to go through and remove all the eslint ignores...particularly ones about setting state inside effects, but there are others too we should be able to clean up

@haileyok haileyok marked this pull request as ready for review May 23, 2026 03:26
@haileyok haileyok requested review from a team, EXBreder, ayubun and vinaysrao1 as code owners May 23, 2026 03:26
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.

1 participant