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,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZOD_IMPORT_SOURCES = void 0;
|
|
3
4
|
exports.isZodImportSource = isZodImportSource;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
exports.ZOD_IMPORT_SOURCES = [
|
|
6
|
+
'zod',
|
|
7
|
+
'zod/mini',
|
|
8
|
+
'zod/v4',
|
|
9
|
+
'zod/v4-mini',
|
|
10
|
+
'zod/v3',
|
|
11
|
+
];
|
|
12
|
+
function isZodImportSource(source, allowedSource) {
|
|
13
|
+
const allowedSources = [];
|
|
14
|
+
if (allowedSource === 'all' || allowedSource === 'zod') {
|
|
15
|
+
allowedSources.push('zod', 'zod/v4', 'zod/v3');
|
|
16
|
+
}
|
|
17
|
+
if (allowedSource === 'all' || allowedSource === 'zod-mini') {
|
|
18
|
+
allowedSources.push('zod/mini', 'zod/v4-mini');
|
|
19
|
+
}
|
|
20
|
+
return allowedSources.includes(source);
|
|
6
21
|
}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ZodImportAllowedSource = 'all' | 'zod' | 'zod-mini';
|
|
2
|
+
export declare const ZOD_IMPORT_SOURCES: readonly ["zod", "zod/mini", "zod/v4", "zod/v4-mini", "zod/v3"];
|
|
3
|
+
export type ZodImportSource = (typeof ZOD_IMPORT_SOURCES)[number];
|
|
4
|
+
export declare function isZodImportSource(source: string, allowedSource: ZodImportAllowedSource): boolean;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ZodImportAllowedSource = 'all' | 'zod' | 'zod-mini';
|
|
2
|
+
export declare const ZOD_IMPORT_SOURCES: readonly ["zod", "zod/mini", "zod/v4", "zod/v4-mini", "zod/v3"];
|
|
3
|
+
export type ZodImportSource = (typeof ZOD_IMPORT_SOURCES)[number];
|
|
4
|
+
export declare function isZodImportSource(source: string, allowedSource: ZodImportAllowedSource): boolean;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export const ZOD_IMPORT_SOURCES = [
|
|
2
|
+
'zod',
|
|
3
|
+
'zod/mini',
|
|
4
|
+
'zod/v4',
|
|
5
|
+
'zod/v4-mini',
|
|
6
|
+
'zod/v3',
|
|
7
|
+
];
|
|
8
|
+
export function isZodImportSource(source, allowedSource) {
|
|
9
|
+
const allowedSources = [];
|
|
10
|
+
if (allowedSource === 'all' || allowedSource === 'zod') {
|
|
11
|
+
allowedSources.push('zod', 'zod/v4', 'zod/v3');
|
|
12
|
+
}
|
|
13
|
+
if (allowedSource === 'all' || allowedSource === 'zod-mini') {
|
|
14
|
+
allowedSources.push('zod/mini', 'zod/v4-mini');
|
|
15
|
+
}
|
|
16
|
+
return allowedSources.includes(source);
|
|
3
17
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.trackZodSchemaImports = trackZodSchemaImports;
|
|
4
|
+
exports.createZodSchemaImportTrack = createZodSchemaImportTrack;
|
|
4
5
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
6
|
const detect_zod_schema_root_node_js_1 = require("./detect-zod-schema-root-node.cjs");
|
|
6
7
|
const is_zod_import_source_js_1 = require("./is-zod-import-source.cjs");
|
|
7
|
-
function trackZodSchemaImports() {
|
|
8
|
+
function trackZodSchemaImports(importAllowedSource) {
|
|
8
9
|
const zodNamespaces = new Set();
|
|
9
10
|
const zodNamedImports = new Set();
|
|
10
11
|
function collectZodChainMethods(node) {
|
|
@@ -34,7 +35,7 @@ function trackZodSchemaImports() {
|
|
|
34
35
|
}
|
|
35
36
|
const result = {
|
|
36
37
|
importDeclarationListener(node) {
|
|
37
|
-
if (!(0, is_zod_import_source_js_1.isZodImportSource)(node.source.value)) {
|
|
38
|
+
if (!(0, is_zod_import_source_js_1.isZodImportSource)(node.source.value, importAllowedSource)) {
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
for (const spec of node.specifiers) {
|
|
@@ -59,3 +60,9 @@ function trackZodSchemaImports() {
|
|
|
59
60
|
};
|
|
60
61
|
return result;
|
|
61
62
|
}
|
|
63
|
+
function createZodSchemaImportTrack(zodImportAllowedSource) {
|
|
64
|
+
return {
|
|
65
|
+
zodImportAllowedSource,
|
|
66
|
+
trackZodSchemaImports: () => trackZodSchemaImports(zodImportAllowedSource),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
import type { DetectResult } from "./detect-zod-schema-root-node.cjs";
|
|
3
|
+
import type { ZodImportAllowedSource } from "./is-zod-import-source.cjs";
|
|
3
4
|
interface ZodChainItem {
|
|
4
5
|
name: string;
|
|
5
6
|
node: TSESTree.CallExpression;
|
|
@@ -9,5 +10,9 @@ interface Result {
|
|
|
9
10
|
detectZodSchemaRootNode: (node: TSESTree.Node) => null | DetectResult;
|
|
10
11
|
collectZodChainMethods: (node: TSESTree.CallExpression) => Array<ZodChainItem>;
|
|
11
12
|
}
|
|
12
|
-
export declare function trackZodSchemaImports(): Result;
|
|
13
|
+
export declare function trackZodSchemaImports(importAllowedSource: ZodImportAllowedSource): Result;
|
|
14
|
+
export declare function createZodSchemaImportTrack(zodImportAllowedSource: ZodImportAllowedSource): {
|
|
15
|
+
zodImportAllowedSource: ZodImportAllowedSource;
|
|
16
|
+
trackZodSchemaImports: () => ReturnType<typeof trackZodSchemaImports>;
|
|
17
|
+
};
|
|
13
18
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
import type { DetectResult } from "./detect-zod-schema-root-node.js";
|
|
3
|
+
import type { ZodImportAllowedSource } from "./is-zod-import-source.js";
|
|
3
4
|
interface ZodChainItem {
|
|
4
5
|
name: string;
|
|
5
6
|
node: TSESTree.CallExpression;
|
|
@@ -9,5 +10,9 @@ interface Result {
|
|
|
9
10
|
detectZodSchemaRootNode: (node: TSESTree.Node) => null | DetectResult;
|
|
10
11
|
collectZodChainMethods: (node: TSESTree.CallExpression) => Array<ZodChainItem>;
|
|
11
12
|
}
|
|
12
|
-
export declare function trackZodSchemaImports(): Result;
|
|
13
|
+
export declare function trackZodSchemaImports(importAllowedSource: ZodImportAllowedSource): Result;
|
|
14
|
+
export declare function createZodSchemaImportTrack(zodImportAllowedSource: ZodImportAllowedSource): {
|
|
15
|
+
zodImportAllowedSource: ZodImportAllowedSource;
|
|
16
|
+
trackZodSchemaImports: () => ReturnType<typeof trackZodSchemaImports>;
|
|
17
|
+
};
|
|
13
18
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
2
|
import { detectZodSchemaRootNode } from "./detect-zod-schema-root-node.js";
|
|
3
3
|
import { isZodImportSource } from "./is-zod-import-source.js";
|
|
4
|
-
export function trackZodSchemaImports() {
|
|
4
|
+
export function trackZodSchemaImports(importAllowedSource) {
|
|
5
5
|
const zodNamespaces = new Set();
|
|
6
6
|
const zodNamedImports = new Set();
|
|
7
7
|
function collectZodChainMethods(node) {
|
|
@@ -31,7 +31,7 @@ export function trackZodSchemaImports() {
|
|
|
31
31
|
}
|
|
32
32
|
const result = {
|
|
33
33
|
importDeclarationListener(node) {
|
|
34
|
-
if (!isZodImportSource(node.source.value)) {
|
|
34
|
+
if (!isZodImportSource(node.source.value, importAllowedSource)) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
for (const spec of node.specifiers) {
|
|
@@ -56,3 +56,9 @@ export function trackZodSchemaImports() {
|
|
|
56
56
|
};
|
|
57
57
|
return result;
|
|
58
58
|
}
|
|
59
|
+
export function createZodSchemaImportTrack(zodImportAllowedSource) {
|
|
60
|
+
return {
|
|
61
|
+
zodImportAllowedSource,
|
|
62
|
+
trackZodSchemaImports: () => trackZodSchemaImports(zodImportAllowedSource),
|
|
63
|
+
};
|
|
64
|
+
}
|