Skip to content

refactor: extract duplicated code patterns into shared utilities - #2

Closed
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1787802589-shared-utilities-refactor
Closed

refactor: extract duplicated code patterns into shared utilities#2
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1787802589-shared-utilities-refactor

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Description

Extracts several duplicated code patterns into shared utilities/hooks:

  • src/utils/useResponsiveSlider.js — shared react-slick slider lifecycle (client detection, viewport-based slidesToShow, debounced resize/load handling, optional image-load listeners, innerSlider.onWindowResized() refresh, cleanup). Adopted by:
    • src/components/Related-Posts/index.js
    • src/sections/Home/So-Special-Section/index.js
    • src/sections/Pricing/review-slider.js (keeps its .slider img load listeners via watchImagesSelector)
    • Per-component breakpoint→slides mappings are preserved unchanged via a computeSlides callback.
  • src/utils/useScrollTiltEffect.js — shared scroll-driven rotateX() tilt effect previously duplicated in src/sections/FeatureHero/index.js and src/sections/SolutionHero/index.js.
  • src/utils/usePaginatedSearch.js — combines the existing useDataList search with page-based slicing; replaces identical state/slicing blocks in src/pages/blog/index.js, src/templates/blog-category-list.js, and src/templates/blog-tag-list.js (same defaults: ["frontmatter", "title"], "id", 10 per page).
  • src/sections/Company/Legal/legal-table.style.js — shared Sistent table styles (StyledTableContainer, StyledTableRow, StyledTableCell, StyledHeaderCell) and legalTableTheme, previously duplicated in the privacy, cookie-notice, and sub-processors pages.

Behavior is unchanged; only duplication is consolidated.

Notes for Reviewers

  • The pre-commit hook (.lintstagedrc.js) needed two fixes to be able to commit at all:
    1. --no-warn-ignored added to the eslint step: eslint's "File ignored" warnings for src/utils/ files (which are in the eslint ignore list) tripped --max-warnings=0, blocking any commit touching src/utils/.
    2. Prettier now runs before eslint --fix instead of after: prettier's output violates the repo's eslint indent rules, so the previous order produced commits that fail npm run checklint (CI). With eslint last, committed files are eslint-clean.
  • The hook's prettier step reformats every staged file, which accounts for the formatting-only churn in the touched files (e.g. the legal pages).
  • Verified: eslint passes on all touched files; npm run build (full Gatsby build) also runs in CI.

Signed commits

  • Yes, I signed my commits.

Link to Devin session: https://app.devin.ai/sessions/2d082449c65546d48e3c44d4e65abd3f
Requested by: @NSTKrishna

NSTKrishna and others added 2 commits August 27, 2026 03:51
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant