@checkstack/common 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @checkstack/common
2
2
 
3
+ ## 0.6.5
4
+
5
+ ### Patch Changes
6
+
7
+ - d1a2796: Enforce stricter code quality standards and eliminate AI slop anti-patterns.
8
+
9
+ **New utility**
10
+
11
+ - `extractErrorMessage(error, fallback?)` in `@checkstack/common` for consistent error extraction
12
+
13
+ **ESLint rules**
14
+
15
+ - `react-hooks/rules-of-hooks` and `exhaustive-deps` for hook correctness
16
+ - `no-console` in frontend packages — forces `toast` over silent `console.error`
17
+ - `no-restricted-syntax` banning `instanceof Error` — forces `extractErrorMessage`
18
+ - Custom `no-eslint-disable-any` rule preventing `@typescript-eslint/no-explicit-any` circumvention
19
+
20
+ **Refactoring**
21
+
22
+ - Replace 141 `instanceof Error` boilerplate patterns across the codebase
23
+ - Replace swallowed `console.error` with user-visible `toast.error()` feedback
24
+ - Remove 15 redundant `as` type casts in IntegrationsPage and ProviderConnectionsPage
25
+ - Consolidate 3 identical callback handlers into `handleDialogClose`
26
+ - Fix conditional React hook call in `FormField.tsx`
27
+ - Fix unstable useMemo deps in `Dashboard.tsx`
28
+ - Replace `useEffect`→`setState` with derived `useMemo` in `RegisterPage.tsx`
29
+ - Rewrite `keystore.test.ts` with typed `DrizzleMockChain` (eliminating 7 `any` suppressions)
30
+ - Delete obvious comments in `encryption.ts` and Teams `provider.ts`
31
+
32
+ ## 0.6.4
33
+
34
+ ### Patch Changes
35
+
36
+ - 67158e2: Standardize package metadata, unify AJV versions to 8.18.0, and enforce monorepo architecture rules via updated ESLint configuration. This ensures consistent package discovery and runtime dependency safety across the platform.
37
+
3
38
  ## 0.6.3
4
39
 
5
40
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/common",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -12,18 +12,21 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@orpc/contract": "^1.5.0",
15
+ "@orpc/contract": "^1.13.14",
16
16
  "lucide-react": "0.562.0",
17
17
  "zod": "^4.0.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "typescript": "^5.7.2",
21
- "@checkstack/tsconfig": "0.0.3",
22
- "@checkstack/scripts": "0.1.1"
21
+ "@checkstack/tsconfig": "0.0.5",
22
+ "@checkstack/scripts": "0.1.2"
23
23
  },
24
24
  "scripts": {
25
25
  "typecheck": "tsc --noEmit",
26
26
  "lint": "bun run lint:code",
27
27
  "lint:code": "eslint . --max-warnings 0"
28
+ },
29
+ "checkstack": {
30
+ "type": "common"
28
31
  }
29
32
  }
@@ -0,0 +1,30 @@
1
+ import { describe, it, expect } from "bun:test";
2
+ import { extractErrorMessage } from "./error-utils";
3
+
4
+ describe("extractErrorMessage", () => {
5
+ it("should extract message from Error instances", () => {
6
+ const error = new Error("something went wrong");
7
+ expect(extractErrorMessage(error)).toBe("something went wrong");
8
+ });
9
+
10
+ it("should extract message from Error subclasses", () => {
11
+ const error = new TypeError("invalid type");
12
+ expect(extractErrorMessage(error)).toBe("invalid type");
13
+ });
14
+
15
+ it("should return string errors directly", () => {
16
+ expect(extractErrorMessage("network failure")).toBe("network failure");
17
+ });
18
+
19
+ it("should return the default fallback for non-Error, non-string values", () => {
20
+ expect(extractErrorMessage(42)).toBe("An error occurred");
21
+ expect(extractErrorMessage(undefined)).toBe("An error occurred");
22
+ // eslint-disable-next-line unicorn/no-null
23
+ expect(extractErrorMessage(null)).toBe("An error occurred");
24
+ expect(extractErrorMessage({ code: 500 })).toBe("An error occurred");
25
+ });
26
+
27
+ it("should return custom fallback when provided", () => {
28
+ expect(extractErrorMessage(42, "Custom fallback")).toBe("Custom fallback");
29
+ });
30
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Extracts a human-readable message from an unknown error value.
3
+ *
4
+ * Handles Error instances, plain strings, and arbitrary values.
5
+ * Designed as a single source of truth — use this instead of
6
+ * inline `error instanceof Error ? error.message : fallback` patterns.
7
+ */
8
+ export function extractErrorMessage(
9
+ error: unknown,
10
+ fallback = "An error occurred",
11
+ ): string {
12
+ // eslint-disable-next-line no-restricted-syntax -- This IS the canonical implementation
13
+ if (error instanceof Error) return error.message;
14
+ if (typeof error === "string") return error;
15
+ return fallback;
16
+ }
package/src/index.ts CHANGED
@@ -9,3 +9,4 @@ export * from "./transport-client";
9
9
  export * from "./json-schema";
10
10
  export * from "./chart-types";
11
11
  export * from "./procedure-builder";
12
+ export * from "./error-utils";