eslint-plugin-zod 3.3.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.
Files changed (98) hide show
  1. package/README.md +33 -22
  2. package/dist/index.cjs +12 -4
  3. package/dist/index.d.cts +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +12 -4
  6. package/dist/rules/array-style.cjs +5 -4
  7. package/dist/rules/array-style.d.cts +3 -2
  8. package/dist/rules/array-style.d.ts +3 -2
  9. package/dist/rules/array-style.js +5 -4
  10. package/dist/rules/consistent-import-source.cjs +5 -11
  11. package/dist/rules/consistent-import-source.d.cts +4 -3
  12. package/dist/rules/consistent-import-source.d.ts +4 -3
  13. package/dist/rules/consistent-import-source.js +4 -10
  14. package/dist/rules/consistent-import.cjs +4 -3
  15. package/dist/rules/consistent-import.d.cts +3 -2
  16. package/dist/rules/consistent-import.d.ts +3 -2
  17. package/dist/rules/consistent-import.js +5 -4
  18. package/dist/rules/consistent-object-schema-type.cjs +5 -3
  19. package/dist/rules/consistent-object-schema-type.d.cts +3 -1
  20. package/dist/rules/consistent-object-schema-type.d.ts +3 -1
  21. package/dist/rules/consistent-object-schema-type.js +6 -4
  22. package/dist/rules/no-any-schema.cjs +5 -3
  23. package/dist/rules/no-any-schema.d.cts +3 -1
  24. package/dist/rules/no-any-schema.d.ts +3 -1
  25. package/dist/rules/no-any-schema.js +6 -4
  26. package/dist/rules/no-empty-custom-schema.cjs +5 -4
  27. package/dist/rules/no-empty-custom-schema.d.cts +3 -2
  28. package/dist/rules/no-empty-custom-schema.d.ts +3 -2
  29. package/dist/rules/no-empty-custom-schema.js +5 -4
  30. package/dist/rules/no-number-schema-with-int.cjs +5 -4
  31. package/dist/rules/no-number-schema-with-int.d.cts +3 -2
  32. package/dist/rules/no-number-schema-with-int.d.ts +3 -2
  33. package/dist/rules/no-number-schema-with-int.js +5 -4
  34. package/dist/rules/no-optional-and-default-together.cjs +5 -4
  35. package/dist/rules/no-optional-and-default-together.d.cts +3 -2
  36. package/dist/rules/no-optional-and-default-together.d.ts +3 -2
  37. package/dist/rules/no-optional-and-default-together.js +5 -4
  38. package/dist/rules/no-string-schema-with-uuid.cjs +5 -4
  39. package/dist/rules/no-string-schema-with-uuid.d.cts +3 -2
  40. package/dist/rules/no-string-schema-with-uuid.d.ts +3 -2
  41. package/dist/rules/no-string-schema-with-uuid.js +5 -4
  42. package/dist/rules/no-throw-in-refine.cjs +5 -3
  43. package/dist/rules/no-throw-in-refine.d.cts +3 -2
  44. package/dist/rules/no-throw-in-refine.d.ts +3 -2
  45. package/dist/rules/no-throw-in-refine.js +6 -4
  46. package/dist/rules/no-unknown-schema.cjs +5 -4
  47. package/dist/rules/no-unknown-schema.d.cts +3 -2
  48. package/dist/rules/no-unknown-schema.d.ts +3 -2
  49. package/dist/rules/no-unknown-schema.js +5 -4
  50. package/dist/rules/prefer-enum-over-literal-union.cjs +5 -3
  51. package/dist/rules/prefer-enum-over-literal-union.d.cts +3 -2
  52. package/dist/rules/prefer-enum-over-literal-union.d.ts +3 -2
  53. package/dist/rules/prefer-enum-over-literal-union.js +6 -4
  54. package/dist/rules/prefer-meta-last.cjs +8 -5
  55. package/dist/rules/prefer-meta-last.d.cts +3 -2
  56. package/dist/rules/prefer-meta-last.d.ts +3 -2
  57. package/dist/rules/prefer-meta-last.js +8 -5
  58. package/dist/rules/prefer-meta.cjs +5 -4
  59. package/dist/rules/prefer-meta.d.cts +3 -2
  60. package/dist/rules/prefer-meta.d.ts +3 -2
  61. package/dist/rules/prefer-meta.js +5 -4
  62. package/dist/rules/prefer-namespace-import.cjs +4 -3
  63. package/dist/rules/prefer-namespace-import.d.cts +3 -2
  64. package/dist/rules/prefer-namespace-import.d.ts +3 -2
  65. package/dist/rules/prefer-namespace-import.js +5 -4
  66. package/dist/rules/prefer-string-schema-with-trim.cjs +5 -4
  67. package/dist/rules/prefer-string-schema-with-trim.d.cts +3 -2
  68. package/dist/rules/prefer-string-schema-with-trim.d.ts +3 -2
  69. package/dist/rules/prefer-string-schema-with-trim.js +5 -4
  70. package/dist/rules/require-brand-type-parameter.cjs +5 -4
  71. package/dist/rules/require-brand-type-parameter.d.cts +3 -1
  72. package/dist/rules/require-brand-type-parameter.d.ts +3 -1
  73. package/dist/rules/require-brand-type-parameter.js +5 -4
  74. package/dist/rules/require-error-message.cjs +5 -3
  75. package/dist/rules/require-error-message.d.cts +3 -2
  76. package/dist/rules/require-error-message.d.ts +3 -2
  77. package/dist/rules/require-error-message.js +6 -4
  78. package/dist/rules/require-schema-suffix.cjs +5 -3
  79. package/dist/rules/require-schema-suffix.d.cts +3 -2
  80. package/dist/rules/require-schema-suffix.d.ts +3 -2
  81. package/dist/rules/require-schema-suffix.js +6 -4
  82. package/dist/rules/schema-error-property-style.cjs +5 -3
  83. package/dist/rules/schema-error-property-style.d.cts +4 -3
  84. package/dist/rules/schema-error-property-style.d.ts +4 -3
  85. package/dist/rules/schema-error-property-style.js +6 -4
  86. package/dist/utils/create-plugin-rule.cjs +6 -0
  87. package/dist/utils/create-plugin-rule.d.cts +13 -0
  88. package/dist/utils/create-plugin-rule.d.ts +13 -0
  89. package/dist/utils/create-plugin-rule.js +3 -0
  90. package/dist/utils/is-zod-import-source.cjs +17 -2
  91. package/dist/utils/is-zod-import-source.d.cts +4 -1
  92. package/dist/utils/is-zod-import-source.d.ts +4 -1
  93. package/dist/utils/is-zod-import-source.js +16 -2
  94. package/dist/utils/track-zod-schema-imports.cjs +9 -2
  95. package/dist/utils/track-zod-schema-imports.d.cts +6 -1
  96. package/dist/utils/track-zod-schema-imports.d.ts +6 -1
  97. package/dist/utils/track-zod-schema-imports.js +8 -2
  98. package/package.json +1 -1
