Skip to content

Conversation

@satyanvm
Copy link
Contributor

@satyanvm satyanvm commented Dec 6, 2025

What kind of change does this PR introduce?

This PR adds a GitHub Action to check for unused files, exports and dependencies and cleans up existing unused code.

Issue Number:

Fixes #99

Did you add tests for your changes?

N/A

Snapshots/Videos:

N/A

If relevant, did you update the documentation?

N/A

Summary

There are unused code in the repository which this PR cleans up and also adds GitHub Action that checks for unused code on every PR.
#99

Does this PR introduce a breaking change?

No

Other information

I have used Knip tool for checking unused code, it's a widely popular and well maintained tool in the TypeScript/JavaScript community.

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • Chores

    • Added code quality tooling to the development workflow to detect unused files, exports, and dependencies.
  • Refactor

    • Removed unused UI component utilities from the codebase.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

Our Pull Request Approval Process

This PR will be reviewed according to our:

  1. Palisadoes Contributing Guidelines

  2. AI Usage Policy

Your PR may be automatically closed if:

  1. Our PR template isn't filled in correctly

  2. You haven't correctly linked your PR to an issue

Thanks for contributing!

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

Walkthrough

Introduces Knip tool for detecting unused files, exports, and dependencies with configuration and CI/CD integration. Removes four identified unused utility components from the src/utils directory.

Changes

Cohort / File(s) Summary
Knip Tool Integration
.github/workflows/pull-request.yml, knip.json, package.json
Adds Knip ^5.71.0 as a devDependency, configures it with project globs for TypeScript/Markdown files and ignored dependencies (docusaurus packages), and adds workflow step to run pnpm knip in Code-Quality-Checks job.
Deleted Unused Components
src/utils/ActionButton.tsx, src/utils/HomeCallToAction.tsx, src/utils/Section.tsx, src/utils/TwoColumns.tsx
Removes four unused React utility components and their default exports. Components were presentational wrappers for layout and UI patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Verify that all four deleted components (ActionButton, HomeCallToAction, Section, TwoColumns) are confirmed unused across the codebase and no active imports remain
  • Validate knip.json configuration: confirm project globs capture all relevant source and documentation files, and that ignoreDependencies are appropriately scoped
  • Confirm workflow step placement and execution context within the Code-Quality-Checks job

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding a GitHub Action for unused code detection and cleanup of unused components.
Description check ✅ Passed The description covers all key template sections: change type, issue number, testing status, summary, breaking changes, and contributor guide acknowledgment.
Linked Issues check ✅ Passed The PR successfully fulfills all coding requirements from issue #99: removes unused files/exports, adds Knip detection tool, configures GitHub Action with proper ignore patterns, and uses non-deprecated tooling.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: GitHub Action workflow updates, Knip configuration, dependency addition, and removal of unused utility components identified by Knip.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3241ecf and 362eacb.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .github/workflows/pull-request.yml (1 hunks)
  • knip.json (1 hunks)
  • package.json (1 hunks)
  • src/utils/ActionButton.tsx (0 hunks)
  • src/utils/HomeCallToAction.tsx (0 hunks)
  • src/utils/Section.tsx (0 hunks)
  • src/utils/TwoColumns.tsx (0 hunks)
💤 Files with no reviewable changes (4)
  • src/utils/Section.tsx
  • src/utils/TwoColumns.tsx
  • src/utils/ActionButton.tsx
  • src/utils/HomeCallToAction.tsx
🔇 Additional comments (3)
package.json (1)

52-52: Knip devDependency version looks good.

The caret version ^5.71.0 appropriately allows for future patch and minor updates while remaining within the Knip v5 major version, which aligns with the schema reference in knip.json.

knip.json (1)

1-5: Knip configuration is clean and properly structured.

The schema reference, project glob patterns for source and docs, and docusaurus-specific ignoreDependencies are all appropriate for the codebase structure.

