Skip to content

Add AI skill that checks for any unused exports#1818

Open
kyoto wants to merge 1 commit intoopenshift:mainfrom
kyoto:find-unused-exports
Open

Add AI skill that checks for any unused exports#1818
kyoto wants to merge 1 commit intoopenshift:mainfrom
kyoto:find-unused-exports

Conversation

@kyoto
Copy link
Copy Markdown
Member

@kyoto kyoto commented Apr 16, 2026

Also removes the unnecessary exports that it found

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added comprehensive workflow documentation for identifying and managing internal code cleanup and unused export detection
  • Refactor

    • Reduced the public API surface by consolidating type and constant declarations as internal-only
    • Refactored module export patterns to improve encapsulation while maintaining existing functionality

Also removes the unnecessary exports that it found
@kyoto kyoto added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 16, 2026
@openshift-ci openshift-ci Bot requested review from syedriko and xrajesh April 16, 2026 06:28
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

This PR removes unused exports from the codebase by making five exported types and constants file-scoped: FetchError, FLAG_LIGHTSPEED_PLUGIN, the named export of useOpenOLS, OLSState, and HistoryCompression. A new skill document outlines the workflow for identifying and reporting unused TypeScript exports.

Changes

Cohort / File(s) Summary
Documentation
.cursor/skills/unused-exports/SKILL.md
New skill document defining a multi-step workflow for identifying unused TypeScript exports using ts-unused-exports, correlating with entry points via package.json and console-extensions.json, and categorizing findings as unused exports or completely unused files.
Type Visibility Changes
src/error.ts, src/redux-reducers.ts, src/types.ts
Removed export keyword from FetchError, OLSState, and HistoryCompression type declarations, converting them from public to file-scoped types.
Export Visibility Changes
src/flags.ts, src/hooks/useOpenOLS.ts
Removed exports: FLAG_LIGHTSPEED_PLUGIN constant (now file-scoped); useOpenOLS changed from named export to default-export-only, preserving default import access while breaking named import usage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 With whiskers twitched and careful eye,
We've trimmed the exports, old and dry.
No longer public, tucked away—
Unused code won't clutter today! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add AI skill that checks for any unused exports' accurately describes the main change—adding a new Markdown skill document—but only partially captures the full scope, which also includes removing unused exports identified by that skill across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@kyoto
Copy link
Copy Markdown
Member Author

kyoto commented Apr 16, 2026

/cherry-pick release-4.19
/cherry-pick pattern-fly-5

@openshift-cherrypick-robot
Copy link
Copy Markdown

@kyoto: once the present PR merges, I will cherry-pick it on top of pattern-fly-5, release-4.19 in new PRs and assign them to you.

Details

In response to this:

/cherry-pick release-4.19
/cherry-pick pattern-fly-5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.cursor/skills/unused-exports/SKILL.md (1)

23-31: Broaden module-path resolution to avoid false positives.

The current wording implies exposedModules always maps to src/<path>.ts; this can miss *.tsx or index.ts(x) entry points.

Proposed doc tweak
-Read `package.json` field `consolePlugin.exposedModules`. Each value is a module
-path relative to `src/` (e.g. `"./flags"` → `src/flags.ts`). These modules are
+Read `package.json` field `consolePlugin.exposedModules`. Each value is a module
+path relative to `src/` (e.g. `"./flags"` may resolve to `src/flags.ts`,
+`src/flags.tsx`, `src/flags/index.ts`, or `src/flags/index.tsx`). These modules are
 loaded at runtime by the OpenShift console framework — their exports are used
 externally even though nothing inside this repo imports them.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.cursor/skills/unused-exports/SKILL.md around lines 23 - 31, The docs assume
consolePlugin.exposedModules always maps to src/<path>.ts which causes false
negatives for .tsx or index files; update the module-path resolution guidance
to, when mapping each exposedModules entry to a file, try resolving the exact
path as given and fall back to src/<path>.ts, src/<path>.tsx,
src/<path>/index.ts, and src/<path>/index.tsx (and accept explicit extensions),
and when parsing console-extensions.json $codeRef values map the ModuleName back
using that broadened resolution so export references (ModuleName or
ModuleName.exportName) correctly identify entry points.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.cursor/skills/unused-exports/SKILL.md:
- Around line 23-31: The docs assume consolePlugin.exposedModules always maps to
src/<path>.ts which causes false negatives for .tsx or index files; update the
module-path resolution guidance to, when mapping each exposedModules entry to a
file, try resolving the exact path as given and fall back to src/<path>.ts,
src/<path>.tsx, src/<path>/index.ts, and src/<path>/index.tsx (and accept
explicit extensions), and when parsing console-extensions.json $codeRef values
map the ModuleName back using that broadened resolution so export references
(ModuleName or ModuleName.exportName) correctly identify entry points.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 15cf0746-3497-466b-95e3-ceb5f7f323ea

📥 Commits

Reviewing files that changed from the base of the PR and between e5f50e2 and 7f0f2a0.

📒 Files selected for processing (6)
  • .cursor/skills/unused-exports/SKILL.md
  • src/error.ts
  • src/flags.ts
  • src/hooks/useOpenOLS.ts
  • src/redux-reducers.ts
  • src/types.ts

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants