Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .cursor/skills/unused-exports/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: unused-exports
description: >-
Find exported symbols that are never imported by another file. Use when the
user says "check exports", "unused exports" or asks to clean up exports.
---

# unused-exports

## Step 1: Run ts-unused-exports

Run the tool with no exclusions so every finding is visible:

```sh
npx ts-unused-exports tsconfig.json \
--findCompletelyUnusedFiles \
--showLineNumber \
--searchNamespaces
```

## Step 2: Identify entry points

Read `package.json` field `consolePlugin.exposedModules`. Each value is a module
path relative to `src/` (e.g. `"./flags"` → `src/flags.ts`). These modules are
loaded at runtime by the OpenShift console framework — their exports are used
externally even though nothing inside this repo imports them.

Also read `console-extensions.json`. Each `$codeRef` value has the form
`"ModuleName"` or `"ModuleName.exportName"`. Map the module name back to
`exposedModules` to get the file path, and note which specific export is
referenced. An export is an entry point if:

- It is the **default export** of an exposed module, OR
- It is **named explicitly** in a `$codeRef` (e.g.
`"OLSFlags.enableLightspeedPluginFlag"` → the named export
`enableLightspeedPluginFlag` in `src/flags.ts`)

## Step 3: Filter results

For each finding from Step 1, check whether it matches an entry point from
Step 2. Remove it from the report if it does. Keep everything else.

## Step 4: Present results

Group findings into two sections:

**Unused exports** — exports that can safely have their `export` keyword removed
(they are still used locally) or be deleted entirely (dead code).

**Completely unused files** — files where nothing is imported anywhere. These
are candidates for deletion.

If nothing remains after filtering, report that all exports are accounted for.

Do **not** modify any files — only report findings.
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ErrorType = {
response?: Response;
};

export type FetchError = {
type FetchError = {
json?: {
detail?: string | { response?: string; cause?: string };
message?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/flags.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SetFeatureFlag } from '@openshift-console/dynamic-plugin-sdk';

export const FLAG_LIGHTSPEED_PLUGIN = 'LIGHTSPEED_PLUGIN';
const FLAG_LIGHTSPEED_PLUGIN = 'LIGHTSPEED_PLUGIN';

export const enableLightspeedPluginFlag = (setFeatureFlag: SetFeatureFlag) =>
setFeatureFlag(FLAG_LIGHTSPEED_PLUGIN, true);
2 changes: 1 addition & 1 deletion src/hooks/useOpenOLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Attachment } from '../types';
// Hook that provides a callback function to open the OpenShift Lightspeed UI with an optional
// initial prompt. Exposed as a console extension so other console pages and plugins can discover
// and invoke it.
export const useOpenOLS = (): ((
const useOpenOLS = (): ((
// Optional initial prompt text to populate the input field
prompt?: string,
// Optional array of attachments to include with the prompt
Expand Down
2 changes: 1 addition & 1 deletion src/redux-reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ActionType, OLSAction } from './redux-actions';
import { Attachment } from './types';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type OLSState = ImmutableMap<string, any>;
type OLSState = ImmutableMap<string, any>;

export type State = {
plugins: {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type Tool = {

export type OlsToolUIComponent = React.ComponentType<{ tool: Tool }>;

export type HistoryCompression = {
type HistoryCompression = {
durationMs?: number;
status: 'compressing' | 'done';
};
Expand Down