package/README.md CHANGED
@@ -21,36 +21,47 @@
21
21
 
22
22
  ## Rules
23
23
 
24
+ `zod` and `zod-mini` have distinct API surfaces.
25
+ This plugin is primarily built for `zod`, so some rules are exclusive to `zod` and not available for `zod-mini`.
26
+
24
27
  <!-- begin auto-generated rules list -->
25
28
 
26
29
  💼 Configurations enabled in.\
27
30
  ✅ Set in the `recommended` configuration.\
31
+ ✔️ Set in the `recommendedMini` configuration.\
28
32
  🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
29
33
  💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\
30
34
  ❌ Deprecated.
31
35
 
32
- | Name                             | Description | 💼 | 🔧 | 💡 | ❌ |
33
- | :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- |
34
- | [array-style](docs/rules/array-style.md) | Enforce consistent Zod array style | | 🔧 | | |
35
- | [consistent-import](docs/rules/consistent-import.md) | Enforce a consistent import style for Zod | | 🔧 | | |
36
- | [consistent-import-source](docs/rules/consistent-import-source.md) | Enforce consistent source from Zod imports | | | 💡 | |
37
- | [consistent-object-schema-type](docs/rules/consistent-object-schema-type.md) | Enforce consistent usage of Zod schema methods | | | 💡 | |
38
- | [no-any-schema](docs/rules/no-any-schema.md) | Disallow usage of `z.any()` in Zod schemas | | | 💡 | |
39
- | [no-empty-custom-schema](docs/rules/no-empty-custom-schema.md) | Disallow usage of `z.custom()` without arguments | ✅ | | | |
40
- | [no-number-schema-with-int](docs/rules/no-number-schema-with-int.md) | Disallow usage of `z.number().int()` as it is considered legacy | ✅ | 🔧 | | |
41
- | [no-optional-and-default-together](docs/rules/no-optional-and-default-together.md) | Disallow using both `.optional()` and `.default()` on the same Zod schema || 🔧 | | |
42
- | [no-string-schema-with-uuid](docs/rules/no-string-schema-with-uuid.md) | Disallow usage of `z.string().uuid()` in favor of the dedicated `z.uuid()` schema | ✅ | 🔧 | | |
43
- | [no-throw-in-refine](docs/rules/no-throw-in-refine.md) | Disallow throwing errors directly inside Zod refine callbacks | | | | |
44
- | [no-unknown-schema](docs/rules/no-unknown-schema.md) | Disallow usage of `z.unknown()` in Zod schemas | | | | |
45
- | [prefer-enum-over-literal-union](docs/rules/prefer-enum-over-literal-union.md) | Prefer `z.enum()` over `z.union()` when all members are string literals. | | 🔧 | | |
46
- | [prefer-meta](docs/rules/prefer-meta.md) | Enforce usage of `.meta()` over `.describe()` | ✅ | 🔧 | | |
47
- | [prefer-meta-last](docs/rules/prefer-meta-last.md) | Enforce `.meta()` as last method || 🔧 | | |
48
- | [prefer-namespace-import](docs/rules/prefer-namespace-import.md) | Enforce importing zod as a namespace import (`import * as z from 'zod'`) | | 🔧 | | ❌ |
49
- | [prefer-string-schema-with-trim](docs/rules/prefer-string-schema-with-trim.md) | Enforce `z.string().trim()` to prevent accidental leading/trailing whitespace | ✅ | 🔧 | | |
50
- | [require-brand-type-parameter](docs/rules/require-brand-type-parameter.md) | Require type parameter on `.brand()` functions | ✅ | | 💡 | |
51
- | [require-error-message](docs/rules/require-error-message.md) | Enforce that custom refinements include an error message | | 🔧 | | |
52
- | [require-schema-suffix](docs/rules/require-schema-suffix.md) | Require schema suffix when declaring a Zod schema | | | | |
53
- | [schema-error-property-style](docs/rules/schema-error-property-style.md) | Enforce consistent style for error messages in Zod schema validation (using ESQuery patterns) | | | | |
36
+ ### Universal rules (`zod` & `zod-mini`)
37
+
38
+ | Name                          | Description | 💼 | 🔧 | 💡 | |
39
+ | :--------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- | :---- | :-- | :-- | :-- |
40
+ | [consistent-import](docs/rules/consistent-import.md) | Enforce a consistent import style for Zod | | 🔧 | | |
41
+ | [consistent-import-source](docs/rules/consistent-import-source.md) | Enforce consistent source from Zod imports | | | 💡 | |
42
+ | [consistent-object-schema-type](docs/rules/consistent-object-schema-type.md) | Enforce consistent usage of Zod schema methods | | | 💡 | |
43
+ | [no-any-schema](docs/rules/no-any-schema.md) | Disallow usage of `z.any()` in Zod schemas | ✅ ✔️ | | 💡 | |
44
+ | [no-empty-custom-schema](docs/rules/no-empty-custom-schema.md) | Disallow usage of `z.custom()` without arguments | ✅ | | | |
45
+ | [no-unknown-schema](docs/rules/no-unknown-schema.md) | Disallow usage of `z.unknown()` in Zod schemas | | | | |
46
+ | [prefer-meta](docs/rules/prefer-meta.md) | Enforce usage of `.meta()` over `.describe()` | ✅ ✔️ | 🔧 | | |
47
+ | [prefer-namespace-import](docs/rules/prefer-namespace-import.md) | Enforce importing zod as a namespace import (`import * as z from 'zod'`) | | 🔧 | ||
48
+ | [require-brand-type-parameter](docs/rules/require-brand-type-parameter.md) | Require type parameter on `.brand()` functions | ✔️ | | 💡 | |
49
+ | [require-error-message](docs/rules/require-error-message.md) | Enforce that custom refinements include an error message | ✔️ | 🔧 | | |
50
+ | [require-schema-suffix](docs/rules/require-schema-suffix.md) | Require schema suffix when declaring a Zod schema | ✅ ✔️ | | | |
51
+ | [schema-error-property-style](docs/rules/schema-error-property-style.md) | Enforce consistent style for error messages in Zod schema validation (using ESQuery patterns) | | | | |
52
+
53
+ ### `zod` exclusive rules
54
+
55
+ | Name                             | Description | 💼 | 🔧 | 💡 ||
56
+ | :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- |
57
+ | [array-style](docs/rules/array-style.md) | Enforce consistent Zod array style | ✅ | 🔧 | | |
58
+ | [no-number-schema-with-int](docs/rules/no-number-schema-with-int.md) | Disallow usage of `z.number().int()` as it is considered legacy | ✅ | 🔧 | | |
59
+ | [no-optional-and-default-together](docs/rules/no-optional-and-default-together.md) | Disallow using both `.optional()` and `.default()` on the same Zod schema | ✅ | 🔧 | | |
60
+ | [no-string-schema-with-uuid](docs/rules/no-string-schema-with-uuid.md) | Disallow usage of `z.string().uuid()` in favor of the dedicated `z.uuid()` schema | ✅ | 🔧 | | |
61
+ | [no-throw-in-refine](docs/rules/no-throw-in-refine.md) | Disallow throwing errors directly inside Zod refine callbacks | ✅ | | | |
62
+ | [prefer-enum-over-literal-union](docs/rules/prefer-enum-over-literal-union.md) | Prefer `z.enum()` over `z.union()` when all members are string literals. | ✅ | 🔧 | | |
63
+ | [prefer-meta-last](docs/rules/prefer-meta-last.md) | Enforce `.meta()` as last method | ✅ | 🔧 | | |
64
+ | [prefer-string-schema-with-trim](docs/rules/prefer-string-schema-with-trim.md) | Enforce `z.string().trim()` to prevent accidental leading/trailing whitespace | ✅ | 🔧 | | |
54
65
 
