diff --git a/.cursor/skills/unused-exports/SKILL.md b/.cursor/skills/unused-exports/SKILL.md new file mode 100644 index 00000000..88a745f8 --- /dev/null +++ b/.cursor/skills/unused-exports/SKILL.md @@ -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. diff --git a/src/error.ts b/src/error.ts index 4226b81b..57934768 100644 --- a/src/error.ts +++ b/src/error.ts @@ -6,7 +6,7 @@ export type ErrorType = { response?: Response; }; -export type FetchError = { +type FetchError = { json?: { detail?: string | { response?: string; cause?: string }; message?: string; diff --git a/src/flags.ts b/src/flags.ts index 47576fc5..8878949d 100644 --- a/src/flags.ts +++ b/src/flags.ts @@ -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); diff --git a/src/hooks/useOpenOLS.ts b/src/hooks/useOpenOLS.ts index a1a3b1e0..fc3f85d2 100644 --- a/src/hooks/useOpenOLS.ts +++ b/src/hooks/useOpenOLS.ts @@ -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 diff --git a/src/redux-reducers.ts b/src/redux-reducers.ts index d71f8ba8..463906ee 100644 --- a/src/redux-reducers.ts +++ b/src/redux-reducers.ts @@ -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; +type OLSState = ImmutableMap; export type State = { plugins: { diff --git a/src/types.ts b/src/types.ts index be6674f5..2f3efe20 100644 --- a/src/types.ts +++ b/src/types.ts @@ -45,7 +45,7 @@ export type Tool = { export type OlsToolUIComponent = React.ComponentType<{ tool: Tool }>; -export type HistoryCompression = { +type HistoryCompression = { durationMs?: number; status: 'compressing' | 'done'; };