eslint-plugin-zod-mini 1.9.0 → 1.10.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 +3 -0
- package/dist/index.cjs +6 -0
- package/dist/index.mjs +6 -0
- package/dist/rules/no-dynamic-schema-value.cjs +17 -0
- package/dist/rules/no-dynamic-schema-value.mjs +17 -0
- package/dist/rules/no-function-scoped-schema.cjs +17 -0
- package/dist/rules/no-function-scoped-schema.mjs +17 -0
- package/dist/rules/no-transform-in-record-key.cjs +1 -13
- package/dist/rules/no-transform-in-record-key.mjs +1 -13
- package/dist/rules/prefer-meta.cjs +1 -1
- package/dist/rules/prefer-meta.mjs +1 -1
- package/dist/rules/prefer-validate.cjs +21 -0
- package/dist/rules/prefer-validate.mjs +21 -0
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -42,7 +42,9 @@ Find out more about [Oxlint's `jsPLugins`](https://oxc.rs/docs/guide/usage/linte
|
|
|
42
42
|
| [no-coerce-boolean](docs/rules/no-coerce-boolean.md) | Disallow `z.coerce.boolean()` because it treats any non-empty string as `true`. | ✅ | | 💡 |
|
|
43
43
|
| [no-conflicting-checks](docs/rules/no-conflicting-checks.md) | Disallow check combinations that can never match, are redundant, or do not apply to the schema type | | | |
|
|
44
44
|
| [no-duplicate-schema-methods](docs/rules/no-duplicate-schema-methods.md) | Disallow calling the same schema method more than once in a single chain | ✅ | | |
|
|
45
|
+
| [no-dynamic-schema-value](docs/rules/no-dynamic-schema-value.md) | Disallow non-static values passed as arguments in a Zod Mini schema expression | | | |
|
|
45
46
|
| [no-empty-custom-schema](docs/rules/no-empty-custom-schema.md) | Disallow usage of `z.custom()` without arguments | ✅ | | |
|
|
47
|
+
| [no-function-scoped-schema](docs/rules/no-function-scoped-schema.md) | Disallow constructing a Zod Mini schema inside a function body | | | |
|
|
46
48
|
| [no-native-enum](docs/rules/no-native-enum.md) | Disallow deprecated `z.nativeEnum()` in favor of `z.enum()`. | ✅ | 🔧 | |
|
|
47
49
|
| [no-promise-schema](docs/rules/no-promise-schema.md) | Disallow deprecated `z.promise()` schemas. | ✅ | | |
|
|
48
50
|
| [no-throw-in-refine](docs/rules/no-throw-in-refine.md) | Disallow throwing errors directly inside Zod Mini refine callbacks | ✅ | | |
|
|
@@ -55,6 +57,7 @@ Find out more about [Oxlint's `jsPLugins`](https://oxc.rs/docs/guide/usage/linte
|
|
|
55
57
|
| [prefer-nullish](docs/rules/prefer-nullish.md) | Enforce `z.nullish()` instead of combining `z.optional()` and `z.nullable()` | ✅ | 🔧 | |
|
|
56
58
|
| [prefer-string-length-over-min-max](docs/rules/prefer-string-length-over-min-max.md) | Prefer `z.length(n)` over `z.minLength(n)` and `z.maxLength(n)` with the same value on a string schema | | 🔧 | |
|
|
57
59
|
| [prefer-tuple-over-array-length](docs/rules/prefer-tuple-over-array-length.md) | Prefer `z.tuple()` over a length-constrained `z.array()` so the length is preserved in the inferred type. | | 🔧 | |
|
|
60
|
+
| [prefer-validate](docs/rules/prefer-validate.md) | Prefer boolean validation when only the success of parsing is used | | | 💡 |
|
|
58
61
|
| [require-brand-type-parameter](docs/rules/require-brand-type-parameter.md) | Require type parameter on `.brand()` functions | ✅ | | 💡 |
|
|
59
62
|
| [require-error-message](docs/rules/require-error-message.md) | Enforce that custom refinements include an error message | ✅ | 🔧 | |
|
|
60
63
|
| [schema-error-property-style](docs/rules/schema-error-property-style.md) | Enforce consistent style for error messages in Zod Mini schema validation (using ESQuery patterns) | | | |
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,9 @@ const require_no_any_schema = require("./rules/no-any-schema.cjs");
|
|
|
8
8
|
const require_no_coerce_boolean = require("./rules/no-coerce-boolean.cjs");
|
|
9
9
|
const require_no_conflicting_checks = require("./rules/no-conflicting-checks.cjs");
|
|
10
10
|
const require_no_duplicate_schema_methods = require("./rules/no-duplicate-schema-methods.cjs");
|
|
11
|
+
const require_no_dynamic_schema_value = require("./rules/no-dynamic-schema-value.cjs");
|
|
11
12
|
const require_no_empty_custom_schema = require("./rules/no-empty-custom-schema.cjs");
|
|
13
|
+
const require_no_function_scoped_schema = require("./rules/no-function-scoped-schema.cjs");
|
|
12
14
|
const require_no_native_enum = require("./rules/no-native-enum.cjs");
|
|
13
15
|
const require_no_promise_schema = require("./rules/no-promise-schema.cjs");
|
|
14
16
|
const require_no_throw_in_refine = require("./rules/no-throw-in-refine.cjs");
|
|
@@ -21,6 +23,7 @@ const require_prefer_meta = require("./rules/prefer-meta.cjs");
|
|
|
21
23
|
const require_prefer_nullish = require("./rules/prefer-nullish.cjs");
|
|
22
24
|
const require_prefer_string_length_over_min_max = require("./rules/prefer-string-length-over-min-max.cjs");
|
|
23
25
|
const require_prefer_tuple_over_array_length = require("./rules/prefer-tuple-over-array-length.cjs");
|
|
26
|
+
const require_prefer_validate = require("./rules/prefer-validate.cjs");
|
|
24
27
|
const require_require_brand_type_parameter = require("./rules/require-brand-type-parameter.cjs");
|
|
25
28
|
const require_require_error_message = require("./rules/require-error-message.cjs");
|
|
26
29
|
const require_schema_error_property_style = require("./rules/schema-error-property-style.cjs");
|
|
@@ -40,7 +43,9 @@ const eslintPluginZodMini = {
|
|
|
40
43
|
"no-coerce-boolean": require_no_coerce_boolean.noCoerceBoolean,
|
|
41
44
|
"no-conflicting-checks": require_no_conflicting_checks.noConflictingChecks,
|
|
42
45
|
"no-duplicate-schema-methods": require_no_duplicate_schema_methods.noDuplicateSchemaMethods,
|
|
46
|
+
"no-dynamic-schema-value": require_no_dynamic_schema_value.noDynamicSchemaValue,
|
|
43
47
|
"no-empty-custom-schema": require_no_empty_custom_schema.noEmptyCustomSchema,
|
|
48
|
+
"no-function-scoped-schema": require_no_function_scoped_schema.noFunctionScopedSchema,
|
|
44
49
|
"no-native-enum": require_no_native_enum.noNativeEnum,
|
|
45
50
|
"no-promise-schema": require_no_promise_schema.noPromiseSchema,
|
|
46
51
|
"no-throw-in-refine": require_no_throw_in_refine.noThrowInRefine,
|
|
@@ -53,6 +58,7 @@ const eslintPluginZodMini = {
|
|
|
53
58
|
"prefer-nullish": require_prefer_nullish.preferNullish,
|
|
54
59
|
"prefer-string-length-over-min-max": require_prefer_string_length_over_min_max.preferStringLengthOverMinMax,
|
|
55
60
|
"prefer-tuple-over-array-length": require_prefer_tuple_over_array_length.preferTupleOverArrayLength,
|
|
61
|
+
"prefer-validate": require_prefer_validate.preferValidate,
|
|
56
62
|
"require-brand-type-parameter": require_require_brand_type_parameter.requireBrandTypeParameter,
|
|
57
63
|
"require-error-message": require_require_error_message.requireErrorMessage,
|
|
58
64
|
"schema-error-property-style": require_schema_error_property_style.schemaErrorPropertyStyle
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,9 @@ import { noAnySchema } from "./rules/no-any-schema.mjs";
|
|
|
8
8
|
import { noCoerceBoolean } from "./rules/no-coerce-boolean.mjs";
|
|
9
9
|
import { noConflictingChecks } from "./rules/no-conflicting-checks.mjs";
|
|
10
10
|
import { noDuplicateSchemaMethods } from "./rules/no-duplicate-schema-methods.mjs";
|
|
11
|
+
import { noDynamicSchemaValue } from "./rules/no-dynamic-schema-value.mjs";
|
|
11
12
|
import { noEmptyCustomSchema } from "./rules/no-empty-custom-schema.mjs";
|
|
13
|
+
import { noFunctionScopedSchema } from "./rules/no-function-scoped-schema.mjs";
|
|
12
14
|
import { noNativeEnum } from "./rules/no-native-enum.mjs";
|
|
13
15
|
import { noPromiseSchema } from "./rules/no-promise-schema.mjs";
|
|
14
16
|
import { noThrowInRefine } from "./rules/no-throw-in-refine.mjs";
|
|
@@ -21,6 +23,7 @@ import { preferMeta } from "./rules/prefer-meta.mjs";
|
|
|
21
23
|
import { preferNullish } from "./rules/prefer-nullish.mjs";
|
|
22
24
|
import { preferStringLengthOverMinMax } from "./rules/prefer-string-length-over-min-max.mjs";
|
|
23
25
|
import { preferTupleOverArrayLength } from "./rules/prefer-tuple-over-array-length.mjs";
|
|
26
|
+
import { preferValidate } from "./rules/prefer-validate.mjs";
|
|
24
27
|
import { requireBrandTypeParameter } from "./rules/require-brand-type-parameter.mjs";
|
|
25
28
|
import { requireErrorMessage } from "./rules/require-error-message.mjs";
|
|
26
29
|
import { schemaErrorPropertyStyle } from "./rules/schema-error-property-style.mjs";
|
|
@@ -40,7 +43,9 @@ const eslintPluginZodMini = {
|
|
|
40
43
|
"no-coerce-boolean": noCoerceBoolean,
|
|
41
44
|
"no-conflicting-checks": noConflictingChecks,
|
|
42
45
|
"no-duplicate-schema-methods": noDuplicateSchemaMethods,
|
|
46
|
+
"no-dynamic-schema-value": noDynamicSchemaValue,
|
|
43
47
|
"no-empty-custom-schema": noEmptyCustomSchema,
|
|
48
|
+
"no-function-scoped-schema": noFunctionScopedSchema,
|
|
44
49
|
"no-native-enum": noNativeEnum,
|
|
45
50
|
"no-promise-schema": noPromiseSchema,
|
|
46
51
|
"no-throw-in-refine": noThrowInRefine,
|
|
@@ -53,6 +58,7 @@ const eslintPluginZodMini = {
|
|
|
53
58
|
"prefer-nullish": preferNullish,
|
|
54
59
|
"prefer-string-length-over-min-max": preferStringLengthOverMinMax,
|
|
55
60
|
"prefer-tuple-over-array-length": preferTupleOverArrayLength,
|
|
61
|
+
"prefer-validate": preferValidate,
|
|
56
62
|
"require-brand-type-parameter": requireBrandTypeParameter,
|
|
57
63
|
"require-error-message": requireErrorMessage,
|
|
58
64
|
"schema-error-property-style": schemaErrorPropertyStyle
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_create_plugin_rule = require("../utils/create-plugin-rule.cjs");
|
|
2
|
+
let _eslint_zod_utils = require("@eslint-zod/utils");
|
|
3
|
+
let _eslint_zod_utils_rule_builders_no_dynamic_schema_value = require("@eslint-zod/utils/rule-builders/no-dynamic-schema-value");
|
|
4
|
+
//#region src/rules/no-dynamic-schema-value.ts
|
|
5
|
+
const noDynamicSchemaValue = require_create_plugin_rule.createZodMiniPluginRule({
|
|
6
|
+
name: "no-dynamic-schema-value",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
docs: { description: "Disallow non-static values passed as arguments in a Zod Mini schema expression" },
|
|
10
|
+
messages: { dynamicValue: "This value must be a literal or an imported binding to be hoistable by tools like `zod-compiler`." },
|
|
11
|
+
schema: []
|
|
12
|
+
},
|
|
13
|
+
defaultOptions: [],
|
|
14
|
+
create: (0, _eslint_zod_utils_rule_builders_no_dynamic_schema_value.buildNoDynamicSchemaValueCreate)(_eslint_zod_utils.zodMiniImportScope)
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.noDynamicSchemaValue = noDynamicSchemaValue;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createZodMiniPluginRule } from "../utils/create-plugin-rule.mjs";
|
|
2
|
+
import { zodMiniImportScope } from "@eslint-zod/utils";
|
|
3
|
+
import { buildNoDynamicSchemaValueCreate } from "@eslint-zod/utils/rule-builders/no-dynamic-schema-value";
|
|
4
|
+
//#region src/rules/no-dynamic-schema-value.ts
|
|
5
|
+
const noDynamicSchemaValue = createZodMiniPluginRule({
|
|
6
|
+
name: "no-dynamic-schema-value",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
docs: { description: "Disallow non-static values passed as arguments in a Zod Mini schema expression" },
|
|
10
|
+
messages: { dynamicValue: "This value must be a literal or an imported binding to be hoistable by tools like `zod-compiler`." },
|
|
11
|
+
schema: []
|
|
12
|
+
},
|
|
13
|
+
defaultOptions: [],
|
|
14
|
+
create: buildNoDynamicSchemaValueCreate(zodMiniImportScope)
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { noDynamicSchemaValue };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_create_plugin_rule = require("../utils/create-plugin-rule.cjs");
|
|
2
|
+
let _eslint_zod_utils = require("@eslint-zod/utils");
|
|
3
|
+
let _eslint_zod_utils_rule_builders_no_function_scoped_schema = require("@eslint-zod/utils/rule-builders/no-function-scoped-schema");
|
|
4
|
+
//#region src/rules/no-function-scoped-schema.ts
|
|
5
|
+
const noFunctionScopedSchema = require_create_plugin_rule.createZodMiniPluginRule({
|
|
6
|
+
name: "no-function-scoped-schema",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
docs: { description: "Disallow constructing a Zod Mini schema inside a function body" },
|
|
10
|
+
messages: { functionScopedSchema: "This schema is constructed inside a function and rebuilt on every call. Declare it once at module scope instead." },
|
|
11
|
+
schema: []
|
|
12
|
+
},
|
|
13
|
+
defaultOptions: [],
|
|
14
|
+
create: (0, _eslint_zod_utils_rule_builders_no_function_scoped_schema.buildNoFunctionScopedSchemaCreate)(_eslint_zod_utils.zodMiniImportScope)
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.noFunctionScopedSchema = noFunctionScopedSchema;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createZodMiniPluginRule } from "../utils/create-plugin-rule.mjs";
|
|
2
|
+
import { zodMiniImportScope } from "@eslint-zod/utils";
|
|
3
|
+
import { buildNoFunctionScopedSchemaCreate } from "@eslint-zod/utils/rule-builders/no-function-scoped-schema";
|
|
4
|
+
//#region src/rules/no-function-scoped-schema.ts
|
|
5
|
+
const noFunctionScopedSchema = createZodMiniPluginRule({
|
|
6
|
+
name: "no-function-scoped-schema",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
docs: { description: "Disallow constructing a Zod Mini schema inside a function body" },
|
|
10
|
+
messages: { functionScopedSchema: "This schema is constructed inside a function and rebuilt on every call. Declare it once at module scope instead." },
|
|
11
|
+
schema: []
|
|
12
|
+
},
|
|
13
|
+
defaultOptions: [],
|
|
14
|
+
create: buildNoFunctionScopedSchemaCreate(zodMiniImportScope)
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { noFunctionScopedSchema };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_create_plugin_rule = require("../utils/create-plugin-rule.cjs");
|
|
2
2
|
let _eslint_zod_utils = require("@eslint-zod/utils");
|
|
3
|
-
let _typescript_eslint_utils = require("@typescript-eslint/utils");
|
|
4
3
|
let _eslint_zod_utils_rule_builders_no_transform_in_record_key = require("@eslint-zod/utils/rule-builders/no-transform-in-record-key");
|
|
5
4
|
//#region src/rules/no-transform-in-record-key.ts
|
|
6
5
|
const noTransformInRecordKey = require_create_plugin_rule.createZodMiniPluginRule({
|
|
@@ -12,18 +11,7 @@ const noTransformInRecordKey = require_create_plugin_rule.createZodMiniPluginRul
|
|
|
12
11
|
schema: []
|
|
13
12
|
},
|
|
14
13
|
defaultOptions: [],
|
|
15
|
-
create: (0, _eslint_zod_utils_rule_builders_no_transform_in_record_key.buildNoTransformInRecordKeyCreate)(_eslint_zod_utils.zodMiniImportScope,
|
|
16
|
-
if (keySchema.type !== _typescript_eslint_utils.AST_NODE_TYPES.CallExpression) return null;
|
|
17
|
-
for (const method of collectZodChainMethods(keySchema)) {
|
|
18
|
-
if (method.name !== "check") continue;
|
|
19
|
-
for (const argument of method.node.arguments) {
|
|
20
|
-
if (argument.type !== _typescript_eslint_utils.AST_NODE_TYPES.CallExpression) continue;
|
|
21
|
-
const zodCheck = detectZodSchemaRootNode(argument);
|
|
22
|
-
if (zodCheck && _eslint_zod_utils.ZOD_MUTATING_CHECK_NAMES.includes(zodCheck.schemaType)) return argument;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
} })
|
|
14
|
+
create: (0, _eslint_zod_utils_rule_builders_no_transform_in_record_key.buildNoTransformInRecordKeyCreate)(_eslint_zod_utils.zodMiniImportScope, _eslint_zod_utils.ZOD_MUTATING_CHECK_NAMES)
|
|
27
15
|
});
|
|
28
16
|
//#endregion
|
|
29
17
|
exports.noTransformInRecordKey = noTransformInRecordKey;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createZodMiniPluginRule } from "../utils/create-plugin-rule.mjs";
|
|
2
2
|
import { ZOD_MUTATING_CHECK_NAMES, zodMiniImportScope } from "@eslint-zod/utils";
|
|
3
|
-
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4
3
|
import { buildNoTransformInRecordKeyCreate } from "@eslint-zod/utils/rule-builders/no-transform-in-record-key";
|
|
5
4
|
//#region src/rules/no-transform-in-record-key.ts
|
|
6
5
|
const noTransformInRecordKey = createZodMiniPluginRule({
|
|
@@ -12,18 +11,7 @@ const noTransformInRecordKey = createZodMiniPluginRule({
|
|
|
12
11
|
schema: []
|
|
13
12
|
},
|
|
14
13
|
defaultOptions: [],
|
|
15
|
-
create: buildNoTransformInRecordKeyCreate(zodMiniImportScope,
|
|
16
|
-
if (keySchema.type !== AST_NODE_TYPES.CallExpression) return null;
|
|
17
|
-
for (const method of collectZodChainMethods(keySchema)) {
|
|
18
|
-
if (method.name !== "check") continue;
|
|
19
|
-
for (const argument of method.node.arguments) {
|
|
20
|
-
if (argument.type !== AST_NODE_TYPES.CallExpression) continue;
|
|
21
|
-
const zodCheck = detectZodSchemaRootNode(argument);
|
|
22
|
-
if (zodCheck && ZOD_MUTATING_CHECK_NAMES.includes(zodCheck.schemaType)) return argument;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
} })
|
|
14
|
+
create: buildNoTransformInRecordKeyCreate(zodMiniImportScope, ZOD_MUTATING_CHECK_NAMES)
|
|
27
15
|
});
|
|
28
16
|
//#endregion
|
|
29
17
|
export { noTransformInRecordKey };
|
|
@@ -12,7 +12,7 @@ const preferMeta = require_create_plugin_rule.createZodMiniPluginRule({
|
|
|
12
12
|
},
|
|
13
13
|
defaultOptions: [],
|
|
14
14
|
create(context) {
|
|
15
|
-
const { createSchemaVisitor } = _eslint_zod_utils.zodMiniImportScope.createTracker();
|
|
15
|
+
const { createSchemaVisitor } = _eslint_zod_utils.zodMiniImportScope.createTracker({ kind: "value" });
|
|
16
16
|
return createSchemaVisitor({
|
|
17
17
|
schemaType: "describe",
|
|
18
18
|
onSchema(node, zodSchemaMeta) {
|
|
@@ -12,7 +12,7 @@ const preferMeta = createZodMiniPluginRule({
|
|
|
12
12
|
},
|
|
13
13
|
defaultOptions: [],
|
|
14
14
|
create(context) {
|
|
15
|
-
const { createSchemaVisitor } = zodMiniImportScope.createTracker();
|
|
15
|
+
const { createSchemaVisitor } = zodMiniImportScope.createTracker({ kind: "value" });
|
|
16
16
|
return createSchemaVisitor({
|
|
17
17
|
schemaType: "describe",
|
|
18
18
|
onSchema(node, zodSchemaMeta) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_create_plugin_rule = require("../utils/create-plugin-rule.cjs");
|
|
2
|
+
let _eslint_zod_utils = require("@eslint-zod/utils");
|
|
3
|
+
let _eslint_zod_utils_rule_builders_prefer_validate = require("@eslint-zod/utils/rule-builders/prefer-validate");
|
|
4
|
+
//#region src/rules/prefer-validate.ts
|
|
5
|
+
const preferValidate = require_create_plugin_rule.createZodMiniPluginRule({
|
|
6
|
+
name: "prefer-validate",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
hasSuggestions: true,
|
|
10
|
+
docs: { description: "Prefer boolean validation when only the success of parsing is used" },
|
|
11
|
+
messages: {
|
|
12
|
+
preferValidate: "Prefer `{{method}}` when only parse success is used.",
|
|
13
|
+
useValidate: "Replace success-only parsing with `{{method}}`."
|
|
14
|
+
},
|
|
15
|
+
schema: []
|
|
16
|
+
},
|
|
17
|
+
defaultOptions: [],
|
|
18
|
+
create: (0, _eslint_zod_utils_rule_builders_prefer_validate.buildPreferValidateCreate)(_eslint_zod_utils.zodMiniImportScope, "standalone")
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.preferValidate = preferValidate;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createZodMiniPluginRule } from "../utils/create-plugin-rule.mjs";
|
|
2
|
+
import { zodMiniImportScope } from "@eslint-zod/utils";
|
|
3
|
+
import { buildPreferValidateCreate } from "@eslint-zod/utils/rule-builders/prefer-validate";
|
|
4
|
+
//#region src/rules/prefer-validate.ts
|
|
5
|
+
const preferValidate = createZodMiniPluginRule({
|
|
6
|
+
name: "prefer-validate",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
hasSuggestions: true,
|
|
10
|
+
docs: { description: "Prefer boolean validation when only the success of parsing is used" },
|
|
11
|
+
messages: {
|
|
12
|
+
preferValidate: "Prefer `{{method}}` when only parse success is used.",
|
|
13
|
+
useValidate: "Replace success-only parsing with `{{method}}`."
|
|
14
|
+
},
|
|
15
|
+
schema: []
|
|
16
|
+
},
|
|
17
|
+
defaultOptions: [],
|
|
18
|
+
create: buildPreferValidateCreate(zodMiniImportScope, "standalone")
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { preferValidate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-zod-mini",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "ESLint plugin that adds custom linting rules to enforce best practices when using Zod Mini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -38,15 +38,16 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/utils": "^8.
|
|
42
|
-
"@eslint-zod/utils": "
|
|
41
|
+
"@typescript-eslint/utils": "^8.70.0",
|
|
42
|
+
"@eslint-zod/utils": "5.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@
|
|
45
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
46
|
+
"@typescript-eslint/rule-tester": "8.70.0",
|
|
46
47
|
"dedent": "1.7.2",
|
|
47
|
-
"eslint-doc-generator": "3.7.
|
|
48
|
-
"tsdown": "0.
|
|
49
|
-
"vitest": "
|
|
48
|
+
"eslint-doc-generator": "3.7.1",
|
|
49
|
+
"tsdown": "0.23.0",
|
|
50
|
+
"vitest": "5.0.0",
|
|
50
51
|
"@eslint-zod/tooling": "0.0.0"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"build": "tsdown",
|
|
74
|
+
"lint:publish": "attw --pack .",
|
|
73
75
|
"build:docs": "pnpm run build && eslint-doc-generator",
|
|
74
76
|
"lint:docs": "eslint-doc-generator --check",
|
|
75
77
|
"test": "vitest"
|