eslint-plugin-zod 3.12.1 → 4.0.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 (81) hide show
  1. package/README.md +44 -58
  2. package/package.json +8 -29
  3. package/dist/_virtual/_rolldown/runtime.cjs +0 -23
  4. package/dist/index.cjs +0 -122
  5. package/dist/index.d.cts +0 -23
  6. package/dist/index.d.mts +0 -24
  7. package/dist/index.mjs +0 -122
  8. package/dist/meta.cjs +0 -13
  9. package/dist/meta.mjs +0 -10
  10. package/dist/rules/array-style.cjs +0 -89
  11. package/dist/rules/array-style.mjs +0 -89
  12. package/dist/rules/consistent-import-source.cjs +0 -60
  13. package/dist/rules/consistent-import-source.mjs +0 -60
  14. package/dist/rules/consistent-import.cjs +0 -153
  15. package/dist/rules/consistent-import.mjs +0 -152
  16. package/dist/rules/consistent-object-schema-type.cjs +0 -82
  17. package/dist/rules/consistent-object-schema-type.mjs +0 -81
  18. package/dist/rules/consistent-schema-output-type-style.cjs +0 -70
  19. package/dist/rules/consistent-schema-output-type-style.mjs +0 -69
  20. package/dist/rules/consistent-schema-var-name.cjs +0 -76
  21. package/dist/rules/consistent-schema-var-name.mjs +0 -75
  22. package/dist/rules/no-any-schema.cjs +0 -63
  23. package/dist/rules/no-any-schema.mjs +0 -62
  24. package/dist/rules/no-empty-custom-schema.cjs +0 -35
  25. package/dist/rules/no-empty-custom-schema.mjs +0 -36
  26. package/dist/rules/no-number-schema-with-finite.cjs +0 -44
  27. package/dist/rules/no-number-schema-with-finite.mjs +0 -44
  28. package/dist/rules/no-number-schema-with-int.cjs +0 -57
  29. package/dist/rules/no-number-schema-with-int.mjs +0 -57
  30. package/dist/rules/no-number-schema-with-is-finite.cjs +0 -38
  31. package/dist/rules/no-number-schema-with-is-finite.mjs +0 -37
  32. package/dist/rules/no-number-schema-with-is-int.cjs +0 -38
  33. package/dist/rules/no-number-schema-with-is-int.mjs +0 -37
  34. package/dist/rules/no-number-schema-with-safe.cjs +0 -57
  35. package/dist/rules/no-number-schema-with-safe.mjs +0 -57
  36. package/dist/rules/no-number-schema-with-step.cjs +0 -43
  37. package/dist/rules/no-number-schema-with-step.mjs +0 -42
  38. package/dist/rules/no-optional-and-default-together.cjs +0 -70
  39. package/dist/rules/no-optional-and-default-together.mjs +0 -71
  40. package/dist/rules/no-string-schema-with-uuid.cjs +0 -58
  41. package/dist/rules/no-string-schema-with-uuid.mjs +0 -58
  42. package/dist/rules/no-throw-in-refine.cjs +0 -70
  43. package/dist/rules/no-throw-in-refine.mjs +0 -69
  44. package/dist/rules/no-transform-in-record-key.cjs +0 -54
  45. package/dist/rules/no-transform-in-record-key.mjs +0 -53
  46. package/dist/rules/no-unknown-schema.cjs +0 -30
  47. package/dist/rules/no-unknown-schema.mjs +0 -31
  48. package/dist/rules/prefer-enum-over-literal-union.cjs +0 -64
  49. package/dist/rules/prefer-enum-over-literal-union.mjs +0 -63
  50. package/dist/rules/prefer-meta-last.cjs +0 -48
  51. package/dist/rules/prefer-meta-last.mjs +0 -49
  52. package/dist/rules/prefer-meta.cjs +0 -39
  53. package/dist/rules/prefer-meta.mjs +0 -40
  54. package/dist/rules/prefer-namespace-import.cjs +0 -117
  55. package/dist/rules/prefer-namespace-import.mjs +0 -116
  56. package/dist/rules/prefer-string-schema-with-trim.cjs +0 -52
  57. package/dist/rules/prefer-string-schema-with-trim.mjs +0 -52
  58. package/dist/rules/prefer-trim-before-string-length-checks.cjs +0 -63
  59. package/dist/rules/prefer-trim-before-string-length-checks.mjs +0 -63
  60. package/dist/rules/require-brand-type-parameter.cjs +0 -48
  61. package/dist/rules/require-brand-type-parameter.mjs +0 -49
  62. package/dist/rules/require-error-message.cjs +0 -85
  63. package/dist/rules/require-error-message.mjs +0 -84
  64. package/dist/rules/require-schema-suffix.cjs +0 -69
  65. package/dist/rules/require-schema-suffix.mjs +0 -68
  66. package/dist/rules/schema-error-property-style.cjs +0 -96
  67. package/dist/rules/schema-error-property-style.mjs +0 -94
  68. package/dist/utils/build-zod-chain-remove-method-fix.cjs +0 -15
  69. package/dist/utils/build-zod-chain-remove-method-fix.mjs +0 -15
  70. package/dist/utils/build-zod-chain-replacement-fix.cjs +0 -30
  71. package/dist/utils/build-zod-chain-replacement-fix.mjs +0 -30
  72. package/dist/utils/create-plugin-rule.cjs +0 -6
  73. package/dist/utils/create-plugin-rule.mjs +0 -6
  74. package/dist/utils/detect-zod-schema-root-node.cjs +0 -113
  75. package/dist/utils/detect-zod-schema-root-node.mjs +0 -111
  76. package/dist/utils/find-parent-schema-matching-condition.cjs +0 -25
  77. package/dist/utils/find-parent-schema-matching-condition.mjs +0 -24
  78. package/dist/utils/is-zod-import-source.cjs +0 -17
  79. package/dist/utils/is-zod-import-source.mjs +0 -16
  80. package/dist/utils/track-zod-schema-imports.cjs +0 -80
  81. package/dist/utils/track-zod-schema-imports.mjs +0 -79
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # eslint-plugin-zod
2
2
 