To ensure completeness, please verify the ignoreDependencies list captures all packages that are used through configuration (non-import) rather than direct code references. Given that package.json contains several @docusaurus/* packages, confirm whether additional entries beyond the two listed are needed.

.github/workflows/pull-request.yml (1)

71-74: Knip check step is well-integrated into the CI pipeline.

The step uses pnpm knip (consistent with the project's package manager established earlier in the workflow), is positioned appropriately after the branch check, and will correctly fail the workflow if unused items are detected. No additional configuration or error handling is needed.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@satyanvm
Copy link
Contributor Author

satyanvm commented Dec 6, 2025

@coderabbitai full review and reevaluate all resolved items. If the PR requires any changes, even trivial ones, then give your review a “requested changes” status. If no changes are required then give the PR an “approved” status.

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Get PR details
echo "=== PR Details ==="
gh pr view 120 --json title,body,state,files,reviews,comments

echo -e "\n=== Changed Files ==="
gh pr diff 120 --name-only

echo -e "\n=== All resolved conversations ==="
gh api repos/PalisadoesFoundation/developer-docs/pulls/120/comments --paginate | jq '[.[] | select(.in_reply_to_id == null) | {id: .id, path: .path, line: .line, body: .body, user: .user.login, created_at: .created_at}]'

echo -e "\n=== PR review comments ==="
gh pr view 120 --comments --json comments | jq '.comments[] | {author: .author.login, body: .body, createdAt: .createdAt}'

Length of output: 13397


🏁 Script executed:

#!/bin/bash

# Get the full diff for all changed files
echo "=== Full PR Diff ==="
gh pr diff 120

echo -e "\n=== Checking if deleted files are truly unused ==="
# Check if the deleted files are referenced anywhere in the codebase
for file in "ActionButton" "HomeCallToAction" "Section" "TwoColumns"; do
  echo "Checking references to $file:"
  rg -i "$file" --type ts --type tsx --type js --type jsx --type json -g '!pnpm-lock.yaml' || echo "No references found for $file"
  echo "---"
done

echo -e "\n=== Verify knip package is added ==="
cat package.json | jq '.devDependencies.knip // .dependencies.knip'

echo -e "\n=== Review knip.json configuration ==="
cat knip.json

Length of output: 22036


🏁 Script executed:

#!/bin/bash

# Check for references to deleted files more thoroughly
echo "=== Searching for ActionButton references ==="
rg -i "ActionButton" --glob '*.{ts,tsx,js,jsx,md,mdx}' -g '!pnpm-lock.yaml' -C2

echo -e "\n=== Searching for HomeCallToAction references ==="
rg -i "HomeCallToAction" --glob '*.{ts,tsx,js,jsx,md,mdx}' -g '!pnpm-lock.yaml' -C2

echo -e "\n=== Searching for Section component references ==="
rg -i "from.*Section" --glob '*.{ts,tsx,js,jsx}' -g '!pnpm-lock.yaml' -C2

echo -e "\n=== Searching for TwoColumns references ==="
rg -i "TwoColumns" --glob '*.{ts,tsx,js,jsx,md,mdx}' -g '!pnpm-lock.yaml' -C2

echo -e "\n=== Check the GitHub Action workflow syntax ==="
cat .github/workflows/pull-request.yml | grep -A 5 -B 5 "Check for unused"

echo -e "\n=== Verify knip installation works ==="
# Just check if knip is properly configured
cat package.json | jq '.devDependencies.knip'

echo -e "\n=== Check for any existing code quality tools ==="
cat package.json | jq '.scripts | to_entries[] | select(.key | test("lint|check|quality"))'

Length of output: 1268


🏁 Script executed:

#!/bin/bash

# Check the full workflow file to see job structure and setup steps
echo "=== Full workflow file ==="
cat .github/workflows/pull-request.yml

echo -e "\n=== Check if knip.json ignores the right files ==="
# Check what other dependencies or patterns might need to be ignored
cat package.json | jq '.dependencies | keys[]'

echo -e "\n=== Verify the deleted files directory structure ==="
# Make sure we're looking at the right path
fd -t d "utils" src/

echo -e "\n=== Check if there are any import maps or aliases ==="
cat tsconfig.json | jq '.compilerOptions.paths // "No path aliases"' 2>/dev/null || echo "No tsconfig with path aliases"

Length of output: 8134


🏁 Script executed:

#!/bin/bash

# Check if there's a docusaurus.config.js to understand entry points
echo "=== Checking docusaurus.config.js for entry points ==="
if [ -f "docusaurus.config.js" ]; then
  cat docusaurus.config.js | head -30
else
  echo "No docusaurus.config.js found"
fi

echo -e "\n=== Check package.json scripts section ==="
cat package.json | jq '.scripts'

echo -e "\n=== Look for any remaining utils imports in the codebase ==="
rg -n "from.*utils" --glob '*.{ts,tsx,js,jsx}' -g '!node_modules' -g '!pnpm-lock.yaml' | head -20 || echo "No imports from utils found"

echo -e "\n=== Check if there are any other files in src/utils ==="
fd . src/utils 2>/dev/null || echo "src/utils directory doesn't exist or is empty"

echo -e "\n=== Verify the GitHub Action job dependencies ==="
cat .github/workflows/pull-request.yml | grep -A 2 "needs:"

echo -e "\n=== Check lint-staged config ==="
cat package.json | jq '."lint-staged"'

Length of output: 1192


@satyanvm: I've completed a full review of PR #120. The PR successfully addresses the goal of cleaning up unused code and adding automated checks, but there is one optimization needed.

Summary

Changes Made:

  • ✅ Removes 4 unused utility components (ActionButton.tsx, HomeCallToAction.tsx, Section.tsx, TwoColumns.tsx)
  • ✅ Adds Knip v5.71.0 as a devDependency for detecting unused code
  • ✅ Adds knip.json configuration file
  • ✅ Adds GitHub Action step to check for unused code on every PR

Verification:

  • ✅ Confirmed no references to deleted files exist in the codebase
  • ✅ knip.json configuration is appropriate with correct schema and ignore patterns
  • ✅ Package is properly added to devDependencies

Issue Found

GitHub Action Optimization Required:

In .github/workflows/pull-request.yml (Line 73), the workflow uses npx knip:

- name: Check for unused files, exports and dependencies
  run: npx knip

Problem: Since knip is already installed as a devDependency and the workflow runs pnpm install in earlier steps, using npx will unnecessarily download knip again, wasting time and resources.

Required Change:

- name: Check for unused files, exports and dependencies
  run: pnpm knip

This ensures consistency with the project's package manager (pnpm) and utilizes the already-installed dependency.


Once this change is made, the PR will be ready for approval.

✅ Actions performed

Full review triggered.

@satyanvm
Copy link
Contributor Author

satyanvm commented Dec 6, 2025

@coderabbitai full review and reevaluate all resolved items. If the PR requires any changes, even trivial ones, then give your review a “requested changes” status. If no changes are required then give the PR an “approved” status.

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Get current PR state and details
echo "=== PR Details ==="
gh pr view 120 --json title,body,state,isDraft,mergeable,reviewDecision,files

echo -e "\n=== PR Diff ==="
gh pr diff 120

echo -e "\n=== Check workflow file specifically ==="
cat .github/workflows/pull-request.yml | grep -A 3 -B 3 "knip"

echo -e "\n=== All review comments (resolved and unresolved) ==="
gh api repos/PalisadoesFoundation/developer-docs/pulls/120/comments --paginate | jq '[.[] | {id: .id, path: .path, line: .line, body: .body, user: .user.login, created_at: .created_at, in_reply_to_id: .in_reply_to_id}]'

echo -e "\n=== Verify knip configuration ==="
cat knip.json

echo -e "\n=== Check package.json for knip ==="
cat package.json | jq '{devDependencies: .devDependencies.knip, scripts: .scripts}'

echo -e "\n=== Search for any remaining references to deleted files ==="
for file in "ActionButton" "HomeCallToAction" "Section" "TwoColumns"; do
  echo "Checking references to $file:"
  rg -i "$file" --glob '*.{ts,tsx,js,jsx,md,mdx}' -g '!pnpm-lock.yaml' || echo "No references found for $file"
done

Length of output: 24762


@satyanvm: I've completed a comprehensive review of PR #120. The previously identified issue has been resolved, and the PR is now in excellent shape.

✅ Verification Results

Files Changed:

  • .github/workflows/pull-request.yml - Adds knip check step
  • knip.json - Configuration file with proper schema
  • package.json - Adds knip v5.71.0 as devDependency
  • pnpm-lock.yaml - Lockfile updated
  • ✅ Deleted 4 unused utility components (no references found in codebase)

Previous Issue - RESOLVED:
The workflow now correctly uses pnpm knip (Line 73) instead of npx knip, ensuring the already-installed dependency is utilized efficiently.

Code Quality Checks:

  • ✅ All deleted files are genuinely unused (verified with ripgrep)
  • ✅ knip.json configuration is correct with appropriate ignore patterns
  • ✅ GitHub Action integrates properly into existing workflow
  • ✅ Uses project's package manager (pnpm) consistently

Summary:
This PR successfully achieves its objectives:

  1. Cleans up unused code (4 utility components)
  2. Adds automated unused code detection via knip
  3. Integrates check into CI/CD pipeline
  4. Uses proper tooling configuration

No changes required - approving PR.

✅ Actions performed

Comments resolved and changes approved.

@satyanvm
Copy link
Contributor Author

satyanvm commented Dec 6, 2025

@palisadoes The PR is ready for review. PTAL.
Removed src/utils as it was unused, added Knip to package.json and added the Knip check to pull-request.yml.

@palisadoes palisadoes merged commit b61c750 into PalisadoesFoundation:main Dec 6, 2025
12 of 13 checks passed
@satyanvm satyanvm deleted the unused-code-check branch December 6, 2025 16:06
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.

DevDocs: Unused Code Files, Dependencies, Exports cleanup and detection with GitHub Action

2 participants