Skip to content

chore(eslint): enable @eslint-react/rules-of-hooks rule#1053

Draft
carlosthe19916 wants to merge 4 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-rules-of-hooks
Draft

chore(eslint): enable @eslint-react/rules-of-hooks rule#1053
carlosthe19916 wants to merge 4 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-rules-of-hooks

Conversation

@carlosthe19916
Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 commented May 27, 2026

Summary

  • Remove the @eslint-react/rules-of-hooks override from ESLint config
  • Rename usePathFromParamsgetPathFromParams since it's a plain utility, not a React hook
  • Call useAuth() unconditionally in header.tsx (was conditionally called via &&)
  • Suppress false positive for Playwright's use() fixture function in e2e tests

Test plan

  • npm run lint passes with 0 warnings

🤖 Generated with Claude Code

Summary by Sourcery

Enable enforcement of React rules-of-hooks in ESLint and update code to comply with the rule.

Bug Fixes:

  • Suppress a false-positive rules-of-hooks violation for Playwright's use() fixture in e2e tests.

Enhancements:

  • Rename the path helper from a React-style hook name to a plain utility name and update its call sites.
  • Adjust header authentication logic to call the auth hook unconditionally while preserving conditional usage semantics.

Build:

  • Remove the override that disabled the @eslint-react/rules-of-hooks rule from the ESLint configuration.

- Rename usePathFromParams to getPathFromParams (not a hook)
- Call useAuth() unconditionally in header.tsx
- Suppress false positive for Playwright fixture use() in e2e

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

sourcery-ai Bot commented May 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enables the @eslint-react/rules-of-hooks rule by treating a routing helper as a plain utility instead of a React hook, fixing a conditional hook usage in the header, and adding a targeted lint suppression for a Playwright fixture, while removing the rule’s override from the ESLint config.

Sequence diagram for HeaderApp useAuth hook usage

sequenceDiagram
  participant HeaderApp
  participant useAuth

  HeaderApp->>useAuth: useAuth()
  useAuth-->>HeaderApp: authFromHook
  HeaderApp->>HeaderApp: [isAuthRequired]
  HeaderApp->>HeaderApp: auth = authFromHook
  HeaderApp->>HeaderApp: [!isAuthRequired]
  HeaderApp->>HeaderApp: auth = undefined
Loading

Flow diagram for getPathFromParams usage in route loaders

flowchart TD
  subgraph Routes
    A[Params]
    B[PathParam]
    C[getPathFromParams]
  end

  subgraph Loaders
    L1[advisory loader]
    L2[package loader]
    L3[sbom loader]
    L4[vulnerability loader]
    L5[sbomGroup loader]
  end

  A --> C
  B --> C
  C --> L1
  C --> L2
  C --> L3
  C --> L4
  C --> L5
Loading

File-Level Changes

Change Details Files
Rename the routing params helper from a hook-style name to a plain utility and update its call sites.
  • Rename usePathFromParams to getPathFromParams while keeping its implementation and signature the same.
  • Update all router loader functions to call getPathFromParams instead of usePathFromParams for extracting IDs from params.
client/src/app/Routes.tsx
Fix conditional React hook usage in the header component to comply with rules-of-hooks.
  • Change useAuth() usage so it is always called unconditionally at the top of HeaderApp.
  • Derive the auth value based on isAuthRequired from the hook result instead of conditionally calling the hook.
client/src/app/layout/header.tsx
Add a scoped lint suppression for a non-React use() helper in Playwright fixtures and enable the hooks rule in ESLint.
  • Add an @eslint-react/rules-of-hooks disable-next-line comment before the Playwright use() call, documenting it as a fixture helper, not a React hook.
  • Remove the override that disabled @eslint-react/rules-of-hooks from the shared ESLint configuration so the rule now runs project-wide.
e2e/tests/api/fixtures.ts
eslint.config.mjs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 50.67%. Comparing base (16a6bec) to head (83fbb55).

Files with missing lines Patch % Lines
client/src/app/layout/header.tsx 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1053      +/-   ##
==========================================
- Coverage   50.68%   50.67%   -0.01%     
==========================================
  Files         253      253              
  Lines        5499     5500       +1     
  Branches     1660     1660              
==========================================
  Hits         2787     2787              
- Misses       2440     2441       +1     
  Partials      272      272              
Flag Coverage Δ
e2e 68.91% <87.50%> (-0.02%) ⬇️
unit 2.01% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carlosthe19916 carlosthe19916 marked this pull request as draft May 27, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant