@enormora/eslint-config-zod 0.0.1 → 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2023]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,7 +1,37 @@
1
1
  {
2
- "name": "@enormora/eslint-config-zod",
3
- "version": "0.0.1",
4
- "description": "Placeholder claiming the npm package name \"@enormora/eslint-config-zod\" so a trusted publisher can be configured. See https://github.com/npm/cli/issues/8544.",
5
- "license": "MIT",
6
- "deprecated": "Placeholder published as a workaround so a Trusted Publisher could be configured. See https://github.com/npm/cli/issues/8544."
7
- }
2
+ "author": "Mathias Schreck <schreck.mathias@gmail.com>",
3
+ "contributors": [
4
+ {
5
+ "email": "github@echooff.de",
6
+ "name": "Christian Rackerseder"
7
+ }
8
+ ],
9
+ "dependencies": {
10
+ "@typescript-eslint/utils": "8.64.0",
11
+ "eslint-plugin-zod-core": "1.0.8",
12
+ "eslint-plugin-zod-mini": "1.5.0"
13
+ },
14
+ "description": "Enormora’s ESLint Zod configuration enforcing Zod Mini and Zod core",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./presets/zod/zod.js"
18
+ }
19
+ },
20
+ "license": "MIT",
21
+ "name": "@enormora/eslint-config-zod",
22
+ "peerDependencies": {
23
+ "@enormora/eslint-config-base": "0.0.52",
24
+ "eslint": "^10.0.0"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git://github.com/enormora/eslint-config.git"
29
+ },
30
+ "sideEffects": [
31
+ "./plugins/enormora-zod/require-readonly-schema.js",
32
+ "./presets/zod/zod.js",
33
+ "./rule-sets/restricted-imports.js"
34
+ ],
35
+ "type": "module",
36
+ "version": "0.0.3"
37
+ }
@@ -0,0 +1,7 @@
1
+ import { requireReadonlySchemaRule } from "./require-readonly-schema.js";
2
+ export const enormoraZodPlugin = {
3
+ rules: {
4
+ 'require-readonly-schema': requireReadonlySchemaRule
5
+ }
6
+ };
7
+ //# sourceMappingURL=enormora-zod-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enormora-zod-plugin.js","sourceRoot":"","sources":["../../../../../configs/plugins/enormora-zod/enormora-zod-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAMzE,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAChD,KAAK,EAAE;QACH,yBAAyB,EAAE,yBAAuD;KACrF;CACJ,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
2
+ function ruleUrl(ruleName) {
3
+ return `https://github.com/enormora/eslint-config/blob/main/configs/plugins/enormora-zod/${ruleName}.ts`;
4
+ }
5
+ const { RuleCreator: ruleCreator } = ESLintUtils;
6
+ const buildRule = ruleCreator(ruleUrl);
7
+ const zodNamespace = 'z';
8
+ const readonlyFactory = 'readonly';
9
+ const mutableSchemaFactories = new Set([
10
+ 'object',
11
+ 'strictObject',
12
+ 'looseObject',
13
+ 'array',
14
+ 'tuple',
15
+ 'record',
16
+ 'map',
17
+ 'set'
18
+ ]);
19
+ function readParent(node) {
20
+ const raw = node.parent;
21
+ return raw ?? undefined;
22
+ }
23
+ function getZodFactoryName(node) {
24
+ const { callee } = node;
25
+ if (callee.type !== AST_NODE_TYPES.MemberExpression || callee.computed) {
26
+ return undefined;
27
+ }
28
+ const { object, property } = callee;
29
+ if (object.type !== AST_NODE_TYPES.Identifier || object.name !== zodNamespace) {
30
+ return undefined;
31
+ }
32
+ if (property.type !== AST_NODE_TYPES.Identifier) {
33
+ return undefined;
34
+ }
35
+ return property.name;
36
+ }
37
+ function isWrappedInReadonly(node) {
38
+ const parent = readParent(node);
39
+ if (parent?.type !== AST_NODE_TYPES.CallExpression) {
40
+ return false;
41
+ }
42
+ if (getZodFactoryName(parent) !== readonlyFactory) {
43
+ return false;
44
+ }
45
+ return parent.arguments[0] === node;
46
+ }
47
+ const description = 'Require mutable Zod Mini schemas (`z.object`, `z.strictObject`, `z.looseObject`, `z.array`, ' +
48
+ '`z.tuple`, `z.record`, `z.map`, `z.set`) to be wrapped in `z.readonly()` so the inferred type is ' +
49
+ 'readonly. Applied at every level, wrapping composes into a deeply readonly type.';
50
+ export const requireReadonlySchemaRule = buildRule({
51
+ name: 'require-readonly-schema',
52
+ meta: {
53
+ type: 'problem',
54
+ fixable: 'code',
55
+ docs: { description },
56
+ messages: {
57
+ schemaShouldBeReadonly: 'Wrap this z.{{factory}}() schema in z.readonly() to produce a readonly type.'
58
+ },
59
+ schema: []
60
+ },
61
+ defaultOptions: [],
62
+ create(context) {
63
+ const { sourceCode } = context;
64
+ return {
65
+ CallExpression(node) {
66
+ const factory = getZodFactoryName(node);
67
+ if (factory === undefined || !mutableSchemaFactories.has(factory)) {
68
+ return;
69
+ }
70
+ if (isWrappedInReadonly(node)) {
71
+ return;
72
+ }
73
+ context.report({
74
+ node,
75
+ messageId: 'schemaShouldBeReadonly',
76
+ data: { factory },
77
+ fix(fixer) {
78
+ return fixer.replaceText(node, `z.readonly(${sourceCode.getText(node)})`);
79
+ }
80
+ });
81
+ }
82
+ };
83
+ }
84
+ });
85
+ //# sourceMappingURL=require-readonly-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-readonly-schema.js","sourceRoot":"","sources":["../../../../../configs/plugins/enormora-zod/require-readonly-schema.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,61 @@
1
+ import zodCorePlugin from 'eslint-plugin-zod-core';
2
+ import zodMiniPlugin from 'eslint-plugin-zod-mini';
3
+ import { enormoraZodPlugin } from "../../plugins/enormora-zod/enormora-zod-plugin.js";
4
+ import { createRestrictedImportsPlugin } from "../../rule-sets/restricted-imports.js";
5
+ import { createRestrictedSyntaxPlugin } from "@enormora/eslint-config-base/rule-sets/restricted-syntax.js";
6
+ const useZodMiniOrCoreMessage = 'Use zod/mini or zod/v4/core instead.';
7
+ const regularZodImportRestriction = {
8
+ paths: [
9
+ { name: 'zod', message: useZodMiniOrCoreMessage },
10
+ { name: 'zod/v4', message: useZodMiniOrCoreMessage },
11
+ { name: 'zod/v3', message: useZodMiniOrCoreMessage }
12
+ ]
13
+ };
14
+ const noEnumSchemaRestriction = {
15
+ selector: "CallExpression[callee.object.name='z'][callee.property.name='enum']",
16
+ message: 'Use a union of z.literal() schemas instead of z.enum().'
17
+ };
18
+ const noNativeEnumSchemaRestriction = {
19
+ selector: "CallExpression[callee.object.name='z'][callee.property.name='nativeEnum']",
20
+ message: 'Use a union of z.literal() schemas instead of z.nativeEnum().'
21
+ };
22
+ const restrictedImportsWrappers = createRestrictedImportsPlugin(['no-regular-zod-import']);
23
+ const restrictedSyntaxWrappers = createRestrictedSyntaxPlugin(['no-enum-schema', 'no-native-enum-schema'], {});
24
+ export const zodConfig = {
25
+ plugins: {
26
+ 'zod-mini': zodMiniPlugin,
27
+ 'zod-core': zodCorePlugin,
28
+ 'enormora-zod': enormoraZodPlugin,
29
+ 'restricted-imports': restrictedImportsWrappers,
30
+ 'restricted-syntax-zod': restrictedSyntaxWrappers
31
+ },
32
+ rules: {
33
+ 'zod-mini/consistent-import': ['error', { syntax: 'named' }],
34
+ 'zod-mini/consistent-import-source': ['error', { sources: ['zod/mini'] }],
35
+ 'zod-mini/consistent-object-schema-type': 'off',
36
+ 'zod-mini/consistent-schema-output-type-style': ['error', { style: 'output' }],
37
+ 'zod-mini/consistent-schema-var-name': 'error',
38
+ 'zod-mini/no-any-schema': 'error',
39
+ 'zod-mini/no-coerce-boolean': 'error',
40
+ 'zod-mini/no-conflicting-checks': 'error',
41
+ 'zod-mini/no-duplicate-schema-methods': 'error',
42
+ 'zod-mini/no-empty-custom-schema': 'error',
43
+ 'zod-mini/no-throw-in-refine': 'error',
44
+ 'zod-mini/no-transform-in-record-key': 'error',
45
+ 'zod-mini/no-unknown-schema': 'off',
46
+ 'zod-mini/no-unnecessary-readonly': 'error',
47
+ 'zod-mini/prefer-enum-over-literal-union': 'off',
48
+ 'zod-mini/prefer-meta': 'error',
49
+ 'zod-mini/prefer-tuple-over-array-length': 'error',
50
+ 'zod-mini/require-brand-type-parameter': 'error',
51
+ 'zod-mini/require-error-message': 'error',
52
+ 'zod-mini/schema-error-property-style': 'off',
53
+ 'zod-core/consistent-import': ['error', { syntax: 'named' }],
54
+ 'zod-core/consistent-schema-output-type-style': ['error', { style: 'output' }],
55
+ 'enormora-zod/require-readonly-schema': 'error',
56
+ 'restricted-imports/no-regular-zod-import': ['error', regularZodImportRestriction],
57
+ 'restricted-syntax-zod/no-enum-schema': ['error', noEnumSchemaRestriction],
58
+ 'restricted-syntax-zod/no-native-enum-schema': ['error', noNativeEnumSchemaRestriction]
59
+ }
60
+ };
61
+ //# sourceMappingURL=zod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod.js","sourceRoot":"","sources":["../../../../../configs/presets/zod/zod.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEpF,MAAM,uBAAuB,GAAG,sCAAsC,CAAC;AAEvE,MAAM,2BAA2B,GAAG;IAChC,KAAK,EAAE;QACH,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAuB,EAAE;QACjD,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,uBAAuB,EAAE;QACpD,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,uBAAuB,EAAE;KACvD;CACJ,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC5B,QAAQ,EAAE,qEAAqE;IAC/E,OAAO,EAAE,yDAAyD;CACrE,CAAC;AAEF,MAAM,6BAA6B,GAAG;IAClC,QAAQ,EAAE,2EAA2E;IACrF,OAAO,EAAE,+DAA+D;CAC3E,CAAC;AAEF,MAAM,yBAAyB,GAAG,6BAA6B,CAAC,CAAE,uBAAuB,CAAE,CAAC,CAAC;AAC7F,MAAM,wBAAwB,GAAG,4BAA4B,CACzD,CAAE,gBAAgB,EAAE,uBAAuB,CAAE,EAC7C,EAAE,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,OAAO,EAAE;QACL,UAAU,EAAE,aAA8B;QAC1C,UAAU,EAAE,aAA8B;QAC1C,cAAc,EAAE,iBAAiB;QACjC,oBAAoB,EAAE,yBAAyB;QAC/C,uBAAuB,EAAE,wBAAwB;KACpD;IACD,KAAK,EAAE;QACH,4BAA4B,EAAE,CAAE,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAE;QAC9D,mCAAmC,EAAE,CAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAE,UAAU,CAAE,EAAE,CAAE;QAC7E,wCAAwC,EAAE,KAAK;QAC/C,8CAA8C,EAAE,CAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAE;QAChF,qCAAqC,EAAE,OAAO;QAC9C,wBAAwB,EAAE,OAAO;QACjC,4BAA4B,EAAE,OAAO;QACrC,gCAAgC,EAAE,OAAO;QACzC,sCAAsC,EAAE,OAAO;QAC/C,iCAAiC,EAAE,OAAO;QAC1C,6BAA6B,EAAE,OAAO;QACtC,qCAAqC,EAAE,OAAO;QAC9C,4BAA4B,EAAE,KAAK;QACnC,kCAAkC,EAAE,OAAO;QAC3C,yCAAyC,EAAE,KAAK;QAChD,sBAAsB,EAAE,OAAO;QAC/B,yCAAyC,EAAE,OAAO;QAClD,uCAAuC,EAAE,OAAO;QAChD,gCAAgC,EAAE,OAAO;QACzC,sCAAsC,EAAE,KAAK;QAE7C,4BAA4B,EAAE,CAAE,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAE;QAC9D,8CAA8C,EAAE,CAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAE;QAEhF,sCAAsC,EAAE,OAAO;QAE/C,0CAA0C,EAAE,CAAE,OAAO,EAAE,2BAA2B,CAAE;QAEpF,sCAAsC,EAAE,CAAE,OAAO,EAAE,uBAAuB,CAAE;QAC5E,6CAA6C,EAAE,CAAE,OAAO,EAAE,6BAA6B,CAAE;KAC5F;CACJ,CAAC"}
package/readme.md CHANGED
@@ -1,7 +1,77 @@
1
- # @enormora/eslint-config-zod
1
+ # `@enormora/eslint-config-zod`
2
2
 