3
- [![CI][CIBadge]][CIURL]
3
+ [![CI Status][CIBadge]][CIURL]
4
4
  [![Code style: prettier][CodeStyleBadge]][CodeStyleURL]
5
5
  [![Lint: eslint][lintBadge]][lintURL]
6
- [![npm version][npmVersionBadge]][npmVersionURL]
7
- [![issues][issuesBadge]][issuesURL]
6
+ [![Open on npmx][npmVersionBadge]][npmVersionURL]
7
+ [![Open issue tracker][issuesBadge]][issuesURL]
8
8
 
9
- [CIBadge]: https://img.shields.io/github/actions/workflow/status/marcalexiei/eslint-plugin-zod/ci.yml?style=for-the-badge&logo=github&event=push&label=CI
10
- [CIURL]: https://github.com/marcalexiei/eslint-plugin-zod/actions/workflows/CI.yml/badge.svg
9
+ [CIBadge]: https://img.shields.io/github/actions/workflow/status/marcalexiei/eslint-zod/ci.yml?style=for-the-badge&logo=github&event=push&label=CI
10
+ [CIURL]: https://github.com/marcalexiei/eslint-zod/actions/workflows/CI.yml/badge.svg
11
11
  [CodeStyleBadge]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge&logo=prettier
12
12
  [CodeStyleURL]: https://prettier.io
13
13
  [npmVersionBadge]: https://img.shields.io/npm/v/eslint-plugin-zod.svg?style=for-the-badge&logo=npm
14
- [npmVersionURL]: https://www.npmjs.com/package/eslint-plugin-zod
14
+ [npmVersionURL]: https://npmx.dev/package/eslint-plugin-zod
15
15
  [lintBadge]: https://img.shields.io/badge/lint-eslint-3A33D1?logo=eslint&style=for-the-badge
16
16
  [lintURL]: https://eslint.org
17
- [issuesBadge]: https://img.shields.io/github/issues/marcalexiei/eslint-plugin-zod.svg?style=for-the-badge
18
- [issuesURL]: https://github.com/marcalexiei/eslint-plugin-zod/issues
17
+ [issuesBadge]: https://img.shields.io/github/issues/marcalexiei/eslint-zod.svg?style=for-the-badge
18
+ [issuesURL]: https://github.com/marcalexiei/eslint-zod/issues
19
19
 
20
20
  [ESLint](https://eslint.org) plugin that adds custom linting rules to enforce best practices when using [Zod](https://github.com/colinhacks/zod).
21
21
 
@@ -24,56 +24,42 @@ Find out more about [Oxlint's `jsPLugins`](https://oxc.rs/docs/guide/usage/linte
24
24
 
25
25
  ## Rules
26
26
 
27
- `zod` and `zod-mini` have distinct API surfaces.
28
- This plugin is primarily built for `zod`, so some rules are exclusive to `zod` and not available for `zod-mini`.
29
-
30
27
  <!-- begin auto-generated rules list -->
31
28
 
32
29
  💼 Configurations enabled in.\
33
30
  ✅ Set in the `recommended` configuration.\
34
- ✔️ Set in the `recommendedMini` configuration.\
35
31
  🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
36
- 💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\
37
- ❌ Deprecated.
38
-
39
- ### Universal rules (`zod` & `zod-mini`)
40
-
41
- | Name                                | Description | 💼 | 🔧 | 💡 | |
42
- | :--------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- | :---- | :-- | :-- | :-- |
43
- | [consistent-import](docs/rules/consistent-import.md) | Enforce a consistent import style for Zod | ✅ | 🔧 | | |
44
- | [consistent-import-source](docs/rules/consistent-import-source.md) | Enforce consistent source from Zod imports | | | 💡 | |
45
- | [consistent-object-schema-type](docs/rules/consistent-object-schema-type.md) | Enforce consistent usage of Zod schema methods | | | 💡 | |
46
- | [consistent-schema-output-type-style](docs/rules/consistent-schema-output-type-style.md) | Enforce consistent use of z.infer or z.output for schema type inference | | 🔧 | | |
47
- | [consistent-schema-var-name](docs/rules/consistent-schema-var-name.md) | Enforce a consistent naming convention for Zod schema variables | ✅ ✔️ | | | |
48
- | [no-any-schema](docs/rules/no-any-schema.md) | Disallow usage of `z.any()` in Zod schemas | ✔️ | | 💡 | |
49
- | [no-empty-custom-schema](docs/rules/no-empty-custom-schema.md) | Disallow usage of `z.custom()` without arguments | ✅ | | | |
50
- | [no-unknown-schema](docs/rules/no-unknown-schema.md) | Disallow usage of `z.unknown()` in Zod schemas | | | | |
51
- | [prefer-meta](docs/rules/prefer-meta.md) | Enforce usage of `.meta()` over `.describe()` | ✔️ | 🔧 | | |
52
- | [prefer-namespace-import](docs/rules/prefer-namespace-import.md) | Enforce importing zod as a namespace import (`import * as z from 'zod'`) | | 🔧 | | ❌ |
53
- | [require-brand-type-parameter](docs/rules/require-brand-type-parameter.md) | Require type parameter on `.brand()` functions | ✅ ✔️ | | 💡 | |
54
- | [require-error-message](docs/rules/require-error-message.md) | Enforce that custom refinements include an error message | ✔️ | 🔧 | | |
55
- | [require-schema-suffix](docs/rules/require-schema-suffix.md) | Require schema suffix when declaring a Zod schema | | | | ❌ |
56
- | [schema-error-property-style](docs/rules/schema-error-property-style.md) | Enforce consistent style for error messages in Zod schema validation (using ESQuery patterns) | | | | |
57
-
58
- ### `zod` exclusive rules
59
-
60
- | Name                                    | Description | 💼 | 🔧 | 💡 | ❌ |
61
- | :----------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- |
62
- | [array-style](docs/rules/array-style.md) | Enforce consistent Zod array style | ✅ | 🔧 | | |
63
- | [no-number-schema-with-finite](docs/rules/no-number-schema-with-finite.md) | Disallow deprecated `z.number().finite()`. In Zod 4+ number schemas do not allow infinite values by default, so it is a no-op. | ✅ | 🔧 | | |
64
- | [no-number-schema-with-int](docs/rules/no-number-schema-with-int.md) | Disallow usage of `z.number().int()` as it is considered legacy | ✅ | 🔧 | | |
65
- | [no-number-schema-with-is-finite](docs/rules/no-number-schema-with-is-finite.md) | Disallow using deprecated `isFinite` on a Zod number schema; in v4+ it is always `true`. | ✅ | | | |
66
- | [no-number-schema-with-is-int](docs/rules/no-number-schema-with-is-int.md) | Disallow using deprecated `isInt` on a Zod number schema; check the `format` property instead. | ✅ | | | |
67
- | [no-number-schema-with-safe](docs/rules/no-number-schema-with-safe.md) | Disallow deprecated `z.number().safe()`. Use `z.int()`; `.safe()` is now identical to `.int()`. | ✅ | 🔧 | | |
68
- | [no-number-schema-with-step](docs/rules/no-number-schema-with-step.md) | Disallow deprecated `z.number().step()`. Use `.multipleOf()` instead. | ✅ | 🔧 | | |
69
- | [no-optional-and-default-together](docs/rules/no-optional-and-default-together.md) | Disallow using both `.optional()` and `.default()` on the same Zod schema | ✅ | 🔧 | | |
70
- | [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 | ✅ | 🔧 | | |
71
- | [no-throw-in-refine](docs/rules/no-throw-in-refine.md) | Disallow throwing errors directly inside Zod refine callbacks | ✅ | | | |
72
- | [no-transform-in-record-key](docs/rules/no-transform-in-record-key.md) | Disallow transforms in z.record() key schemas, which can cause silent key mutations and data loss through key collisions | | | | |
73
- | [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. | ✅ | 🔧 | | |
74
- | [prefer-meta-last](docs/rules/prefer-meta-last.md) | Enforce `.meta()` as last method | ✅ | 🔧 | | |
75
- | [prefer-string-schema-with-trim](docs/rules/prefer-string-schema-with-trim.md) | Enforce `z.string().trim()` to prevent accidental leading/trailing whitespace | ✅ | 🔧 | | |
76
- | [prefer-trim-before-string-length-checks](docs/rules/prefer-trim-before-string-length-checks.md) | Enforce `.trim()` is called before string length checks to ensure accurate validation | ✅ | 🔧 | | |
32
+ 💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
33
+
34
+ | Name                                    | Description | 💼 | 🔧 | 💡 |
35
+ | :----------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------- | :-- | :-- | :-- |
36
+ | [array-style](docs/rules/array-style.md) | Enforce consistent Zod array style | ✅ | 🔧 | |
37
+ | [consistent-import](docs/rules/consistent-import.md) | Enforce a consistent import style for Zod | | 🔧 | |
38
+ | [consistent-import-source](docs/rules/consistent-import-source.md) | Enforce consistent source from Zod imports | | | 💡 |
39
+ | [consistent-object-schema-type](docs/rules/consistent-object-schema-type.md) | Enforce consistent usage of Zod schema methods | | | 💡 |
40
+ | [consistent-schema-output-type-style](docs/rules/consistent-schema-output-type-style.md) | Enforce consistent use of z.infer or z.output for schema type inference | | 🔧 | |
41
+ | [consistent-schema-var-name](docs/rules/consistent-schema-var-name.md) | Enforce a consistent naming convention for Zod schema variables | | | |
42
+ | [no-any-schema](docs/rules/no-any-schema.md) | Disallow usage of `z.any()` in Zod schemas | | | 💡 |
43
+ | [no-empty-custom-schema](docs/rules/no-empty-custom-schema.md) | Disallow usage of `z.custom()` without arguments | ✅ | | |
44
+ | [no-number-schema-with-finite](docs/rules/no-number-schema-with-finite.md) | Disallow deprecated `z.number().finite()`. In Zod 4+ number schemas do not allow infinite values by default, so it is a no-op. || 🔧 | |
45
+ | [no-number-schema-with-int](docs/rules/no-number-schema-with-int.md) | Disallow usage of `z.number().int()` as it is considered legacy | ✅ | 🔧 | |
46
+ | [no-number-schema-with-is-finite](docs/rules/no-number-schema-with-is-finite.md) | Disallow using deprecated `isFinite` on a Zod number schema; in v4+ it is always `true`. || | |
47
+ | [no-number-schema-with-is-int](docs/rules/no-number-schema-with-is-int.md) | Disallow using deprecated `isInt` on a Zod number schema; check the `format` property instead. | | | |
48
+ | [no-number-schema-with-safe](docs/rules/no-number-schema-with-safe.md) | Disallow deprecated `z.number().safe()`. Use `z.int()`; `.safe()` is now identical to `.int()`. || 🔧 | |
49
+ | [no-number-schema-with-step](docs/rules/no-number-schema-with-step.md) | Disallow deprecated `z.number().step()`. Use `.multipleOf()` instead. | ✅ | 🔧 | |
50
+ | [no-optional-and-default-together](docs/rules/no-optional-and-default-together.md) | Disallow using both `.optional()` and `.default()` on the same Zod schema | ✅ | 🔧 | |
51
+ | [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 || 🔧 | |
52
+ | [no-throw-in-refine](docs/rules/no-throw-in-refine.md) | Disallow throwing errors directly inside Zod refine callbacks | | | |
53
+ | [no-transform-in-record-key](docs/rules/no-transform-in-record-key.md) | Disallow transforms in z.record() key schemas, which can cause silent key mutations and data loss through key collisions | | | |
54
+ | [no-unknown-schema](docs/rules/no-unknown-schema.md) | Disallow usage of `z.unknown()` in Zod schemas | | | |
55
+ | [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. | ✅ | 🔧 | |
56
+ | [prefer-meta](docs/rules/prefer-meta.md) | Enforce usage of `.meta()` over `.describe()` | | 🔧 | |
57
+ | [prefer-meta-last](docs/rules/prefer-meta-last.md) | Enforce `.meta()` as last method | | 🔧 | |
58
+ | [prefer-string-schema-with-trim](docs/rules/prefer-string-schema-with-trim.md) | Enforce `z.string().trim()` to prevent accidental leading/trailing whitespace | ✅ | 🔧 | |
59
+ | [prefer-trim-before-string-length-checks](docs/rules/prefer-trim-before-string-length-checks.md) | Enforce `.trim()` is called before string length checks to ensure accurate validation | ✅ | 🔧 | |
60
+ | [require-brand-type-parameter](docs/rules/require-brand-type-parameter.md) | Require type parameter on `.brand()` functions | ✅ | | 💡 |
61
+ | [require-error-message](docs/rules/require-error-message.md) | Enforce that custom refinements include an error message | ✅ | 🔧 | |
62
+ | [schema-error-property-style](docs/rules/schema-error-property-style.md) | Enforce consistent style for error messages in Zod schema validation (using ESQuery patterns) | | | |
77
63
 
78
64
  <!-- end auto-generated rules list -->
79
65
 
@@ -109,7 +95,7 @@ pnpm add --save-dev eslint eslint-plugin-zod
109
95
  eslintPluginZod.configs.recommended,
110
96
  ```
111
97
 
112
- Heres a minimal example using the flat config format:
98
+ Here's a minimal example using the flat config format:
113
99
 
114
100
  ```ts
115
101
  // eslint.config.js
@@ -159,7 +145,7 @@ pnpm add --save-dev oxlint eslint-plugin-zod
159
145
  3. Add `eslintPluginZod.configs.recommended.rules` to your Oxlint config.\
160
146
  Alternatively you can specify the rules manually
161
147
 
162
- Heres a minimal example using the flat config format:
148
+ Here's a minimal example using the flat config format:
163
149
 
164
150
  ```ts
165
151
  // oxlint.config.ts
@@ -178,9 +164,9 @@ export default defineConfig({
178
164
 
179
165
  `eslint-plugin-zod` is designed for projects that use `zod@^4`.
180
166
  While the plugin analyzes Zod schemas in your code,
181
- it doesnt import or depend on Zod at runtime.
167
+ it doesn't import or depend on Zod at runtime.
182
168
  To document this relationship without forcing installation,
183
- Zod is declared as an optional peer dependency in the plugins `package.json`.
169
+ Zod is declared as an optional peer dependency in the plugin's `package.json`.
184
170
 
185
171
  If your project uses Zod v4, the plugin will automatically lint your schemas.
186
- If youre not using Zod (for example, in a separate ESLint workspace), you dont need to install it.
172
+ If you're not using Zod (for example, in a separate ESLint workspace), you don't need to install it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-zod",
3
- "version": "3.12.1",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "description": "ESLint plugin that adds custom linting rules to enforce best practices when using Zod",
6
6
  "engines": {
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "./package.json": "./package.json"
21
21
  },
22
- "homepage": "https://github.com/marcalexiei/eslint-plugin-zod#readme",
22
+ "homepage": "https://github.com/marcalexiei/eslint-zod#readme",
23
23
  "bugs": {
24
- "url": "https://github.com/marcalexiei/eslint-plugin-zod/issues"
24
+ "url": "https://github.com/marcalexiei/eslint-zod/issues"
25
25
  },
26
26
  "keywords": [
27
27
  "eslint",
@@ -37,12 +37,13 @@
37
37
  "license": "MIT",
38
38
  "repository": {
39
39
  "type": "git",
40
- "url": "https://github.com/marcalexiei/eslint-plugin-zod"
40
+ "url": "https://github.com/marcalexiei/eslint-zod",
41
+ "directory": "plugins/eslint-plugin-zod"
41
42
  },
42
- "prettier": "@marcalexiei/prettier-config",
43
43
  "dependencies": {
44
44
  "@typescript-eslint/utils": "^8.57.0",
45
- "esquery": "^1.6.0"
45
+ "esquery": "^1.6.0",
46
+ "@eslint-zod/utils": "1.0.0"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "eslint": "^9 || ^10",
@@ -61,41 +62,19 @@
61
62
  }
62
63
  },
63
64
  "devDependencies": {
64
- "@changesets/changelog-github": "0.6.0",
65
- "@changesets/cli": "2.31.0",
66
- "@marcalexiei/eslint-config": "7.0.0",
67
65
  "@marcalexiei/prettier-config": "1.1.4",
68
66
  "@types/esquery": "1.5.4",
69
- "@types/node": "25.6.0",
70
67
  "@typescript-eslint/rule-tester": "8.59.2",
71
- "@vitest/eslint-plugin": "1.6.16",
72
68
  "dedent": "1.7.2",
73
- "eslint": "10.3.0",
74
69
  "eslint-doc-generator": "3.3.2",
75
- "eslint-import-resolver-typescript": "4.4.4",
76
- "eslint-plugin-eslint-plugin": "7.3.3",
77
- "eslint-plugin-import-x": "4.16.2",
78
- "eslint-plugin-n": "17.24.0",
79
- "knip": "6.11.0",
80
70
  "prettier": "3.8.3",
81
71
  "tsdown": "0.21.10",
82
- "typescript": "6.0.3",
83
- "typescript-eslint": "8.59.2",
84
72
  "vitest": "4.1.5"
85
73
  },
86
74
  "scripts": {
87
75
  "build": "tsdown",
88
76
  "build:docs": "pnpm run build && eslint-doc-generator",
89
- "lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:knip",
90
- "lint:js": "eslint .",
91
- "lint:js:fix": "eslint . --fix",
92
77
  "lint:docs": "eslint-doc-generator --check",
93
- "lint:knip": "knip",
94
- "format": "prettier . --write",
95
- "format:check": "prettier . --check",
96
- "test": "vitest",
97
- "test:dev": "vitest --typecheck=false",
98
- "release": "pnpm run build && changeset publish",
99
- "check-all": "pnpm run \"/^(lint|format|typecheck|build)$/\" && pnpm run test --run"
78
+ "test": "vitest"
100
79
  }
101
80
  }
@@ -1,23 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- exports.__toESM = __toESM;
package/dist/index.cjs DELETED
@@ -1,122 +0,0 @@
1
- const require_meta = require("./meta.cjs");
2
- const require_array_style = require("./rules/array-style.cjs");
3
- const require_consistent_import_source = require("./rules/consistent-import-source.cjs");
4
- const require_consistent_import = require("./rules/consistent-import.cjs");
5
- const require_consistent_object_schema_type = require("./rules/consistent-object-schema-type.cjs");
6
- const require_consistent_schema_output_type_style = require("./rules/consistent-schema-output-type-style.cjs");
7
- const require_consistent_schema_var_name = require("./rules/consistent-schema-var-name.cjs");
8
- const require_no_any_schema = require("./rules/no-any-schema.cjs");
9
- const require_no_empty_custom_schema = require("./rules/no-empty-custom-schema.cjs");
10
- const require_no_number_schema_with_finite = require("./rules/no-number-schema-with-finite.cjs");
11
- const require_no_number_schema_with_int = require("./rules/no-number-schema-with-int.cjs");
12
- const require_no_number_schema_with_is_finite = require("./rules/no-number-schema-with-is-finite.cjs");
13
- const require_no_number_schema_with_is_int = require("./rules/no-number-schema-with-is-int.cjs");
14
- const require_no_number_schema_with_safe = require("./rules/no-number-schema-with-safe.cjs");
15
- const require_no_number_schema_with_step = require("./rules/no-number-schema-with-step.cjs");
16
- const require_no_optional_and_default_together = require("./rules/no-optional-and-default-together.cjs");
17
- const require_no_string_schema_with_uuid = require("./rules/no-string-schema-with-uuid.cjs");
18
- const require_no_throw_in_refine = require("./rules/no-throw-in-refine.cjs");
19
- const require_no_transform_in_record_key = require("./rules/no-transform-in-record-key.cjs");
20
- const require_no_unknown_schema = require("./rules/no-unknown-schema.cjs");
21
- const require_prefer_enum_over_literal_union = require("./rules/prefer-enum-over-literal-union.cjs");
22
- const require_prefer_meta_last = require("./rules/prefer-meta-last.cjs");
23
- const require_prefer_meta = require("./rules/prefer-meta.cjs");
24
- const require_prefer_namespace_import = require("./rules/prefer-namespace-import.cjs");
25
- const require_prefer_string_schema_with_trim = require("./rules/prefer-string-schema-with-trim.cjs");
26
- const require_prefer_trim_before_string_length_checks = require("./rules/prefer-trim-before-string-length-checks.cjs");
27
- const require_require_brand_type_parameter = require("./rules/require-brand-type-parameter.cjs");
28
- const require_require_error_message = require("./rules/require-error-message.cjs");
29
- const require_require_schema_suffix = require("./rules/require-schema-suffix.cjs");
30
- const require_schema_error_property_style = require("./rules/schema-error-property-style.cjs");
31
- //#region src/index.ts
32
- const eslintPluginZod = {
33
- meta: {
34
- name: require_meta.PLUGIN_NAME,
35
- version: require_meta.PLUGIN_VERSION
36
- },
37
- rules: {
38
- "array-style": require_array_style.arrayStyle,
39
- "consistent-import-source": require_consistent_import_source.consistentImportSource,
40
- "consistent-import": require_consistent_import.consistentImport,
41
- "consistent-object-schema-type": require_consistent_object_schema_type.consistentObjectSchemaType,
42
- "consistent-schema-var-name": require_consistent_schema_var_name.consistentSchemaVarName,
43
- "consistent-schema-output-type-style": require_consistent_schema_output_type_style.consistentSchemaOutputTypeStyle,
44
- "no-any-schema": require_no_any_schema.noAnySchema,
45
- "no-empty-custom-schema": require_no_empty_custom_schema.noEmptyCustomSchema,
46
- "no-number-schema-with-finite": require_no_number_schema_with_finite.noNumberSchemaWithFinite,
47
- "no-number-schema-with-int": require_no_number_schema_with_int.noNumberSchemaWithInt,
48
- "no-number-schema-with-is-finite": require_no_number_schema_with_is_finite.noNumberSchemaWithIsFinite,
49
- "no-number-schema-with-is-int": require_no_number_schema_with_is_int.noNumberSchemaWithIsInt,
50
- "no-number-schema-with-safe": require_no_number_schema_with_safe.noNumberSchemaWithSafe,
51
- "no-number-schema-with-step": require_no_number_schema_with_step.noNumberSchemaWithStep,
52
- "no-string-schema-with-uuid": require_no_string_schema_with_uuid.noStringSchemaWithUuid,
53
- "no-optional-and-default-together": require_no_optional_and_default_together.noOptionalAndDefaultTogether,
54
- "no-throw-in-refine": require_no_throw_in_refine.noThrowInRefine,
55
- "no-transform-in-record-key": require_no_transform_in_record_key.noTransformInRecordKey,
56
- "no-unknown-schema": require_no_unknown_schema.noUnknownSchema,
57
- "prefer-enum-over-literal-union": require_prefer_enum_over_literal_union.preferEnumOverLiteralUnion,
58
- "prefer-meta": require_prefer_meta.preferMeta,
59
- "prefer-meta-last": require_prefer_meta_last.preferMetaLast,
60
- "prefer-namespace-import": require_prefer_namespace_import.preferNamespaceImport,
61
- "prefer-string-schema-with-trim": require_prefer_string_schema_with_trim.preferStringSchemaWithTrim,
62
- "prefer-trim-before-string-length-checks": require_prefer_trim_before_string_length_checks.preferTrimBeforeStringLengthChecks,
63
- "require-brand-type-parameter": require_require_brand_type_parameter.requireBrandTypeParameter,
64
- "require-error-message": require_require_error_message.requireErrorMessage,
65
- "require-schema-suffix": require_require_schema_suffix.requireSchemaSuffix,
66
- "schema-error-property-style": require_schema_error_property_style.schemaErrorPropertyStyle
67
- }
68
- };
69
- const baseConfig = {
70
- name: `${require_meta.PLUGIN_NAME}/recommended`,
71
- files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
72
- plugins: { zod: eslintPluginZod }
73
- };
74
- const recommendedConfig = {
75
- ...baseConfig,
76
- rules: {
77
- "zod/array-style": "error",
78
- "zod/consistent-import": "error",
79
- "zod/consistent-schema-var-name": "error",
80
- "zod/no-any-schema": "error",
81
- "zod/no-empty-custom-schema": "error",
82
- "zod/no-number-schema-with-finite": "error",
83
- "zod/no-number-schema-with-int": "error",
84
- "zod/no-number-schema-with-is-finite": "error",
85
- "zod/no-number-schema-with-is-int": "error",
86
- "zod/no-number-schema-with-safe": "error",
87
- "zod/no-number-schema-with-step": "error",
88
- "zod/no-string-schema-with-uuid": "error",
89
- "zod/no-optional-and-default-together": "error",
90
- "zod/no-throw-in-refine": "error",
91
- "zod/prefer-enum-over-literal-union": "error",
92
- "zod/prefer-meta": "error",
93
- "zod/prefer-meta-last": "error",
94
- "zod/prefer-string-schema-with-trim": "error",
95
- "zod/prefer-trim-before-string-length-checks": "error",
96
- "zod/require-brand-type-parameter": "error",
97
- "zod/require-error-message": "error"
98
- }
99
- };
100
- const recommendedConfigMini = {
101
- ...baseConfig,
102
- rules: {
103
- "zod/consistent-schema-var-name": "error",
104
- "zod/no-any-schema": "error",
105
- "zod/prefer-meta": "error",
106
- "zod/require-brand-type-parameter": "error",
107
- "zod/require-error-message": "error"
108
- }
109
- };
110
- var src_default = {
111
- ...eslintPluginZod,
112
- configs: {
113
- recommended: recommendedConfig,
114
- recommendedMini: recommendedConfigMini
115
- }
116
- };
117
- /**
118
- * why `satisfies`?
119
- * @see https://github.com/marcalexiei/eslint-plugin-zod/issues/49
120
- */
121
- //#endregion
122
- module.exports = src_default;
package/dist/index.d.cts DELETED
@@ -1,23 +0,0 @@
1
- //#region src/index.d.ts
2
- interface CompatibleConfig {
3
- name?: string;
4
- rules?: object;
5
- plugins?: Record<string, CompatiblePlugin>;
6
- }
7
- interface CompatiblePlugin {
8
- meta: {
9
- name: string;
10
- version: string;
11
- };
12
- }
13
- declare const _default: {
14
- configs: {
15
- recommended: CompatibleConfig;
16
- recommendedMini: CompatibleConfig;
17
- };
18
- meta: {
19
- name: string;
20
- version: string;
21
- };
22
- };
23
- export = _default;
package/dist/index.d.mts DELETED
@@ -1,24 +0,0 @@
1
- //#region src/index.d.ts
2
- interface CompatibleConfig {
3
- name?: string;
4
- rules?: object;
5
- plugins?: Record<string, CompatiblePlugin>;
6
- }
7
- interface CompatiblePlugin {
8
- meta: {
9
- name: string;
10
- version: string;
11
- };
12
- }
13
- declare const _default: {
14
- configs: {
15
- recommended: CompatibleConfig;
16
- recommendedMini: CompatibleConfig;
17
- };
18
- meta: {
19
- name: string;
20
- version: string;
21
- };
22
- };
23
- //#endregion
24
- export { _default as default };
package/dist/index.mjs DELETED
@@ -1,122 +0,0 @@
1
- import { PLUGIN_NAME, PLUGIN_VERSION } from "./meta.mjs";
2
- import { arrayStyle } from "./rules/array-style.mjs";
3
- import { consistentImportSource } from "./rules/consistent-import-source.mjs";
4
- import { consistentImport } from "./rules/consistent-import.mjs";
5
- import { consistentObjectSchemaType } from "./rules/consistent-object-schema-type.mjs";
6
- import { consistentSchemaOutputTypeStyle } from "./rules/consistent-schema-output-type-style.mjs";
7
- import { consistentSchemaVarName } from "./rules/consistent-schema-var-name.mjs";
8
- import { noAnySchema } from "./rules/no-any-schema.mjs";
9
- import { noEmptyCustomSchema } from "./rules/no-empty-custom-schema.mjs";
10
- import { noNumberSchemaWithFinite } from "./rules/no-number-schema-with-finite.mjs";
11
- import { noNumberSchemaWithInt } from "./rules/no-number-schema-with-int.mjs";
12
- import { noNumberSchemaWithIsFinite } from "./rules/no-number-schema-with-is-finite.mjs";
13
- import { noNumberSchemaWithIsInt } from "./rules/no-number-schema-with-is-int.mjs";
14
- import { noNumberSchemaWithSafe } from "./rules/no-number-schema-with-safe.mjs";
15
- import { noNumberSchemaWithStep } from "./rules/no-number-schema-with-step.mjs";
16
- import { noOptionalAndDefaultTogether } from "./rules/no-optional-and-default-together.mjs";
17
- import { noStringSchemaWithUuid } from "./rules/no-string-schema-with-uuid.mjs";
18
- import { noThrowInRefine } from "./rules/no-throw-in-refine.mjs";
19
- import { noTransformInRecordKey } from "./rules/no-transform-in-record-key.mjs";
20
- import { noUnknownSchema } from "./rules/no-unknown-schema.mjs";
21
- import { preferEnumOverLiteralUnion } from "./rules/prefer-enum-over-literal-union.mjs";
22
- import { preferMetaLast } from "./rules/prefer-meta-last.mjs";
23
- import { preferMeta } from "./rules/prefer-meta.mjs";
24
- import { preferNamespaceImport } from "./rules/prefer-namespace-import.mjs";
25
- import { preferStringSchemaWithTrim } from "./rules/prefer-string-schema-with-trim.mjs";
26
- import { preferTrimBeforeStringLengthChecks } from "./rules/prefer-trim-before-string-length-checks.mjs";
27
- import { requireBrandTypeParameter } from "./rules/require-brand-type-parameter.mjs";
28
- import { requireErrorMessage } from "./rules/require-error-message.mjs";
29
- import { requireSchemaSuffix } from "./rules/require-schema-suffix.mjs";
30
- import { schemaErrorPropertyStyle } from "./rules/schema-error-property-style.mjs";
31
- //#region src/index.ts
32
- const eslintPluginZod = {
33
- meta: {
34
- name: PLUGIN_NAME,
35
- version: PLUGIN_VERSION
36
- },
37
- rules: {
38
- "array-style": arrayStyle,
39
- "consistent-import-source": consistentImportSource,
40
- "consistent-import": consistentImport,
41
- "consistent-object-schema-type": consistentObjectSchemaType,
42
- "consistent-schema-var-name": consistentSchemaVarName,
43
- "consistent-schema-output-type-style": consistentSchemaOutputTypeStyle,
44
- "no-any-schema": noAnySchema,
45
- "no-empty-custom-schema": noEmptyCustomSchema,
46
- "no-number-schema-with-finite": noNumberSchemaWithFinite,
47
- "no-number-schema-with-int": noNumberSchemaWithInt,
48
- "no-number-schema-with-is-finite": noNumberSchemaWithIsFinite,
49
- "no-number-schema-with-is-int": noNumberSchemaWithIsInt,
50
- "no-number-schema-with-safe": noNumberSchemaWithSafe,
51
- "no-number-schema-with-step": noNumberSchemaWithStep,
52
- "no-string-schema-with-uuid": noStringSchemaWithUuid,
53
- "no-optional-and-default-together": noOptionalAndDefaultTogether,
54
- "no-throw-in-refine": noThrowInRefine,
55
- "no-transform-in-record-key": noTransformInRecordKey,
56
- "no-unknown-schema": noUnknownSchema,
57
- "prefer-enum-over-literal-union": preferEnumOverLiteralUnion,
58
- "prefer-meta": preferMeta,
59
- "prefer-meta-last": preferMetaLast,
60
- "prefer-namespace-import": preferNamespaceImport,
61
- "prefer-string-schema-with-trim": preferStringSchemaWithTrim,
62
- "prefer-trim-before-string-length-checks": preferTrimBeforeStringLengthChecks,
63
- "require-brand-type-parameter": requireBrandTypeParameter,
64
- "require-error-message": requireErrorMessage,
65
- "require-schema-suffix": requireSchemaSuffix,
66
- "schema-error-property-style": schemaErrorPropertyStyle
67
- }
68
- };
69
- const baseConfig = {
70
- name: `${PLUGIN_NAME}/recommended`,
71
- files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
72
- plugins: { zod: eslintPluginZod }
73
- };
74
- const recommendedConfig = {
75
- ...baseConfig,
76
- rules: {
77
- "zod/array-style": "error",
78
- "zod/consistent-import": "error",
79
- "zod/consistent-schema-var-name": "error",
80
- "zod/no-any-schema": "error",
81
- "zod/no-empty-custom-schema": "error",
82
- "zod/no-number-schema-with-finite": "error",
83
- "zod/no-number-schema-with-int": "error",
84
- "zod/no-number-schema-with-is-finite": "error",
85
- "zod/no-number-schema-with-is-int": "error",
86
- "zod/no-number-schema-with-safe": "error",
87
- "zod/no-number-schema-with-step": "error",
88
- "zod/no-string-schema-with-uuid": "error",
89
- "zod/no-optional-and-default-together": "error",
90
- "zod/no-throw-in-refine": "error",
91
- "zod/prefer-enum-over-literal-union": "error",
92
- "zod/prefer-meta": "error",
93
- "zod/prefer-meta-last": "error",
94
- "zod/prefer-string-schema-with-trim": "error",
95
- "zod/prefer-trim-before-string-length-checks": "error",
96
- "zod/require-brand-type-parameter": "error",
97
- "zod/require-error-message": "error"
98
- }
99
- };
100
- const recommendedConfigMini = {
101
- ...baseConfig,
102
- rules: {
103
- "zod/consistent-schema-var-name": "error",
104
- "zod/no-any-schema": "error",
105
- "zod/prefer-meta": "error",
106
- "zod/require-brand-type-parameter": "error",
107
- "zod/require-error-message": "error"
108
- }
109
- };
110
- var src_default = {
111
- ...eslintPluginZod,
112
- configs: {
113
- recommended: recommendedConfig,
114
- recommendedMini: recommendedConfigMini
115
- }
116
- };
117
- /**
118
- * why `satisfies`?
119
- * @see https://github.com/marcalexiei/eslint-plugin-zod/issues/49
120
- */
121
- //#endregion
122
- export { src_default as default };
package/dist/meta.cjs DELETED
@@ -1,13 +0,0 @@
1
- require("./_virtual/_rolldown/runtime.cjs");
2
- let node_fs = require("node:fs");
3
- //#region src/meta.ts
4
- const { name: PLUGIN_NAME, version: PLUGIN_VERSION, homepage } = JSON.parse((0, node_fs.readFileSync)(new URL("../package.json", require("url").pathToFileURL(__filename).href), "utf8"));
5
- /** @see https://github.com/marcalexiei/eslint-plugin-zod/pull/97 */
6
- const PLUGIN_HOMEPAGE = homepage.replace(/#[^#]*$/, "");
7
- function getRuleURL(ruleID) {
8
- return `${PLUGIN_HOMEPAGE}/blob/v${PLUGIN_VERSION}/docs/rules/${ruleID}.md`;
9
- }
10
- //#endregion
11
- exports.PLUGIN_NAME = PLUGIN_NAME;
12
- exports.PLUGIN_VERSION = PLUGIN_VERSION;
13
- exports.getRuleURL = getRuleURL;
package/dist/meta.mjs DELETED
@@ -1,10 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- //#region src/meta.ts
3
- const { name: PLUGIN_NAME, version: PLUGIN_VERSION, homepage } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
4
- /** @see https://github.com/marcalexiei/eslint-plugin-zod/pull/97 */
5
- const PLUGIN_HOMEPAGE = homepage.replace(/#[^#]*$/, "");
6
- function getRuleURL(ruleID) {
7
- return `${PLUGIN_HOMEPAGE}/blob/v${PLUGIN_VERSION}/docs/rules/${ruleID}.md`;
8
- }
9
- //#endregion
10
- export { PLUGIN_NAME, PLUGIN_VERSION, getRuleURL };