55
66
  <!-- end auto-generated rules list -->
56
67
 
package/dist/index.cjs CHANGED
@@ -49,13 +49,14 @@ const eslintPluginZod = {
49
49
  'schema-error-property-style': schema_error_property_style_js_1.schemaErrorPropertyStyle,
50
50
  },
51
51
  };
52
- const recommendedConfig = {
52
+ const baseConfig = {
53
53
  name: `${meta_js_1.PLUGIN_NAME}/recommended`,
54
54
  files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
55
55
  plugins: {
56
56
  zod: eslintPluginZod,
57
57
  },
58
- rules: {
58
+ };
59
+ const recommendedConfig = Object.assign(Object.assign({}, baseConfig), { rules: {
59
60
  'zod/array-style': 'error',
60
61
  'zod/consistent-import': 'error',
61
62
  'zod/no-any-schema': 'error',
@@ -71,9 +72,16 @@ const recommendedConfig = {
71
72
  'zod/require-brand-type-parameter': 'error',
72
73
  'zod/require-error-message': 'error',
73
74
  'zod/require-schema-suffix': 'error',
74
- },
75
- };
75
+ } });
76
+ const recommendedConfigMini = Object.assign(Object.assign({}, baseConfig), { rules: {
77
+ 'zod/no-any-schema': 'error',
78
+ 'zod/prefer-meta': 'error',
79
+ 'zod/require-brand-type-parameter': 'error',
80
+ 'zod/require-error-message': 'error',
81
+ 'zod/require-schema-suffix': 'error',
82
+ } });
76
83
  exports.default = Object.assign(Object.assign({}, eslintPluginZod), { configs: {
77
84
  recommended: recommendedConfig,
85
+ recommendedMini: recommendedConfigMini,
78
86
  } });
79
87
  module.exports = exports.default;
package/dist/index.d.cts CHANGED
@@ -12,6 +12,7 @@ interface CompatiblePlugin {
12
12
  declare const _default: {
13
13
  configs: {
14
14
  recommended: CompatibleConfig;
15
+ recommendedMini: CompatibleConfig;
15
16
  };
16
17
  meta: {
17
18
  name: string;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ interface CompatiblePlugin {
12
12
  declare const _default: {
13
13
  configs: {
14
14
  recommended: CompatibleConfig;
15
+ recommendedMini: CompatibleConfig;
15
16
  };
16
17
  meta: {
17
18
  name: string;
package/dist/index.js CHANGED
@@ -47,13 +47,14 @@ const eslintPluginZod = {
47
47
  'schema-error-property-style': schemaErrorPropertyStyle,
48
48
  },
49
49
  };
50
- const recommendedConfig = {
50
+ const baseConfig = {
51
51
  name: `${PLUGIN_NAME}/recommended`,
52
52
  files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
53
53
  plugins: {
54
54
  zod: eslintPluginZod,
55
55
  },
56
- rules: {
56
+ };
57
+ const recommendedConfig = Object.assign(Object.assign({}, baseConfig), { rules: {
57
58
  'zod/array-style': 'error',
58
59
  'zod/consistent-import': 'error',
59
60
  'zod/no-any-schema': 'error',
@@ -69,8 +70,15 @@ const recommendedConfig = {
69
70
  'zod/require-brand-type-parameter': 'error',
70
71
  'zod/require-error-message': 'error',
71
72
  'zod/require-schema-suffix': 'error',
72
- },
73
- };
73
+ } });
74
+ const recommendedConfigMini = Object.assign(Object.assign({}, baseConfig), { rules: {
75
+ 'zod/no-any-schema': 'error',
76
+ 'zod/prefer-meta': 'error',
77
+ 'zod/require-brand-type-parameter': 'error',
78
+ 'zod/require-error-message': 'error',
79
+ 'zod/require-schema-suffix': 'error',
80
+ } });
74
81
  export default Object.assign(Object.assign({}, eslintPluginZod), { configs: {
75
82
  recommended: recommendedConfig,
83
+ recommendedMini: recommendedConfigMini,
76
84
  } });
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.arrayStyle = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
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 ZOD_ARRAY_STYLES = ['function', 'method'];
8
7
  const defaultOptions = { style: 'function' };
9
- exports.arrayStyle = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
8
+ const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('zod');
9
+ exports.arrayStyle = (0, create_plugin_rule_js_1.createZodPluginRule)({
10
10
  name: 'array-style',
11
11
  meta: {
12
12
  type: 'suggestion',
13
13
  fixable: 'code',
14
14
  docs: {
15
+ zodImportAllowedSource,
15
16
  description: 'Enforce consistent Zod array style',
16
17
  },
17
18
  messages: {
@@ -35,7 +36,7 @@ exports.arrayStyle = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
35
36
  defaultOptions: [defaultOptions],
36
37
  create(context, [{ style }]) {
37
38
  const { sourceCode } = context;
38
- const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = (0, track_zod_schema_imports_js_1.trackZodSchemaImports)();
39
+ const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
39
40
  return {
40
41
  ImportDeclaration: importDeclarationListener,
41
42
  CallExpression(node) {
@@ -1,10 +1,11 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
1
  declare const ZOD_ARRAY_STYLES: string[];
3
2
  interface Options {
4
3
  style: (typeof ZOD_ARRAY_STYLES)[number];
5
4
  }
6
5
  type MessageIds = 'useFunction' | 'useMethod';
7
- export declare const arrayStyle: ESLintUtils.RuleModule<MessageIds, [Options], unknown, ESLintUtils.RuleListener> & {
6
+ export declare const arrayStyle: import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<MessageIds, [Options], {
7
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
8
+ }, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener> & {
8
9
  name: string;
9
10
  };
10
11
  export {};
@@ -1,10 +1,11 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
1
  declare const ZOD_ARRAY_STYLES: string[];
3
2
  interface Options {
4
3
  style: (typeof ZOD_ARRAY_STYLES)[number];
5
4
  }
6
5
  type MessageIds = 'useFunction' | 'useMethod';
7
- export declare const arrayStyle: ESLintUtils.RuleModule<MessageIds, [Options], unknown, ESLintUtils.RuleListener> & {
6
+ export declare const arrayStyle: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, [Options], {
7
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
8
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
8
9
  name: string;
9
10
  };
10
11
  export {};
@@ -1,14 +1,15 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- import { getRuleURL } from "../meta.js";
3
- import { trackZodSchemaImports } from "../utils/track-zod-schema-imports.js";
1
+ import { createZodPluginRule } from "../utils/create-plugin-rule.js";
2
+ import { createZodSchemaImportTrack } from "../utils/track-zod-schema-imports.js";
4
3
  const ZOD_ARRAY_STYLES = ['function', 'method'];
5
4
  const defaultOptions = { style: 'function' };
6
- export const arrayStyle = ESLintUtils.RuleCreator(getRuleURL)({
5
+ const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('zod');
6
+ export const arrayStyle = createZodPluginRule({
7
7
  name: 'array-style',
8
8
  meta: {
9
9
  type: 'suggestion',
10
10
  fixable: 'code',
11
11
  docs: {
12
+ zodImportAllowedSource,
12
13
  description: 'Enforce consistent Zod array style',
13
14
  },
14
15
  messages: {
@@ -1,21 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.consistentImportSource = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
- const meta_js_1 = require("../meta.cjs");
6
- const ZOD_IMPORT_SOURCES = [
7
- 'zod',
8
- 'zod/mini',
9
- 'zod/v4',
10
- 'zod/v4-mini',
11
- 'zod/v3',
12
- ];
13
- exports.consistentImportSource = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
4
+ const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
5
+ const is_zod_import_source_js_1 = require("../utils/is-zod-import-source.cjs");
6
+ exports.consistentImportSource = (0, create_plugin_rule_js_1.createZodPluginRule)({
14
7
  name: 'consistent-import-source',
15
8
  meta: {
16
9
  hasSuggestions: true,
17
10
  type: 'suggestion',
18
11
  docs: {
12
+ zodImportAllowedSource: 'all',
19
13
  description: 'Enforce consistent source from Zod imports',
20
14
  },
21
15
  messages: {
@@ -31,7 +25,7 @@ exports.consistentImportSource = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRu
31
25
  description: 'An array of allowed Zod import sources.',
32
26
  items: {
33
27
  type: 'string',
34
- enum: [...ZOD_IMPORT_SOURCES],
28
+ enum: [...is_zod_import_source_js_1.ZOD_IMPORT_SOURCES],
35
29
  },
36
30
  minItems: 1,
37
31
  uniqueItems: true,
@@ -1,10 +1,11 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- declare const ZOD_IMPORT_SOURCES: readonly ["zod", "zod/mini", "zod/v4", "zod/v4-mini", "zod/v3"];
3
- type ZodImportSource = (typeof ZOD_IMPORT_SOURCES)[number];
2
+ import type { ZodImportSource } from "../utils/is-zod-import-source.cjs";
4
3
  type MessageIds = 'sourceNotAllowed' | 'replaceSource';
5
4
  export declare const consistentImportSource: TSESLint.RuleModule<MessageIds, [{
6
5
  sources: Array<ZodImportSource>;
7
- }], unknown, TSESLint.RuleListener> & {
6
+ }], {
7
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
8
+ }, TSESLint.RuleListener> & {
8
9
  name: string;
9
10
  };
10
11
  export {};
@@ -1,10 +1,11 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- declare const ZOD_IMPORT_SOURCES: readonly ["zod", "zod/mini", "zod/v4", "zod/v4-mini", "zod/v3"];
3
- type ZodImportSource = (typeof ZOD_IMPORT_SOURCES)[number];
2
+ import type { ZodImportSource } from "../utils/is-zod-import-source.js";
4
3
  type MessageIds = 'sourceNotAllowed' | 'replaceSource';
5
4
  export declare const consistentImportSource: TSESLint.RuleModule<MessageIds, [{
6
5
  sources: Array<ZodImportSource>;
7
- }], unknown, TSESLint.RuleListener> & {
6
+ }], {
7
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
8
+ }, TSESLint.RuleListener> & {
8
9
  name: string;
9
10
  };
10
11
  export {};
@@ -1,18 +1,12 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- import { getRuleURL } from "../meta.js";
3
- const ZOD_IMPORT_SOURCES = [
4
- 'zod',
5
- 'zod/mini',
6
- 'zod/v4',
7
- 'zod/v4-mini',
8
- 'zod/v3',
9
- ];
10
- export const consistentImportSource = ESLintUtils.RuleCreator(getRuleURL)({
1
+ import { createZodPluginRule } from "../utils/create-plugin-rule.js";
2
+ import { ZOD_IMPORT_SOURCES } from "../utils/is-zod-import-source.js";
3
+ export const consistentImportSource = createZodPluginRule({
11
4
  name: 'consistent-import-source',
12
5
  meta: {
13
6
  hasSuggestions: true,
14
7
  type: 'suggestion',
15
8
  docs: {
9
+ zodImportAllowedSource: 'all',
16
10
  description: 'Enforce consistent source from Zod imports',
17
11
  },
18
12
  messages: {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.consistentImport = void 0;
4
4
  const utils_1 = require("@typescript-eslint/utils");
5
- const meta_js_1 = require("../meta.cjs");
5
+ const create_plugin_rule_js_1 = require("../utils/create-plugin-rule.cjs");
6
6
  const is_zod_import_source_js_1 = require("../utils/is-zod-import-source.cjs");
7
7
  const IMPORT_SYNTAXES = ['namespace', 'named'];
8
8
  function isGroupFirstImportKindValidForSyntax(group, syntax) {
@@ -48,11 +48,12 @@ function getNamespaceAliasNameFrom(node) {
48
48
  }
49
49
  return null;
50
50
  }
51
- exports.consistentImport = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
51
+ exports.consistentImport = (0, create_plugin_rule_js_1.createZodPluginRule)({
52
52
  name: 'consistent-import',
53
53
  meta: {
54
54
  type: 'problem',
55
55
  docs: {
56
+ zodImportAllowedSource: 'all',
56
57
  description: 'Enforce a consistent import style for Zod',
57
58
  },
58
59
  fixable: 'code',
@@ -83,7 +84,7 @@ exports.consistentImport = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)
83
84
  return {
84
85
  ImportDeclaration(node) {
85
86
  const { source, importKind } = node;
86
- if (!(0, is_zod_import_source_js_1.isZodImportSource)(source.value)) {
87
+ if (!(0, is_zod_import_source_js_1.isZodImportSource)(source.value, 'all')) {
87
88
  return;
88
89
  }
89
90
  if (!importGroups[source.value]) {
@@ -1,11 +1,12 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
1
  declare const IMPORT_SYNTAXES: readonly ["namespace", "named"];
3
2
  type ImportSyntax = (typeof IMPORT_SYNTAXES)[number];
4
3
  interface Options {
5
4
  syntax: ImportSyntax;
6
5
  }
7
6
  type MessageIds = 'changeImportSyntax' | 'removeDuplicate' | 'convertUsage';
8
- export declare const consistentImport: ESLintUtils.RuleModule<MessageIds, [Options], unknown, ESLintUtils.RuleListener> & {
7
+ export declare const consistentImport: 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 IMPORT_SYNTAXES: readonly ["namespace", "named"];
3
2
  type ImportSyntax = (typeof IMPORT_SYNTAXES)[number];
4
3
  interface Options {
5
4
  syntax: ImportSyntax;
6
5
  }
7
6
  type MessageIds = 'changeImportSyntax' | 'removeDuplicate' | 'convertUsage';
8
- export declare const consistentImport: ESLintUtils.RuleModule<MessageIds, [Options], unknown, ESLintUtils.RuleListener> & {
7
+ export declare const consistentImport: 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,5 +1,5 @@
1
- import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
2
- import { getRuleURL } from "../meta.js";
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/utils';
2
+ import { createZodPluginRule } from "../utils/create-plugin-rule.js";
3
3
  import { isZodImportSource } from "../utils/is-zod-import-source.js";
4
4
  const IMPORT_SYNTAXES = ['namespace', 'named'];
5
5
  function isGroupFirstImportKindValidForSyntax(group, syntax) {
@@ -45,11 +45,12 @@ function getNamespaceAliasNameFrom(node) {
45
45
  }
46
46
  return null;
47
47
  }
48
- export const consistentImport = ESLintUtils.RuleCreator(getRuleURL)({
48
+ export const consistentImport = createZodPluginRule({
49
49
  name: 'consistent-import',
50
50
  meta: {
51
51
  type: 'problem',
52
52
  docs: {
53
+ zodImportAllowedSource: 'all',
53
54
  description: 'Enforce a consistent import style for Zod',
54
55
  },
55
56
  fixable: 'code',
@@ -80,7 +81,7 @@ export const consistentImport = ESLintUtils.RuleCreator(getRuleURL)({
80
81
  return {
81
82
  ImportDeclaration(node) {
82
83
  const { source, importKind } = node;
83
- if (!isZodImportSource(source.value)) {
84
+ if (!isZodImportSource(source.value, 'all')) {
84
85
  return;
85
86
  }
86
87
  if (!importGroups[source.value]) {
@@ -2,16 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.consistentObjectSchemaType = void 0;
4
4
  const utils_1 = require("@typescript-eslint/utils");
5
- const meta_js_1 = require("../meta.cjs");
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 ZOD_OBJECT_METHODS = ['object', 'looseObject', 'strictObject'];
8
8
  const defaultOptions = { allow: ['object'] };
9
- exports.consistentObjectSchemaType = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
9
+ const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('all');
10
+ exports.consistentObjectSchemaType = (0, create_plugin_rule_js_1.createZodPluginRule)({
10
11
  name: 'consistent-object-schema-type',
11
12
  meta: {
12
13
  hasSuggestions: true,
13
14
  type: 'suggestion',
14
15
  docs: {
16
+ zodImportAllowedSource,
15
17
  description: 'Enforce consistent usage of Zod schema methods',
16
18
  },
17
19
  messages: {
@@ -39,7 +41,7 @@ exports.consistentObjectSchemaType = utils_1.ESLintUtils.RuleCreator(meta_js_1.g
39
41
  },
40
42
  defaultOptions: [defaultOptions],
41
43
  create(context, [{ allow: allowedList }]) {
42
- const { importDeclarationListener, detectZodSchemaRootNode, } = (0, track_zod_schema_imports_js_1.trackZodSchemaImports)();
44
+ const { importDeclarationListener, detectZodSchemaRootNode, } = trackZodSchemaImports();
43
45
  return {
44
46
  ImportDeclaration: importDeclarationListener,
45
47
  CallExpression(node) {
@@ -5,7 +5,9 @@ interface Options {
5
5
  allow: Array<ZodObjectMethod>;
6
6
  }
7
7
  type MessageIds = 'consistentMethod' | 'useMethod';
8
- export declare const consistentObjectSchemaType: TSESLint.RuleModule<MessageIds, [Options], unknown, TSESLint.RuleListener> & {
8
+ export declare const consistentObjectSchemaType: TSESLint.RuleModule<MessageIds, [Options], {
9
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
10
+ }, TSESLint.RuleListener> & {
9
11
  name: string;
10
12
  };
11
13
  export {};
@@ -5,7 +5,9 @@ interface Options {
5
5
  allow: Array<ZodObjectMethod>;
6
6
  }
7
7
  type MessageIds = 'consistentMethod' | 'useMethod';
8
- export declare const consistentObjectSchemaType: TSESLint.RuleModule<MessageIds, [Options], unknown, TSESLint.RuleListener> & {
8
+ export declare const consistentObjectSchemaType: TSESLint.RuleModule<MessageIds, [Options], {
9
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
10
+ }, TSESLint.RuleListener> & {
9
11
  name: string;
10
12
  };
11
13
  export {};
@@ -1,14 +1,16 @@
1
- import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
2
- import { getRuleURL } from "../meta.js";
3
- import { trackZodSchemaImports } from "../utils/track-zod-schema-imports.js";
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
4
  const ZOD_OBJECT_METHODS = ['object', 'looseObject', 'strictObject'];
5
5
  const defaultOptions = { allow: ['object'] };
6
- export const consistentObjectSchemaType = ESLintUtils.RuleCreator(getRuleURL)({
6
+ const { zodImportAllowedSource, trackZodSchemaImports, } = createZodSchemaImportTrack('all');
7
+ export const consistentObjectSchemaType = createZodPluginRule({
7
8
  name: 'consistent-object-schema-type',
8
9
  meta: {
9
10
  hasSuggestions: true,
10
11
  type: 'suggestion',
11
12
  docs: {
13
+ zodImportAllowedSource,
12
14
  description: 'Enforce consistent usage of Zod schema methods',
13
15
  },
14
16
  messages: {
@@ -2,14 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noAnySchema = void 0;
4
4
  const utils_1 = require("@typescript-eslint/utils");
5
- const meta_js_1 = require("../meta.cjs");
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
- exports.noAnySchema = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
7
+ const { zodImportAllowedSource, trackZodSchemaImports, } = (0, track_zod_schema_imports_js_1.createZodSchemaImportTrack)('all');
8
+ exports.noAnySchema = (0, create_plugin_rule_js_1.createZodPluginRule)({
8
9
  name: 'no-any-schema',
9
10
  meta: {
10
11
  hasSuggestions: true,
11
12
  type: 'suggestion',
12
13
  docs: {
14
+ zodImportAllowedSource,
13
15
  description: 'Disallow usage of `z.any()` in Zod schemas',
14
16
  },
15
17
  messages: {
@@ -20,7 +22,7 @@ exports.noAnySchema = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
20
22
  },
21
23
  defaultOptions: [],
22
24
  create(context) {
23
- const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = (0, track_zod_schema_imports_js_1.trackZodSchemaImports)();
25
+ const { importDeclarationListener, detectZodSchemaRootNode, collectZodChainMethods, } = trackZodSchemaImports();
24
26
  return {
25
27
  ImportDeclaration: importDeclarationListener,
26
28
  CallExpression(node) {
@@ -1,4 +1,6 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- export declare const noAnySchema: TSESLint.RuleModule<"noZAny" | "useUnknown", [], unknown, TSESLint.RuleListener> & {
2
+ export declare const noAnySchema: TSESLint.RuleModule<"noZAny" | "useUnknown", [], {
3
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
4
+ }, TSESLint.RuleListener> & {
3
5
  name: string;
4
6
  };
@@ -1,4 +1,6 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- export declare const noAnySchema: TSESLint.RuleModule<"noZAny" | "useUnknown", [], unknown, TSESLint.RuleListener> & {
2
+ export declare const noAnySchema: TSESLint.RuleModule<"noZAny" | "useUnknown", [], {
3
+ zodImportAllowedSource: "all" | "zod" | "zod-mini";
4
+ }, TSESLint.RuleListener> & {
3
5
  name: string;
4
6
  };
@@ -1,12 +1,14 @@
1
- import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
2
- import { getRuleURL } from "../meta.js";
3
- import { trackZodSchemaImports } from "../utils/track-zod-schema-imports.js";
4
- export const noAnySchema = ESLintUtils.RuleCreator(getRuleURL)({
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('all');
5
+ export const noAnySchema = createZodPluginRule({
5
6
  name: 'no-any-schema',
6
7
  meta: {
7
8
  hasSuggestions: true,
8
9
  type: 'suggestion',
9
10
  docs: {
11
+ zodImportAllowedSource,
10
12
  description: 'Disallow usage of `z.any()` in Zod schemas',
11
13
  },
12
14
  messages: {
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noEmptyCustomSchema = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
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
- exports.noEmptyCustomSchema = utils_1.ESLintUtils.RuleCreator(meta_js_1.getRuleURL)({
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, } = (0, track_zod_schema_imports_js_1.trackZodSchemaImports)();
23
+ const { importDeclarationListener, detectZodSchemaRootNode, } = trackZodSchemaImports();
23
24
  return {
24
25
  ImportDeclaration: importDeclarationListener,
25
26
  CallExpression(node) {