3
- This version is a placeholder published only to claim the npm name `@enormora/eslint-config-zod` so a Trusted Publisher
4
- can subsequently be configured for it. It contains no real package content and is published already
5
- deprecated.
3
+ [![npm](https://img.shields.io/npm/v/@enormora/eslint-config-zod?label=)](https://www.npmjs.com/package/@enormora/eslint-config-zod)
6
4
 
7
- Workaround context: https://github.com/npm/cli/issues/8544
5
+ Config preset for [Zod](https://zod.dev). It enforces the usage of [Zod Mini](https://zod.dev/packages/mini) (`zod/mini`) together with [Zod core](https://zod.dev/packages/core) (`zod/v4/core`), and reports the regular Zod API as a problem.
6
+
7
+ Wraps [`eslint-plugin-zod-mini`](https://github.com/marcalexiei/eslint-plugin-zod) and [`eslint-plugin-zod-core`](https://github.com/marcalexiei/eslint-plugin-zod).
8
+
9
+ ## Install & Setup
10
+
11
+ Install `@enormora/eslint-config-zod` and the base preset package via npm:
12
+
13
+ ```bash
14
+ npm install --save-dev @enormora/eslint-config-base @enormora/eslint-config-zod
15
+ ```
16
+
17
+ Create an ESLint configuration file (e.g., `eslint.config.js`) in your project and add the base and Zod config to the configuration array:
18
+
19
+ ```javascript
20
+ import { baseConfig } from '@enormora/eslint-config-base';
21
+ import { zodConfig } from '@enormora/eslint-config-zod';
22
+
23
+ export default [
24
+ {
25
+ ignores: [ 'dist/**/*' ]
26
+ },
27
+ ...baseConfig,
28
+ zodConfig
29
+ ];
30
+ ```
31
+
32
+ ## Enforcing Zod Mini
33
+
34
+ Importing from the regular `zod` entry points is reported, while `zod/mini` and `zod/v4/core` are allowed:
35
+
36
+ ```javascript
37
+ import { z } from 'zod'; // error: Use zod/mini or zod/v4/core instead.
38
+ import { z } from 'zod/mini'; // ok
39
+ import { $ZodType } from 'zod/v4/core'; // ok
40
+ ```
41
+
42
+ ## Banned schemas
43
+
44
+ `z.enum()` and `z.nativeEnum()` are reported; use a union of `z.literal()` instead:
45
+
46
+ ```javascript
47
+ z.enum([ 'a', 'b' ]); // error
48
+ z.nativeEnum(Color); // error
49
+ z.union([ z.literal('a'), z.literal('b') ]); // ok
50
+ ```
51
+
52
+ A `z.array()` carrying a length check (`z.length()`, `z.minLength()`, `z.maxLength()`) is reported; a length-constrained array has a precise `z.tuple()` form:
53
+
54
+ ```javascript
55
+ z.array(z.string()).check(z.length(2)); // error
56
+ z.array(z.string()).check(z.minLength(1)); // error
57
+ z.tuple([ z.string(), z.string() ]); // ok
58
+ z.tuple([ z.string() ], z.string()); // ok: [string, ...string[]]
59
+ z.array(z.string()); // ok: unbounded array
60
+ ```
61
+
62
+ ## Readonly schemas
63
+
64
+ Mutable schemas (`z.object`, `z.strictObject`, `z.looseObject`, `z.array`, `z.tuple`, `z.record`, `z.map`, `z.set`) must be wrapped in `z.readonly()` so the inferred type is readonly, matching the readonly-everywhere TypeScript stance. The check is autofixable, and applying it at every level composes into a deeply readonly type (`z.readonly()` is shallow):
65
+
66
+ ```javascript
67
+ z.object({ a: z.string() }); // error
68
+ z.readonly(z.object({ a: z.string() })); // ok
69
+ z.readonly(z.object({ items: z.readonly(z.array(z.string())) })); // ok: deep
70
+ ```
71
+
72
+ Conversely, `z.readonly()` on an already-immutable schema (a primitive such as `z.string()`/`z.literal()`, or a doubled `z.readonly()`) is reported and removed by autofix, since it has no effect on the inferred type:
73
+
74
+ ```javascript
75
+ z.readonly(z.string()); // error → z.string()
76
+ z.string(); // ok
77
+ ```
@@ -0,0 +1,11 @@
1
+ import { builtinRules } from 'eslint/use-at-your-own-risk';
2
+ const noRestrictedImportsRule = builtinRules.get('no-restricted-imports');
3
+ export function createRestrictedImportsPlugin(ruleNames) {
4
+ const wrapperEntries = Object.fromEntries(ruleNames.map(function toRuleEntry(ruleName) {
5
+ return [ruleName, noRestrictedImportsRule];
6
+ }));
7
+ return {
8
+ rules: wrapperEntries
9
+ };
10
+ }
11
+ //# sourceMappingURL=restricted-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restricted-imports.js","sourceRoot":"","sources":["../../../../configs/rule-sets/restricted-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM3D,MAAM,uBAAuB,GAAG,YAAY,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE1E,MAAM,UAAU,6BAA6B,CAAC,SAA4B;IACtE,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CACrC,SAAS,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,QAAgB;QAC/C,OAAO,CAAE,QAAQ,EAAE,uBAAuB,CAAE,CAAC;IACjD,CAAC,CAAC,CACL,CAAC;IACF,OAAO;QACH,KAAK,EAAE,cAAc;KACxB,CAAC;AACN,CAAC"}
package/sbom.cdx.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
3
+ "bomFormat": "CycloneDX",
4
+ "specVersion": "1.6",
5
+ "version": 1,
6
+ "metadata": {
7
+ "tools": {
8
+ "components": [
9
+ {
10
+ "type": "application",
11
+ "name": "packtory",
12
+ "version": "0.0.67"
13
+ }
14
+ ]
15
+ },
16
+ "component": {
17
+ "type": "library",
18
+ "name": "@enormora/eslint-config-zod",
19
+ "version": "0.0.3",
20
+ "bom-ref": "pkg:npm/@enormora/eslint-config-zod@0.0.3",
21
+ "purl": "pkg:npm/@enormora/eslint-config-zod@0.0.3"
22
+ }
23
+ },
24
+ "components": [
25
+ {
26
+ "type": "library",
27
+ "name": "@enormora/eslint-config-base",
28
+ "version": "0.0.52",
29
+ "bom-ref": "pkg:npm/@enormora/eslint-config-base@0.0.52",
30
+ "scope": "optional",
31
+ "licenses": [
32
+ {
33
+ "expression": "MIT"
34
+ }
35
+ ],
36
+ "purl": "pkg:npm/@enormora/eslint-config-base@0.0.52"
37
+ },
38
+ {
39
+ "type": "library",
40
+ "name": "@typescript-eslint/utils",
41
+ "version": "8.64.0",
42
+ "bom-ref": "pkg:npm/@typescript-eslint/utils@8.64.0",
43
+ "scope": "required",
44
+ "licenses": [
45
+ {
46
+ "expression": "MIT"
47
+ }
48
+ ],
49
+ "purl": "pkg:npm/@typescript-eslint/utils@8.64.0"
50
+ },
51
+ {
52
+ "type": "library",
53
+ "name": "eslint-plugin-zod-core",
54
+ "version": "1.0.8",
55
+ "bom-ref": "pkg:npm/eslint-plugin-zod-core@1.0.8",
56
+ "scope": "required",
57
+ "licenses": [
58
+ {
59
+ "expression": "MIT"
60
+ }
61
+ ],
62
+ "purl": "pkg:npm/eslint-plugin-zod-core@1.0.8"
63
+ },
64
+ {
65
+ "type": "library",
66
+ "name": "eslint-plugin-zod-mini",
67
+ "version": "1.5.0",
68
+ "bom-ref": "pkg:npm/eslint-plugin-zod-mini@1.5.0",
69
+ "scope": "required",
70
+ "licenses": [
71
+ {
72
+ "expression": "MIT"
73
+ }
74
+ ],
75
+ "purl": "pkg:npm/eslint-plugin-zod-mini@1.5.0"
76
+ },
77
+ {
78
+ "type": "library",
79
+ "name": "eslint",
80
+ "version": "^10.0.0",
81
+ "bom-ref": "pkg:npm/eslint@%5E10.0.0",
82
+ "scope": "optional",
83
+ "licenses": [
84
+ {
85
+ "expression": "MIT"
86
+ }
87
+ ],
88
+ "purl": "pkg:npm/eslint@%5E10.0.0"
89
+ }
90
+ ],
91
+ "dependencies": [
92
+ {
93
+ "ref": "pkg:npm/@enormora/eslint-config-base@0.0.52"
94
+ },
95
+ {
96
+ "ref": "pkg:npm/@enormora/eslint-config-zod@0.0.3",
97
+ "dependsOn": [
98
+ "pkg:npm/@enormora/eslint-config-base@0.0.52",
99
+ "pkg:npm/@typescript-eslint/utils@8.64.0",
100
+ "pkg:npm/eslint-plugin-zod-core@1.0.8",
101
+ "pkg:npm/eslint-plugin-zod-mini@1.5.0",
102
+ "pkg:npm/eslint@%5E10.0.0"
103
+ ]
104
+ },
105
+ {
106
+ "ref": "pkg:npm/@typescript-eslint/utils@8.64.0"
107
+ },
108
+ {
109
+ "ref": "pkg:npm/eslint-plugin-zod-core@1.0.8"
110
+ },
111
+ {
112
+ "ref": "pkg:npm/eslint-plugin-zod-mini@1.5.0"
113
+ },
114
+ {
115
+ "ref": "pkg:npm/eslint@%5E10.0.0"
116
+ }
117
+ ]
118
+ }