eslint-plugin-zod 4.8.0 → 4.9.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 +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.mjs +3 -0
- package/dist/rules/prefer-nullish.cjs +18 -0
- package/dist/rules/prefer-nullish.mjs +18 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ Find out more about [Oxlint's `jsPLugins`](https://oxc.rs/docs/guide/usage/linte
|
|
|
65
65
|
| [prefer-loose-object](docs/rules/prefer-loose-object.md) | Prefer `z.looseObject()` over `z.object().passthrough()` and `z.object().loose()` | ✅ | 🔧 | | |
|
|
66
66
|
| [prefer-meta](docs/rules/prefer-meta.md) | Enforce usage of `.meta()` over `.describe()` | ✅ | 🔧 | | |
|
|
67
67
|
| [prefer-meta-last](docs/rules/prefer-meta-last.md) | Enforce `.meta()` as last method | ✅ | 🔧 | | |
|
|
68
|
+
| [prefer-nullish](docs/rules/prefer-nullish.md) | Enforce `.nullish()` instead of combining `.optional()` and `.nullable()` | ✅ | 🔧 | | |
|
|
68
69
|
| [prefer-strict-object](docs/rules/prefer-strict-object.md) | Prefer `z.strictObject()` over `z.object().strict()` | ✅ | 🔧 | | |
|
|
69
70
|
| [prefer-string-schema-with-trim](docs/rules/prefer-string-schema-with-trim.md) | Enforce `z.string().trim()` to prevent accidental leading/trailing whitespace | ✅ | 🔧 | | |
|
|
70
71
|
| [prefer-top-level-string-formats](docs/rules/prefer-top-level-string-formats.md) | Prefer top-level string format schemas over deprecated `z.string().<format>()` methods | ✅ | 🔧 | | |
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ const require_prefer_enum_over_literal_union = require("./rules/prefer-enum-over
|
|
|
30
30
|
const require_prefer_loose_object = require("./rules/prefer-loose-object.cjs");
|
|
31
31
|
const require_prefer_meta_last = require("./rules/prefer-meta-last.cjs");
|
|
32
32
|
const require_prefer_meta = require("./rules/prefer-meta.cjs");
|
|
33
|
+
const require_prefer_nullish = require("./rules/prefer-nullish.cjs");
|
|
33
34
|
const require_prefer_strict_object = require("./rules/prefer-strict-object.cjs");
|
|
34
35
|
const require_prefer_string_schema_with_trim = require("./rules/prefer-string-schema-with-trim.cjs");
|
|
35
36
|
const require_prefer_top_level_string_formats = require("./rules/prefer-top-level-string-formats.cjs");
|
|
@@ -76,6 +77,7 @@ const eslintPluginZod = {
|
|
|
76
77
|
"prefer-loose-object": require_prefer_loose_object.preferLooseObject,
|
|
77
78
|
"prefer-meta": require_prefer_meta.preferMeta,
|
|
78
79
|
"prefer-meta-last": require_prefer_meta_last.preferMetaLast,
|
|
80
|
+
"prefer-nullish": require_prefer_nullish.preferNullish,
|
|
79
81
|
"prefer-strict-object": require_prefer_strict_object.preferStrictObject,
|
|
80
82
|
"prefer-top-level-string-formats": require_prefer_top_level_string_formats.preferTopLevelStringFormats,
|
|
81
83
|
"prefer-string-schema-with-trim": require_prefer_string_schema_with_trim.preferStringSchemaWithTrim,
|
|
@@ -114,6 +116,7 @@ const recommendedConfig = {
|
|
|
114
116
|
"zod/prefer-loose-object": "error",
|
|
115
117
|
"zod/prefer-meta": "error",
|
|
116
118
|
"zod/prefer-meta-last": "error",
|
|
119
|
+
"zod/prefer-nullish": "error",
|
|
117
120
|
"zod/prefer-strict-object": "error",
|
|
118
121
|
"zod/prefer-top-level-string-formats": "error",
|
|
119
122
|
"zod/prefer-string-schema-with-trim": "error",
|
package/dist/index.mjs
CHANGED
|
@@ -30,6 +30,7 @@ import { preferEnumOverLiteralUnion } from "./rules/prefer-enum-over-literal-uni
|
|
|
30
30
|
import { preferLooseObject } from "./rules/prefer-loose-object.mjs";
|
|
31
31
|
import { preferMetaLast } from "./rules/prefer-meta-last.mjs";
|
|
32
32
|
import { preferMeta } from "./rules/prefer-meta.mjs";
|
|
33
|
+
import { preferNullish } from "./rules/prefer-nullish.mjs";
|
|
33
34
|
import { preferStrictObject } from "./rules/prefer-strict-object.mjs";
|
|
34
35
|
import { preferStringSchemaWithTrim } from "./rules/prefer-string-schema-with-trim.mjs";
|
|
35
36
|
import { preferTopLevelStringFormats } from "./rules/prefer-top-level-string-formats.mjs";
|
|
@@ -76,6 +77,7 @@ const eslintPluginZod = {
|
|
|
76
77
|
"prefer-loose-object": preferLooseObject,
|
|
77
78
|
"prefer-meta": preferMeta,
|
|
78
79
|
"prefer-meta-last": preferMetaLast,
|
|
80
|
+
"prefer-nullish": preferNullish,
|
|
79
81
|
"prefer-strict-object": preferStrictObject,
|
|
80
82
|
"prefer-top-level-string-formats": preferTopLevelStringFormats,
|
|
81
83
|
"prefer-string-schema-with-trim": preferStringSchemaWithTrim,
|
|
@@ -114,6 +116,7 @@ const recommendedConfig = {
|
|
|
114
116
|
"zod/prefer-loose-object": "error",
|
|
115
117
|
"zod/prefer-meta": "error",
|
|
116
118
|
"zod/prefer-meta-last": "error",
|
|
119
|
+
"zod/prefer-nullish": "error",
|
|
117
120
|
"zod/prefer-strict-object": "error",
|
|
118
121
|
"zod/prefer-top-level-string-formats": "error",
|
|
119
122
|
"zod/prefer-string-schema-with-trim": "error",
|
|
@@ -0,0 +1,18 @@
|
|
|
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_nullish = require("@eslint-zod/utils/rule-builders/prefer-nullish");
|
|
4
|
+
//#region src/rules/prefer-nullish.ts
|
|
5
|
+
const preferNullish = require_create_plugin_rule.createZodPluginRule({
|
|
6
|
+
name: "prefer-nullish",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
fixable: "code",
|
|
10
|
+
docs: { description: "Enforce `.nullish()` instead of combining `.optional()` and `.nullable()`" },
|
|
11
|
+
messages: { preferNullish: "Combining `.optional()` and `.nullable()` is redundant. Use `.nullish()` instead." },
|
|
12
|
+
schema: []
|
|
13
|
+
},
|
|
14
|
+
defaultOptions: [],
|
|
15
|
+
create: (0, _eslint_zod_utils_rule_builders_prefer_nullish.buildPreferNullishCreate)(_eslint_zod_utils.zodImportScope)
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.preferNullish = preferNullish;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.mjs";
|
|
2
|
+
import { zodImportScope } from "@eslint-zod/utils";
|
|
3
|
+
import { buildPreferNullishCreate } from "@eslint-zod/utils/rule-builders/prefer-nullish";
|
|
4
|
+
//#region src/rules/prefer-nullish.ts
|
|
5
|
+
const preferNullish = createZodPluginRule({
|
|
6
|
+
name: "prefer-nullish",
|
|
7
|
+
meta: {
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
fixable: "code",
|
|
10
|
+
docs: { description: "Enforce `.nullish()` instead of combining `.optional()` and `.nullable()`" },
|
|
11
|
+
messages: { preferNullish: "Combining `.optional()` and `.nullable()` is redundant. Use `.nullish()` instead." },
|
|
12
|
+
schema: []
|
|
13
|
+
},
|
|
14
|
+
defaultOptions: [],
|
|
15
|
+
create: buildPreferNullishCreate(zodImportScope)
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { preferNullish };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-zod",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "ESLint plugin that adds custom linting rules to enforce best practices when using Zod",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@typescript-eslint/utils": "^8.62.0",
|
|
42
|
-
"@eslint-zod/utils": "2.
|
|
42
|
+
"@eslint-zod/utils": "2.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@marcalexiei/prettier-config": "2.0.0",
|