en un clic
code-quality
// Refactor, deduplicate, and improve TypeScript code quality in the Zowe Explorer monorepo. Use when refactoring or checking code quality in packages/zowe-explorer/ and packages/zowe-explorer-api/.
// Refactor, deduplicate, and improve TypeScript code quality in the Zowe Explorer monorepo. Use when refactoring or checking code quality in packages/zowe-explorer/ and packages/zowe-explorer-api/.
Write and maintain Vitest unit tests and WDIO/Cucumber end-to-end tests in the Zowe Explorer monorepo. Use when adding, updating, debugging, or reviewing tests, when working with `*.unit.test.ts` files, `__tests__/__unit__/` or `__tests__/__e2e__/` directories, `.feature` files, step definitions, page objects, mock factories (`mockCreators/`), `MockedProperty`, `jest-mock-vscode`, `vitest.config`, `wdio.conf`, or running `pnpm test` / `pnpm test:e2e` in `packages/zowe-explorer/`, `packages/zowe-explorer-api/`, or `packages/zowe-explorer-ftp-extension/`.
Audit pull requests for breaking changes in the Zowe Explorer monorepo. Examines PR descriptions, review comments, and diffs to identify API and behavioral breaking changes, with special sensitivity to packages/zowe-explorer-api. Reconciles labels with user confirmation. Use when asked to audit breaking changes, check for breaking changes, or review a set of PRs for breaking impact.
Review code changes for functional correctness and regressions in Zowe Explorer. Focuses on tree view actions, filesystem APIs, and extension initialization. Use when validating a completed feature, bug fix, or refactor before merging or release.
Review pull requests for code quality, security, and Zowe conformance. Use when reviewing PRs, examining code changes, checking branch differences, or when the user asks for a code review.
Use the Zowe Explorer Development CLI (zedc) ONLY when the user explicitly mentions or requests "zedc". Provides sandboxed testing, environment setup, and package management.
| name | code-quality |
| description | Refactor, deduplicate, and improve TypeScript code quality in the Zowe Explorer monorepo. Use when refactoring or checking code quality in packages/zowe-explorer/ and packages/zowe-explorer-api/. |
| metadata | {"version":"1.0"} |
When refactoring or writing code for the Zowe Explorer monorepo, follow these project-specific guidelines. The agent should already understand general best practices (DRY, YAGNI, SRP); these instructions focus on conventions specific to Zowe Explorer.
packages/zowe-explorer-api: Low-level interaction with mainframe resources and extensibility framework.packages/zowe-explorer/src/trees/*/*Actions.ts: Business logic and data manipulation.packages/zowe-explorer/src/trees/*/*Node.ts: Presenting data in the VS Code TreeView. Never put business logic or data fetching directly in Node classes.fs or path calls for mainframe resources. Always use vscode.workspace.fs or Zowe filesystem providers.extensionContext.storageUri or globalStorageUri.**/zowe.config.json) as it circumvents Zowe SDK logic. Use Profiles.ts or profile management APIs from Imperative.When deduplicating or improving code, apply these specific patterns:
Centralize error formatting using AuthUtils.errorHandling rather than duplicating try/catch and raw vscode.window.showErrorMessage calls across individual UI handlers.
// BAD: Inconsistent UI output and duplicated logging
try {
await api.dataSet(filter);
} catch (error) {
ZoweLogger.error(`Error: ${error.message}`);
vscode.window.showErrorMessage(`Failed to list datasets: ${error.message}`);
}
// GOOD: Consistent error handling that translates errors and handles auth edge cases
try {
await api.dataSet(filter);
} catch (error) {
await AuthUtils.errorHandling(error, {
apiType: ZoweExplorerApiType.Mvs,
profile: node.getProfile(),
scenario: "Dataset listing",
});
}
Always use the Gui utility (from zowe-explorer-api) for user interactions rather than directly calling vscode.window.
// GOOD
import { Gui } from "@zowe/zowe-explorer-api";
const input = await Gui.showInputBox({
prompt: "Enter dataset name",
placeHolder: "HLQ.DATA.SET"
});
Use ZoweLogger consistently instead of console.log. Only log for meaningful events (trace for entry/exit, debug for troubleshooting, info for operations, warn/error).
// GOOD
import { ZoweLogger } from "../tools/ZoweLogger";
ZoweLogger.trace("MvsActions.fetchDataset entry");
ZoweLogger.error(`Operation failed for ${profile}: ${error.message}`);
Before finishing a code quality refactor:
import paths correctly reference @zowe/zowe-explorer-api where appropriate instead of using relative paths reaching into other workspace packages.any types were introduced; use zowe-explorer-api types whenever possible.Actions classes.pnpm lint and pnpm pretty to format the code.pnpm test (or cd packages/<package> && pnpm test) to ensure no regressions.pnpm build completes successfully.