Skip to content

chore(eslint): enable @eslint-react/purity rule#1051

Draft
carlosthe19916 wants to merge 4 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-purity
Draft

chore(eslint): enable @eslint-react/purity rule#1051
carlosthe19916 wants to merge 4 commits into
guacsec:mainfrom
carlosthe19916:hotfix/enable-purity

Conversation

@carlosthe19916
Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 commented May 27, 2026

Summary

  • Remove the @eslint-react/purity override from ESLint config
  • Replace document.createElement("span") with useRef(null) in PageDrawerContext
  • Extract new Date().getFullYear() to module-level constant in about.tsx

Test plan

  • npm run lint passes with 0 warnings

🤖 Generated with Claude Code

Summary by Sourcery

Enable the @eslint-react/purity rule and adjust React components to comply with purity constraints.

Enhancements:

  • Replace DOM-based ref initialization in PageDrawerContext with a typed React ref using a null initial value.
  • Extract the current year computation in about.tsx into a module-level constant to avoid recomputing it on each render.

Build:

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

Move impure calls out of render:
- Replace document.createElement("span") with useRef(null) in PageDrawerContext
- Extract new Date().getFullYear() to module-level constant in about.tsx

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/purity rule by removing its override, and updates React components to avoid impure render-time side effects by using a ref initialized to null and hoisting a Date computation to module scope.

File-Level Changes

Change Details Files
Make About dialog footer text compliant with purity/side‑effect rules by hoisting Date computation.
  • Introduce a module-level CURRENT_YEAR constant initialized with new Date().getFullYear().
  • Replace inline new Date().getFullYear() in the trademark string with the CURRENT_YEAR constant.
client/src/app/layout/about.tsx
Fix PageDrawerContext focus ref initialization to avoid DOM mutation during render.
  • Change drawerFocusRef initialization from React.useRef(document.createElement("span")) to React.useRef(null) so the DOM node is provided later rather than created during render.
client/src/app/components/PageDrawerContext.tsx
Enable @eslint-react/purity lint rule for React codebase.
  • Remove the '@eslint-react/purity': 'off' override from the ESLint flat config so the rule runs with its default behavior.
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:

  • Now that drawerFocusRef is initialized with null instead of an actual span element, double-check all usages to ensure they handle the potentially null current value (e.g., optional chaining or early returns before calling .focus() or similar).
  • If the AboutApp component can stay mounted across a year boundary (e.g., long-lived admin consoles), consider computing the year at render-time or when needed instead of at module-load, so the displayed copyright year stays accurate without a full reload.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that `drawerFocusRef` is initialized with `null` instead of an actual `span` element, double-check all usages to ensure they handle the potentially null `current` value (e.g., optional chaining or early returns before calling `.focus()` or similar).
- If the `AboutApp` component can stay mounted across a year boundary (e.g., long-lived admin consoles), consider computing the year at render-time or when needed instead of at module-load, so the displayed copyright year stays accurate without a full reload.

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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.69%. Comparing base (16a6bec) to head (5f45e14).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1051   +/-   ##
=======================================
  Coverage   50.68%   50.69%           
=======================================
  Files         253      253           
  Lines        5499     5500    +1     
  Branches     1660     1660           
=======================================
+ Hits         2787     2788    +1     
- Misses       2440     2441    +1     
+ Partials      272      271    -1     
Flag Coverage Δ
e2e 68.94% <100.00%> (+<0.01%) ⬆️
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