Skip to content

chore(eslint): enable @eslint-react/no-unnecessary-use-prefix rule#1058

Draft
carlosthe19916 wants to merge 5 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-no-unnecessary-use-prefix
Draft

chore(eslint): enable @eslint-react/no-unnecessary-use-prefix rule#1058
carlosthe19916 wants to merge 5 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-no-unnecessary-use-prefix

Conversation

@carlosthe19916
Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 commented May 27, 2026

Summary

  • Remove the @eslint-react/no-unnecessary-use-prefix override from ESLint config
  • Rename functions that have use prefix but don't call any React hooks:
    • usePathFromParamsgetPathFromParams
    • useExpansionPropHelpersgetExpansionPropHelpers
    • useFilterPropHelpersgetFilterPropHelpers
    • useSortPropHelpersgetSortPropHelpers
    • useBrandinggetBranding
    • usePersistenceProvidergetPersistenceProvider

Test plan

  • npm run lint passes with 0 warnings

🤖 Generated with Claude Code

Summary by Sourcery

Enable the @eslint-react/no-unnecessary-use-prefix ESLint rule and align helper function naming with React hook conventions.

Enhancements:

  • Rename non-hook helper functions from a use* prefix to a get* prefix across routing, table controls, branding, and persistence utilities to better reflect their behavior.

Build:

  • Remove the override disabling @eslint-react/no-unnecessary-use-prefix in the ESLint configuration so the rule is enforced project-wide.

Rename functions that have 'use' prefix but don't call React hooks:
- usePathFromParams → getPathFromParams
- useExpansionPropHelpers → getExpansionPropHelpers
- useFilterPropHelpers → getFilterPropHelpers
- useSortPropHelpers → getSortPropHelpers
- useBranding → getBranding
- usePersistenceProvider → getPersistenceProvider

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

Enables the @eslint-react/no-unnecessary-use-prefix rule by renaming non-hook utility functions and helpers to drop the misleading use prefix and wiring those new names through all call sites and documentation comments, plus removing the ESLint override.

File-Level Changes

Change Details Files
Rename route param helper from a hook-style name to a pure utility and update all router loaders to use it.
  • Rename usePathFromParams to getPathFromParams while keeping its behavior the same.
  • Update all React Router loaders in AppRoutes to call getPathFromParams instead of usePathFromParams.
client/src/app/Routes.tsx
Rename table control helper factories from use* to get* and update their consumers.
  • Rename useFilterPropHelpers to getFilterPropHelpers and adjust its JSDoc.
  • Rename useSortPropHelpers to getSortPropHelpers and adjust its JSDoc.
  • Rename useExpansionPropHelpers to getExpansionPropHelpers and adjust its JSDoc.
  • Update useTableControlProps to call the new get* helpers while continuing to treat useTableControlProps itself as a hook.
client/src/app/hooks/table-controls/useTableControlProps.ts
client/src/app/hooks/table-controls/expansion/useExpansionPropHelpers.ts
client/src/app/hooks/table-controls/sorting/useSortPropHelpers.ts
client/src/app/hooks/table-controls/filtering/useFilterPropHelpers.ts
Rename branding accessor from useBranding to getBranding and update imports and usage.
  • Change the branding helper implementation and default export from useBranding to getBranding.
  • Update components using branding (DocumentMetadata, AboutApp, HeaderApp) to import and call getBranding instead of useBranding.
client/src/app/hooks/useBranding.ts
client/src/app/components/DocumentMetadata.tsx
client/src/app/layout/about.tsx
client/src/app/layout/header.tsx
Rename persistence provider factory from a hook-like name to a pure helper and update its caller.
  • Rename the internal helper usePersistenceProvider to getPersistenceProvider in usePersistentState.
  • Update the usePersistentState hook to reference getPersistenceProvider when constructing the persistence layer.
client/src/app/hooks/usePersistentState.ts
Enable the ESLint rule disallowing unnecessary use prefixes in non-hook functions.
  • Remove the @eslint-react/no-unnecessary-use-prefix override from the ESLint configuration so the rule is now active.
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 left some high level feedback:

  • The useBranding module is still defined in hooks/useBranding.ts, but some imports were changed to @app/hooks/getBranding; either rename the file to getBranding.ts or keep importing from @app/hooks/useBranding to avoid broken module resolution.
  • Since useBranding is now exported as getBranding by default, check for any remaining import useBranding from "@app/hooks/useBranding" usages and update them for consistency with the new naming.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `useBranding` module is still defined in `hooks/useBranding.ts`, but some imports were changed to `@app/hooks/getBranding`; either rename the file to `getBranding.ts` or keep importing from `@app/hooks/useBranding` to avoid broken module resolution.
- Since `useBranding` is now exported as `getBranding` by default, check for any remaining `import useBranding from "@app/hooks/useBranding"` usages and update them for consistency with the new naming.

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.

The function was renamed to getBranding but the file is still
useBranding.ts — keep import paths pointing to the file name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@carlosthe19916 carlosthe19916 marked this pull request as draft May 27, 2026 12:14
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.66%. Comparing base (16a6bec) to head (846c900).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1058      +/-   ##
==========================================
- Coverage   50.68%   50.66%   -0.02%     
==========================================
  Files         253      253              
  Lines        5499     5499              
  Branches     1660     1660              
==========================================
- Hits         2787     2786       -1     
- Misses       2440     2441       +1     
  Partials      272      272              
Flag Coverage Δ
e2e 68.91% <100.00%> (-0.03%) ⬇️
unit 2.01% <0.00%> (ø)

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.

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