eslint-plugin-zod 3.2.0 → 3.4.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 +33 -21
- package/dist/index.cjs +15 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -4
- package/dist/rules/array-style.cjs +5 -4
- package/dist/rules/array-style.d.cts +3 -2
- package/dist/rules/array-style.d.ts +3 -2
- package/dist/rules/array-style.js +5 -4
- package/dist/rules/consistent-import-source.cjs +5 -11
- package/dist/rules/consistent-import-source.d.cts +4 -3
- package/dist/rules/consistent-import-source.d.ts +4 -3
- package/dist/rules/consistent-import-source.js +4 -10
- package/dist/rules/consistent-import.cjs +4 -3
- package/dist/rules/consistent-import.d.cts +3 -2
- package/dist/rules/consistent-import.d.ts +3 -2
- package/dist/rules/consistent-import.js +5 -4
- package/dist/rules/consistent-object-schema-type.cjs +5 -3
- package/dist/rules/consistent-object-schema-type.d.cts +3 -1
- package/dist/rules/consistent-object-schema-type.d.ts +3 -1
- package/dist/rules/consistent-object-schema-type.js +6 -4
- package/dist/rules/no-any-schema.cjs +5 -3
- package/dist/rules/no-any-schema.d.cts +3 -1
- package/dist/rules/no-any-schema.d.ts +3 -1
- package/dist/rules/no-any-schema.js +6 -4
- package/dist/rules/no-empty-custom-schema.cjs +5 -4
- package/dist/rules/no-empty-custom-schema.d.cts +3 -2
- package/dist/rules/no-empty-custom-schema.d.ts +3 -2
- package/dist/rules/no-empty-custom-schema.js +5 -4
- package/dist/rules/no-number-schema-with-int.cjs +5 -4
- package/dist/rules/no-number-schema-with-int.d.cts +3 -2
- package/dist/rules/no-number-schema-with-int.d.ts +3 -2
- package/dist/rules/no-number-schema-with-int.js +5 -4
- package/dist/rules/no-optional-and-default-together.cjs +6 -5
- package/dist/rules/no-optional-and-default-together.d.cts +3 -2
- package/dist/rules/no-optional-and-default-together.d.ts +3 -2
- package/dist/rules/no-optional-and-default-together.js +7 -6
- package/dist/rules/no-string-schema-with-uuid.cjs +5 -4
- package/dist/rules/no-string-schema-with-uuid.d.cts +3 -2
- package/dist/rules/no-string-schema-with-uuid.d.ts +3 -2
- package/dist/rules/no-string-schema-with-uuid.js +5 -4
- package/dist/rules/no-throw-in-refine.cjs +5 -3
- package/dist/rules/no-throw-in-refine.d.cts +3 -2
- package/dist/rules/no-throw-in-refine.d.ts +3 -2
- package/dist/rules/no-throw-in-refine.js +6 -4
- package/dist/rules/no-unknown-schema.cjs +5 -4
- package/dist/rules/no-unknown-schema.d.cts +3 -2
- package/dist/rules/no-unknown-schema.d.ts +3 -2
- package/dist/rules/no-unknown-schema.js +5 -4
- package/dist/rules/prefer-enum-over-literal-union.cjs +5 -3
- package/dist/rules/prefer-enum-over-literal-union.d.cts +3 -2
- package/dist/rules/prefer-enum-over-literal-union.d.ts +3 -2
- package/dist/rules/prefer-enum-over-literal-union.js +6 -4
- package/dist/rules/prefer-meta-last.cjs +8 -5
- package/dist/rules/prefer-meta-last.d.cts +3 -2
- package/dist/rules/prefer-meta-last.d.ts +3 -2
- package/dist/rules/prefer-meta-last.js +8 -5
- package/dist/rules/prefer-meta.cjs +5 -4
- package/dist/rules/prefer-meta.d.cts +3 -2
- package/dist/rules/prefer-meta.d.ts +3 -2
- package/dist/rules/prefer-meta.js +5 -4
- package/dist/rules/prefer-namespace-import.cjs +4 -3
- package/dist/rules/prefer-namespace-import.d.cts +3 -2
- package/dist/rules/prefer-namespace-import.d.ts +3 -2
- package/dist/rules/prefer-namespace-import.js +5 -4
- package/dist/rules/prefer-string-schema-with-trim.cjs +53 -0
- package/dist/rules/prefer-string-schema-with-trim.d.cts +5 -0
- package/dist/rules/prefer-string-schema-with-trim.d.ts +5 -0
- package/dist/rules/prefer-string-schema-with-trim.js +50 -0
- package/dist/rules/require-brand-type-parameter.cjs +5 -4
- package/dist/rules/require-brand-type-parameter.d.cts +3 -1
- package/dist/rules/require-brand-type-parameter.d.ts +3 -1
- package/dist/rules/require-brand-type-parameter.js +5 -4
- package/dist/rules/require-error-message.cjs +5 -3
- package/dist/rules/require-error-message.d.cts +3 -2
- package/dist/rules/require-error-message.d.ts +3 -2
- package/dist/rules/require-error-message.js +6 -4
- package/dist/rules/require-schema-suffix.cjs +5 -3
- package/dist/rules/require-schema-suffix.d.cts +3 -2
- package/dist/rules/require-schema-suffix.d.ts +3 -2
- package/dist/rules/require-schema-suffix.js +6 -4
- package/dist/rules/schema-error-property-style.cjs +5 -3
- package/dist/rules/schema-error-property-style.d.cts +4 -3
- package/dist/rules/schema-error-property-style.d.ts +4 -3
- package/dist/rules/schema-error-property-style.js +6 -4
- package/dist/utils/build-zod-chain-replacement-fix.cjs +8 -1
- package/dist/utils/build-zod-chain-replacement-fix.js +8 -1
- package/dist/utils/create-plugin-rule.cjs +6 -0
- package/dist/utils/create-plugin-rule.d.cts +13 -0
- package/dist/utils/create-plugin-rule.d.ts +13 -0
- package/dist/utils/create-plugin-rule.js +3 -0
- package/dist/utils/is-zod-import-source.cjs +17 -2
- package/dist/utils/is-zod-import-source.d.cts +4 -1
- package/dist/utils/is-zod-import-source.d.ts +4 -1
- package/dist/utils/is-zod-import-source.js +16 -2
- package/dist/utils/track-zod-schema-imports.cjs +9 -2
- package/dist/utils/track-zod-schema-imports.d.cts +6 -1
- package/dist/utils/track-zod-schema-imports.d.ts +6 -1
- package/dist/utils/track-zod-schema-imports.js +8 -2
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noEmptyCustomSchema = void 0;
|
|
4
|
-
const
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
4
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
5
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
7
|
-
|
|
6
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('all');
|
|
7
|
+
exports.noEmptyCustomSchema = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
8
8
|
name: 'no-empty-custom-schema',
|
|
9
9
|
meta: {
|
|
10
10
|
hasSuggestions: false,
|
|
11
11
|
type: 'suggestion',
|
|
12
12
|
docs: {
|
|
13
|
+
zodImportAllowedSource,
|
|
13
14
|
description: 'Disallow usage of `z.custom()` without arguments',
|
|
14
15
|
},
|
|
15
16
|
messages: {
|
|
@@ -19,7 +20,7 @@ exports.noEmptyCustomSchema = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleU
|
|
|
19
20
|
},
|
|
20
21
|
defaultOptions: [],
|
|
21
22
|
create(context) {
|
|
22
|
-
const { importDeclarationListener, detectZodSchemaRootNode, } =
|
|
23
|
+
const { importDeclarationListener, detectZodSchemaRootNode, } = trackZodSchemaImports();
|
|
23
24
|
return {
|
|
24
25
|
ImportDeclaration: importDeclarationListener,
|
|
25
26
|
CallExpression(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noEmptyCustomSchema: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"noEmptyCustomSchema", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noEmptyCustomSchema: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noEmptyCustomSchema", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const noEmptyCustomSchema =
|
|
1
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
2
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
3
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('all');
|
|
4
|
+
export const noEmptyCustomSchema = createZodPluginRule({
|
|
5
5
|
name: 'no-empty-custom-schema',
|
|
6
6
|
meta: {
|
|
7
7
|
hasSuggestions: false,
|
|
8
8
|
type: 'suggestion',
|
|
9
9
|
docs: {
|
|
10
|
+
zodImportAllowedSource,
|
|
10
11
|
description: 'Disallow usage of `z.custom()` without arguments',
|
|
11
12
|
},
|
|
12
13
|
messages: {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noNumberSchemaWithInt = void 0;
|
|
4
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
6
4
|
const build_zod_chain_replacement_fix_js_1 = require("../utils/build-zod-chain-replacement-fix.cjs");
|
|
5
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
7
6
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
8
|
-
|
|
7
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
|
|
8
|
+
exports.noNumberSchemaWithInt = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
9
9
|
name: 'no-number-schema-with-int',
|
|
10
10
|
meta: {
|
|
11
11
|
fixable: 'code',
|
|
12
12
|
type: 'problem',
|
|
13
13
|
docs: {
|
|
14
|
+
zodImportAllowedSource,
|
|
14
15
|
description: 'Disallow usage of `z.number().int()` as it is considered legacy',
|
|
15
16
|
},
|
|
16
17
|
messages: {
|
|
@@ -21,7 +22,7 @@ exports.noNumberSchemaWithInt = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRul
|
|
|
21
22
|
defaultOptions: [],
|
|
22
23
|
create(context) {
|
|
23
24
|
const { sourceCode } = context;
|
|
24
|
-
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } =
|
|
25
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
25
26
|
return {
|
|
26
27
|
ImportDeclaration: importDeclarationListener,
|
|
27
28
|
CallExpression(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noNumberSchemaWithInt: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"removeNumber", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noNumberSchemaWithInt: import("@typescript-eslint/utils/ts-eslint").RuleModule<"removeNumber", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
import { getRuleURL } from "../meta.js";
|
|
3
1
|
import { buildZodChainReplacementFix } from "../utils/build-zod-chain-replacement-fix.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
3
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
4
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
|
|
5
|
+
export const noNumberSchemaWithInt = createZodPluginRule({
|
|
6
6
|
name: 'no-number-schema-with-int',
|
|
7
7
|
meta: {
|
|
8
8
|
fixable: 'code',
|
|
9
9
|
type: 'problem',
|
|
10
10
|
docs: {
|
|
11
|
+
zodImportAllowedSource,
|
|
11
12
|
description: 'Disallow usage of `z.number().int()` as it is considered legacy',
|
|
12
13
|
},
|
|
13
14
|
messages: {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noOptionalAndDefaultTogether = void 0;
|
|
4
|
-
const
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
4
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
5
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
6
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
|
|
7
7
|
const preferredMethods = ['none', 'default', 'optional'];
|
|
8
8
|
const defaultOptions = { preferredMethod: 'none' };
|
|
9
|
-
exports.noOptionalAndDefaultTogether =
|
|
9
|
+
exports.noOptionalAndDefaultTogether = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
10
10
|
name: 'no-optional-and-default-together',
|
|
11
11
|
meta: {
|
|
12
12
|
type: 'problem',
|
|
13
13
|
fixable: 'code',
|
|
14
14
|
docs: {
|
|
15
|
+
zodImportAllowedSource,
|
|
15
16
|
description: 'Disallow using both `.optional()` and `.default()` on the same Zod schema',
|
|
16
17
|
},
|
|
17
18
|
messages: {
|
|
@@ -35,11 +36,11 @@ exports.noOptionalAndDefaultTogether = utils_1.ESLintUtils.RuleCreator(meta_js_1
|
|
|
35
36
|
defaultOptions: [defaultOptions],
|
|
36
37
|
create(context, [{ preferredMethod }]) {
|
|
37
38
|
const { sourceCode } = context;
|
|
38
|
-
const { importDeclarationListener, detectZodSchemaRootNode
|
|
39
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
39
40
|
return {
|
|
40
41
|
ImportDeclaration: importDeclarationListener,
|
|
41
42
|
CallExpression(node) {
|
|
42
|
-
if (!
|
|
43
|
+
if (!detectZodSchemaRootNode(node)) {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
const methods = collectZodChainMethods(node);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
1
|
declare const preferredMethods: readonly ["none", "default", "optional"];
|
|
3
2
|
type PreferredMethod = (typeof preferredMethods)[number];
|
|
4
3
|
interface Options {
|
|
5
4
|
preferredMethod: PreferredMethod;
|
|
6
5
|
}
|
|
7
6
|
type MessageIds = 'noOptionalAndDefaultTogether' | 'noOptionalAndDefaultTogetherRemoveMethod';
|
|
8
|
-
export declare const noOptionalAndDefaultTogether:
|
|
7
|
+
export declare const noOptionalAndDefaultTogether: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<MessageIds, [Options], {
|
|
8
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
9
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
9
10
|
name: string;
|
|
10
11
|
};
|
|
11
12
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
1
|
declare const preferredMethods: readonly ["none", "default", "optional"];
|
|
3
2
|
type PreferredMethod = (typeof preferredMethods)[number];
|
|
4
3
|
interface Options {
|
|
5
4
|
preferredMethod: PreferredMethod;
|
|
6
5
|
}
|
|
7
6
|
type MessageIds = 'noOptionalAndDefaultTogether' | 'noOptionalAndDefaultTogetherRemoveMethod';
|
|
8
|
-
export declare const noOptionalAndDefaultTogether:
|
|
7
|
+
export declare const noOptionalAndDefaultTogether: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, [Options], {
|
|
8
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
9
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
9
10
|
name: string;
|
|
10
11
|
};
|
|
11
12
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
2
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
3
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
|
|
4
4
|
const preferredMethods = ['none', 'default', 'optional'];
|
|
5
5
|
const defaultOptions = { preferredMethod: 'none' };
|
|
6
|
-
export const noOptionalAndDefaultTogether =
|
|
6
|
+
export const noOptionalAndDefaultTogether = createZodPluginRule({
|
|
7
7
|
name: 'no-optional-and-default-together',
|
|
8
8
|
meta: {
|
|
9
9
|
type: 'problem',
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
docs: {
|
|
12
|
+
zodImportAllowedSource,
|
|
12
13
|
description: 'Disallow using both `.optional()` and `.default()` on the same Zod schema',
|
|
13
14
|
},
|
|
14
15
|
messages: {
|
|
@@ -32,11 +33,11 @@ export const noOptionalAndDefaultTogether = ESLintUtils.RuleCreator(getRuleURL)(
|
|
|
32
33
|
defaultOptions: [defaultOptions],
|
|
33
34
|
create(context, [{ preferredMethod }]) {
|
|
34
35
|
const { sourceCode } = context;
|
|
35
|
-
const { importDeclarationListener, detectZodSchemaRootNode
|
|
36
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
36
37
|
return {
|
|
37
38
|
ImportDeclaration: importDeclarationListener,
|
|
38
39
|
CallExpression(node) {
|
|
39
|
-
if (!
|
|
40
|
+
if (!detectZodSchemaRootNode(node)) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
43
|
const methods = collectZodChainMethods(node);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noStringSchemaWithUuid = void 0;
|
|
4
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
6
4
|
const build_zod_chain_replacement_fix_js_1 = require("../utils/build-zod-chain-replacement-fix.cjs");
|
|
5
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
7
6
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
8
|
-
|
|
7
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
|
|
8
|
+
exports.noStringSchemaWithUuid = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
9
9
|
name: 'no-string-schema-with-uuid',
|
|
10
10
|
meta: {
|
|
11
11
|
fixable: 'code',
|
|
12
12
|
type: 'problem',
|
|
13
13
|
docs: {
|
|
14
|
+
zodImportAllowedSource,
|
|
14
15
|
description: 'Disallow usage of `z.string().uuid()` in favor of the dedicated `z.uuid()` schema',
|
|
15
16
|
url: 'https://zod.dev/api#uuids',
|
|
16
17
|
},
|
|
@@ -22,7 +23,7 @@ exports.noStringSchemaWithUuid = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRu
|
|
|
22
23
|
defaultOptions: [],
|
|
23
24
|
create(context) {
|
|
24
25
|
const { sourceCode } = context;
|
|
25
|
-
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } =
|
|
26
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
26
27
|
return {
|
|
27
28
|
ImportDeclaration: importDeclarationListener,
|
|
28
29
|
CallExpression(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noStringSchemaWithUuid: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"useUuid", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noStringSchemaWithUuid: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useUuid", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
import { getRuleURL } from "../meta.js";
|
|
3
1
|
import { buildZodChainReplacementFix } from "../utils/build-zod-chain-replacement-fix.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
3
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
4
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
|
|
5
|
+
export const noStringSchemaWithUuid = createZodPluginRule({
|
|
6
6
|
name: 'no-string-schema-with-uuid',
|
|
7
7
|
meta: {
|
|
8
8
|
fixable: 'code',
|
|
9
9
|
type: 'problem',
|
|
10
10
|
docs: {
|
|
11
|
+
zodImportAllowedSource,
|
|
11
12
|
description: 'Disallow usage of `z.string().uuid()` in favor of the dedicated `z.uuid()` schema',
|
|
12
13
|
url: 'https://zod.dev/api#uuids',
|
|
13
14
|
},
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noThrowInRefine = void 0;
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
const
|
|
5
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
6
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
7
|
-
|
|
7
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
|
|
8
|
+
exports.noThrowInRefine = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
8
9
|
name: 'no-throw-in-refine',
|
|
9
10
|
meta: {
|
|
10
11
|
type: 'problem',
|
|
11
12
|
docs: {
|
|
13
|
+
zodImportAllowedSource,
|
|
12
14
|
description: 'Disallow throwing errors directly inside Zod refine callbacks',
|
|
13
15
|
},
|
|
14
16
|
messages: {
|
|
@@ -18,7 +20,7 @@ exports.noThrowInRefine = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)(
|
|
|
18
20
|
},
|
|
19
21
|
defaultOptions: [],
|
|
20
22
|
create(context) {
|
|
21
|
-
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } =
|
|
23
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
22
24
|
function checkNode(node) {
|
|
23
25
|
if (!node) {
|
|
24
26
|
return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noThrowInRefine: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"noThrowInRefine", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noThrowInRefine: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noThrowInRefine", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { AST_NODE_TYPES
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
3
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
4
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
|
|
5
|
+
export const noThrowInRefine = createZodPluginRule({
|
|
5
6
|
name: 'no-throw-in-refine',
|
|
6
7
|
meta: {
|
|
7
8
|
type: 'problem',
|
|
8
9
|
docs: {
|
|
10
|
+
zodImportAllowedSource,
|
|
9
11
|
description: 'Disallow throwing errors directly inside Zod refine callbacks',
|
|
10
12
|
},
|
|
11
13
|
messages: {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noUnknownSchema = void 0;
|
|
4
|
-
const
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
4
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
5
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
7
|
-
|
|
6
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('all');
|
|
7
|
+
exports.noUnknownSchema = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
8
8
|
name: 'no-unknown-schema',
|
|
9
9
|
meta: {
|
|
10
10
|
type: 'suggestion',
|
|
11
11
|
docs: {
|
|
12
|
+
zodImportAllowedSource,
|
|
12
13
|
description: 'Disallow usage of `z.unknown()` in Zod schemas',
|
|
13
14
|
},
|
|
14
15
|
messages: {
|
|
@@ -18,7 +19,7 @@ exports.noUnknownSchema = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)(
|
|
|
18
19
|
},
|
|
19
20
|
defaultOptions: [],
|
|
20
21
|
create(context) {
|
|
21
|
-
const { importDeclarationListener, detectZodSchemaRootNode, } =
|
|
22
|
+
const { importDeclarationListener, detectZodSchemaRootNode, } = trackZodSchemaImports();
|
|
22
23
|
return {
|
|
23
24
|
ImportDeclaration: importDeclarationListener,
|
|
24
25
|
CallExpression(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noUnknownSchema: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"noZUnknown", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const noUnknownSchema: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noZUnknown", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const noUnknownSchema =
|
|
1
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
2
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
3
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('all');
|
|
4
|
+
export const noUnknownSchema = createZodPluginRule({
|
|
5
5
|
name: 'no-unknown-schema',
|
|
6
6
|
meta: {
|
|
7
7
|
type: 'suggestion',
|
|
8
8
|
docs: {
|
|
9
|
+
zodImportAllowedSource,
|
|
9
10
|
description: 'Disallow usage of `z.unknown()` in Zod schemas',
|
|
10
11
|
},
|
|
11
12
|
messages: {
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.preferEnumOverLiteralUnion = void 0;
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
const
|
|
5
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
6
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
7
|
-
|
|
7
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
|
|
8
|
+
exports.preferEnumOverLiteralUnion = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
8
9
|
name: 'prefer-enum-over-literal-union',
|
|
9
10
|
meta: {
|
|
10
11
|
type: 'suggestion',
|
|
11
12
|
fixable: 'code',
|
|
12
13
|
docs: {
|
|
14
|
+
zodImportAllowedSource,
|
|
13
15
|
description: 'Prefer `z.enum()` over `z.union()` when all members are string literals.',
|
|
14
16
|
},
|
|
15
17
|
messages: {
|
|
@@ -19,7 +21,7 @@ exports.preferEnumOverLiteralUnion = utils_1.ESLintUtils.RuleCreator(meta_js_1.g
|
|
|
19
21
|
},
|
|
20
22
|
defaultOptions: [],
|
|
21
23
|
create(context) {
|
|
22
|
-
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } =
|
|
24
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
23
25
|
return {
|
|
24
26
|
ImportDeclaration: importDeclarationListener,
|
|
25
27
|
CallExpression(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const preferEnumOverLiteralUnion: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"useEnum", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const preferEnumOverLiteralUnion: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useEnum", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { AST_NODE_TYPES
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
3
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
4
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
|
|
5
|
+
export const preferEnumOverLiteralUnion = createZodPluginRule({
|
|
5
6
|
name: 'prefer-enum-over-literal-union',
|
|
6
7
|
meta: {
|
|
7
8
|
type: 'suggestion',
|
|
8
9
|
fixable: 'code',
|
|
9
10
|
docs: {
|
|
11
|
+
zodImportAllowedSource,
|
|
10
12
|
description: 'Prefer `z.enum()` over `z.union()` when all members are string literals.',
|
|
11
13
|
},
|
|
12
14
|
messages: {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.preferMetaLast = void 0;
|
|
4
|
-
const
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
4
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
5
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
7
|
-
|
|
6
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
|
|
7
|
+
exports.preferMetaLast = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
8
8
|
name: 'prefer-meta-last',
|
|
9
9
|
meta: {
|
|
10
10
|
type: 'suggestion',
|
|
11
|
-
docs: {
|
|
11
|
+
docs: {
|
|
12
|
+
zodImportAllowedSource,
|
|
13
|
+
description: 'Enforce `.meta()` as last method',
|
|
14
|
+
},
|
|
12
15
|
fixable: 'code',
|
|
13
16
|
messages: {
|
|
14
17
|
metaNotLast: 'The `.meta()` methods should be the last one called',
|
|
@@ -17,7 +20,7 @@ exports.preferMetaLast = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
|
|
|
17
20
|
},
|
|
18
21
|
defaultOptions: [],
|
|
19
22
|
create(context) {
|
|
20
|
-
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } =
|
|
23
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
21
24
|
return {
|
|
22
25
|
ImportDeclaration: importDeclarationListener,
|
|
23
26
|
CallExpression(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const preferMetaLast: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"metaNotLast", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const preferMetaLast: import("@typescript-eslint/utils/ts-eslint").RuleModule<"metaNotLast", [], {
|
|
2
|
+
zodImportAllowedSource: "all" | "zod" | "zod-mini";
|
|
3
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const preferMetaLast =
|
|
1
|
+
import { createZodPluginRule } from "../utils/create-plugin-rule.js";
|
|
2
|
+
import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
|
|
3
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
|
|
4
|
+
export const preferMetaLast = createZodPluginRule({
|
|
5
5
|
name: 'prefer-meta-last',
|
|
6
6
|
meta: {
|
|
7
7
|
type: 'suggestion',
|
|
8
|
-
docs: {
|
|
8
|
+
docs: {
|
|
9
|
+
zodImportAllowedSource,
|
|
10
|
+
description: 'Enforce `.meta()` as last method',
|
|
11
|
+
},
|
|
9
12
|
fixable: 'code',
|
|
10
13
|
messages: {
|
|
11
14
|
metaNotLast: 'The `.meta()` methods should be the last one called',
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.preferMeta = void 0;
|
|
4
|
-
const
|
|
5
|
-
const meta_js_1 = require("../meta.cjs");
|
|
4
|
+
const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
|
|
6
5
|
const track_zod_schema_imports_js_1 = require("../utils/track-zod-schema-imports.cjs");
|
|
7
|
-
|
|
6
|
+
const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('all');
|
|
7
|
+
exports.preferMeta = (0, create_plugin_rule_js_1.createZodPluginRule)({
|
|
8
8
|
name: 'prefer-meta',
|
|
9
9
|
meta: {
|
|
10
10
|
type: 'suggestion',
|
|
11
11
|
fixable: 'code',
|
|
12
12
|
docs: {
|
|
13
|
+
zodImportAllowedSource,
|
|
13
14
|
description: 'Enforce usage of `.meta()` over `.describe()`',
|
|
14
15
|
},
|
|
15
16
|
messages: {
|
|
@@ -19,7 +20,7 @@ exports.preferMeta = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
|
|
|
19
20
|
},
|
|
20
21
|
defaultOptions: [],
|
|
21
22
|
create(context) {
|
|
22
|
-
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } =
|
|
23
|
+
const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
|
|
23
24
|
return {
|
|
24
25
|
ImportDeclaration: importDeclarationListener,
|
|
25
26
|
CallExpression(node) {
|