eslint-plugin-zod-v4 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -81,6 +81,8 @@ These rules detect Zod v3 patterns that will break in v4.
81
81
  | [no-deep-partial](docs/rules/no-deep-partial.md) | Disallow `.deepPartial()` (removed in v4). | ❌ No |
82
82
  | [no-deprecated-ip-methods](docs/rules/no-deprecated-ip-methods.md) | Disallow `.ip()`/`.cidr()`. Use `.ipv4()`/`.ipv6()` variants. | ❌ No |
83
83
  | [no-promise-schema](docs/rules/no-promise-schema.md) | Disallow `z.promise()`. Await before parsing. | ❌ No |
84
+ | [no-throw-in-refine](docs/rules/no-throw-in-refine.md) | Disallow `throw` inside `.refine()`/`.superRefine()`/`.transform()`. Use return patterns. | ❌ No |
85
+ | [require-enum-as-const](docs/rules/require-enum-as-const.md) | Require `as const` for arrays passed to `z.enum()`. | ❌ No |
84
86
 
85
87
  ### Best Practices (severity: warn)
86
88
 
@@ -301,6 +303,16 @@ schema.partial() // shallow only
301
303
 
302
304
  ## Changelog
303
305
 
306
+ ### v0.3.0 (2025-02-21)
307
+
308
+ **New Rules:**
309
+ - `no-throw-in-refine`: Detects `throw` statements inside `.refine()`, `.superRefine()`, and `.transform()` callbacks. These errors are **not captured by Zod**, causing silent failures. The rule provides educational messages with correct patterns for each method.
310
+ - `require-enum-as-const`: Requires `as const` for arrays passed to `z.enum()`. Without it, TypeScript infers `string[]` instead of the literal union, breaking type inference.
311
+
312
+ **Improvements:**
313
+ - Added 61 new test cases (276 total tests passing)
314
+ - Updated documentation with migration examples for new rules
315
+
304
316
  ### v0.2.0 (2025-12-16)
305
317
 
306
318
  **New Features:**
package/dist/index.cjs CHANGED
@@ -12466,6 +12466,14 @@ function isModuleLevelFactoryFunction(node) {
12466
12466
  }
12467
12467
 
12468
12468
  // src/rules/prefer-error-param.ts
12469
+ function isDirectZodObjectCall(node) {
12470
+ if (node.callee.type !== "MemberExpression") return false;
12471
+ const { object, property } = node.callee;
12472
+ if (object.type === "Identifier" && object.name === "z") {
12473
+ return property.type === "Identifier" && property.name === "object";
12474
+ }
12475
+ return false;
12476
+ }
12469
12477
  var preferErrorParam = createRule({
12470
12478
  name: "prefer-error-param",
12471
12479
  meta: {
@@ -12484,6 +12492,7 @@ var preferErrorParam = createRule({
12484
12492
  return {
12485
12493
  CallExpression(node) {
12486
12494
  if (!isZodCall(node)) return;
12495
+ if (isDirectZodObjectCall(node)) return;
12487
12496
  for (const arg of node.arguments) {
12488
12497
  if (arg.type !== "ObjectExpression") continue;
12489
12498
  for (const prop of arg.properties) {