@eventcatalog/linter 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -27
- package/dist/cli/index.js +22 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +155 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js +4 -0
- package/dist/reporters/index.js.map +1 -1
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/index.js +1 -0
- package/dist/scanner/index.js.map +1 -1
- package/dist/schemas/data-store.d.ts +348 -0
- package/dist/schemas/data-store.d.ts.map +1 -0
- package/dist/schemas/data-store.js +17 -0
- package/dist/schemas/data-store.js.map +1 -0
- package/dist/schemas/index.d.ts +386 -3
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/service.d.ts +36 -0
- package/dist/schemas/service.d.ts.map +1 -1
- package/dist/schemas/service.js +2 -0
- package/dist/schemas/service.js.map +1 -1
- package/dist/schemas/team.js +1 -1
- package/dist/schemas/team.js.map +1 -1
- package/dist/schemas/user.d.ts +3 -3
- package/dist/schemas/user.js +2 -2
- package/dist/schemas/user.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/validators/best-practices-validator.d.ts +4 -0
- package/dist/validators/best-practices-validator.d.ts.map +1 -0
- package/dist/validators/best-practices-validator.js +36 -0
- package/dist/validators/best-practices-validator.js.map +1 -0
- package/dist/validators/index.d.ts +1 -0
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js +4 -1
- package/dist/validators/index.js.map +1 -1
- package/dist/validators/reference-validator.d.ts.map +1 -1
- package/dist/validators/reference-validator.js +18 -2
- package/dist/validators/reference-validator.js.map +1 -1
- package/dist/validators/schema-validator.d.ts.map +1 -1
- package/dist/validators/schema-validator.js +12 -0
- package/dist/validators/schema-validator.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,9 @@ A comprehensive linter for EventCatalog that validates frontmatter schemas and r
|
|
|
10
10
|
- **📋 Schema Validation**: Validates all resource frontmatter against defined schemas using Zod
|
|
11
11
|
- **🔗 Reference Validation**: Ensures all referenced resources (services, events, domains, etc.) actually exist
|
|
12
12
|
- **📦 Semver Version Support**: Supports semantic versions, ranges (`^1.0.0`, `~1.2.0`), x-patterns (`0.0.x`), and `latest`
|
|
13
|
+
- **⚙️ Configurable Rules**: Optional `.eventcatalogrc.js` config file for customizing rule severity and behavior
|
|
14
|
+
- **🚫 Ignore Patterns**: Skip validation for specific file patterns (archived, drafts, etc.)
|
|
15
|
+
- **🎯 Rule Overrides**: Apply different rules to different file patterns for flexible team workflows
|
|
13
16
|
- **🎯 Comprehensive Coverage**: Supports all EventCatalog resource types
|
|
14
17
|
- **⚡ Fast Performance**: Efficiently scans large catalogs
|
|
15
18
|
- **🎨 ESLint-Inspired Output**: Clean, file-grouped error reporting with severity levels
|
|
@@ -31,16 +34,16 @@ A comprehensive linter for EventCatalog that validates frontmatter schemas and r
|
|
|
31
34
|
|
|
32
35
|
## 📦 Installation
|
|
33
36
|
|
|
34
|
-
###
|
|
37
|
+
### Use with npx (Recommended)
|
|
35
38
|
|
|
36
39
|
```bash
|
|
37
|
-
|
|
40
|
+
npx @eventcatalog/linter
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
###
|
|
43
|
+
### Global Installation
|
|
41
44
|
|
|
42
45
|
```bash
|
|
43
|
-
|
|
46
|
+
npm install -g @eventcatalog/linter
|
|
44
47
|
```
|
|
45
48
|
|
|
46
49
|
### Add to your project
|
|
@@ -49,6 +52,30 @@ npx @eventcatalog/linter
|
|
|
49
52
|
npm install --save-dev @eventcatalog/linter
|
|
50
53
|
```
|
|
51
54
|
|
|
55
|
+
### Quick Start
|
|
56
|
+
|
|
57
|
+
1. **Install and run**: Start linting immediately with npx
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx @eventcatalog/linter
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. **Add configuration**: Create a `.eventcatalogrc.js` file to customize rules
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
module.exports = {
|
|
67
|
+
rules: {
|
|
68
|
+
'best-practices/summary-required': 'warn',
|
|
69
|
+
'refs/owner-exists': 'error',
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
3. **Integrate with CI/CD**: Add to your GitHub Actions or GitLab CI
|
|
75
|
+
```yaml
|
|
76
|
+
- run: npx @eventcatalog/linter
|
|
77
|
+
```
|
|
78
|
+
|
|
52
79
|
## 🛠️ Usage
|
|
53
80
|
|
|
54
81
|
### Basic Usage
|
|
@@ -91,8 +118,8 @@ Add to your `package.json` scripts:
|
|
|
91
118
|
```json
|
|
92
119
|
{
|
|
93
120
|
"scripts": {
|
|
94
|
-
"lint:eventcatalog": "
|
|
95
|
-
"lint:eventcatalog:verbose": "
|
|
121
|
+
"lint:eventcatalog": "eventcatalog-linter",
|
|
122
|
+
"lint:eventcatalog:verbose": "eventcatalog-linter --verbose"
|
|
96
123
|
}
|
|
97
124
|
}
|
|
98
125
|
```
|
|
@@ -126,6 +153,161 @@ eventcatalog-lint:
|
|
|
126
153
|
- npx @eventcatalog/linter
|
|
127
154
|
```
|
|
128
155
|
|
|
156
|
+
## ⚙️ Configuration
|
|
157
|
+
|
|
158
|
+
The EventCatalog Linter supports optional configuration through a `.eventcatalogrc.js` file in your catalog root directory. This allows you to:
|
|
159
|
+
|
|
160
|
+
- Turn rules on/off
|
|
161
|
+
- Configure rule severity levels (error, warn, off)
|
|
162
|
+
- Ignore specific file patterns
|
|
163
|
+
- Override rules for specific file patterns
|
|
164
|
+
|
|
165
|
+
### Configuration File
|
|
166
|
+
|
|
167
|
+
Create a `.eventcatalogrc.js` file in your EventCatalog root directory:
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
// .eventcatalogrc.js
|
|
171
|
+
module.exports = {
|
|
172
|
+
rules: {
|
|
173
|
+
// Schema validation rules
|
|
174
|
+
'schema/required-fields': 'error',
|
|
175
|
+
'schema/valid-semver': 'error',
|
|
176
|
+
'schema/valid-email': 'warn',
|
|
177
|
+
|
|
178
|
+
// Reference validation rules
|
|
179
|
+
'refs/owner-exists': 'error',
|
|
180
|
+
'refs/valid-version-range': 'error',
|
|
181
|
+
|
|
182
|
+
// Best practice rules
|
|
183
|
+
'best-practices/summary-required': 'warn',
|
|
184
|
+
'best-practices/owner-required': 'error',
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
// Ignore certain paths
|
|
188
|
+
ignorePatterns: ['**/archived/**', '**/drafts/**'],
|
|
189
|
+
|
|
190
|
+
// Override rules for specific file patterns
|
|
191
|
+
overrides: [
|
|
192
|
+
{
|
|
193
|
+
files: ['**/experimental/**'],
|
|
194
|
+
rules: {
|
|
195
|
+
'best-practices/owner-required': 'off',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Rule Severity Levels
|
|
203
|
+
|
|
204
|
+
- **`'error'`** - Causes the linter to exit with error code 1
|
|
205
|
+
- **`'warn'`** - Shows warnings but allows the linter to pass (unless `--fail-on-warning` is used)
|
|
206
|
+
- **`'off'`** - Disables the rule completely
|
|
207
|
+
|
|
208
|
+
### Available Rules
|
|
209
|
+
|
|
210
|
+
| Rule Name | Description | Accepted Values | Default |
|
|
211
|
+
| --------------------------------- | -------------------------------------------------------------------------- | ---------------------- | -------------- |
|
|
212
|
+
| **Schema Validation Rules** |
|
|
213
|
+
| `schema/required-fields` | Validates that required fields are present in frontmatter | `error`, `warn`, `off` | `error` |
|
|
214
|
+
| `schema/valid-type` | Validates that field types are correct (strings, arrays, objects) | `error`, `warn`, `off` | `error` |
|
|
215
|
+
| `schema/valid-semver` | Validates semantic version format (1.0.0, 2.1.3-beta) | `error`, `warn`, `off` | `error` |
|
|
216
|
+
| `schema/valid-email` | Validates email address format in user frontmatter | `error`, `warn`, `off` | `error` |
|
|
217
|
+
| `schema/validation-error` | General schema validation errors | `error`, `warn`, `off` | `error` |
|
|
218
|
+
| **Reference Validation Rules** |
|
|
219
|
+
| `refs/owner-exists` | Ensures referenced owners (users/teams) exist | `error`, `warn`, `off` | `error` |
|
|
220
|
+
| `refs/valid-version-range` | Validates version references and patterns | `error`, `warn`, `off` | `error` |
|
|
221
|
+
| `refs/resource-exists` | Ensures referenced resources exist (always enabled for critical resources) | Always enabled | Always enabled |
|
|
222
|
+
| **Best Practice Rules** |
|
|
223
|
+
| `best-practices/summary-required` | Requires summary field for better documentation | `error`, `warn`, `off` | `error` |
|
|
224
|
+
| `best-practices/owner-required` | Requires at least one owner for accountability | `error`, `warn`, `off` | `error` |
|
|
225
|
+
|
|
226
|
+
**Note**: Core resource reference validation (services, domains, entities) is always enabled and cannot be disabled, ensuring referential integrity of your EventCatalog.
|
|
227
|
+
|
|
228
|
+
### Configuration Examples
|
|
229
|
+
|
|
230
|
+
#### Relaxed Configuration for Development
|
|
231
|
+
|
|
232
|
+
```javascript
|
|
233
|
+
module.exports = {
|
|
234
|
+
rules: {
|
|
235
|
+
'best-practices/summary-required': 'warn',
|
|
236
|
+
'best-practices/owner-required': 'warn',
|
|
237
|
+
'refs/owner-exists': 'warn',
|
|
238
|
+
},
|
|
239
|
+
ignorePatterns: ['**/drafts/**', '**/experimental/**'],
|
|
240
|
+
};
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Strict Configuration for Production
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
module.exports = {
|
|
247
|
+
rules: {
|
|
248
|
+
'schema/required-fields': 'error',
|
|
249
|
+
'refs/owner-exists': 'error',
|
|
250
|
+
'best-practices/summary-required': 'error',
|
|
251
|
+
'best-practices/owner-required': 'error',
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### Team-Specific Overrides
|
|
257
|
+
|
|
258
|
+
```javascript
|
|
259
|
+
module.exports = {
|
|
260
|
+
rules: {
|
|
261
|
+
'best-practices/owner-required': 'error',
|
|
262
|
+
'best-practices/summary-required': 'error',
|
|
263
|
+
},
|
|
264
|
+
overrides: [
|
|
265
|
+
{
|
|
266
|
+
files: ['**/legacy/**'],
|
|
267
|
+
rules: {
|
|
268
|
+
'best-practices/owner-required': 'warn',
|
|
269
|
+
'best-practices/summary-required': 'off',
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
files: ['**/critical/**'],
|
|
274
|
+
rules: {
|
|
275
|
+
'best-practices/summary-required': 'error',
|
|
276
|
+
'refs/owner-exists': 'error',
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Using with CI/CD
|
|
284
|
+
|
|
285
|
+
The configuration file allows you to have different validation rules for different environments:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Development - warnings allowed
|
|
289
|
+
npx @eventcatalog/linter
|
|
290
|
+
|
|
291
|
+
# Production - fail on warnings
|
|
292
|
+
npx @eventcatalog/linter --fail-on-warning
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Using with CI/CD
|
|
296
|
+
|
|
297
|
+
The configuration file allows you to have different validation rules for different environments:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Development - warnings allowed
|
|
301
|
+
npx @eventcatalog/linter
|
|
302
|
+
|
|
303
|
+
# Production - fail on warnings
|
|
304
|
+
npx @eventcatalog/linter --fail-on-warning
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Default Behavior
|
|
308
|
+
|
|
309
|
+
If no `.eventcatalogrc.js` file is found, the linter uses default rules where all validations are set to `'error'`. This ensures strict validation out of the box, making it easy to get started with quality documentation practices.
|
|
310
|
+
|
|
129
311
|
## ✅ What It Validates
|
|
130
312
|
|
|
131
313
|
### Frontmatter Schema Validation
|
|
@@ -204,18 +386,18 @@ $ eventcatalog-linter
|
|
|
204
386
|
$ eventcatalog-linter
|
|
205
387
|
|
|
206
388
|
services/user-service/index.mdx
|
|
207
|
-
✖ error version: Invalid semantic version format [version] (
|
|
208
|
-
⚠ warning
|
|
389
|
+
✖ error version: Invalid semantic version format [version] (schema/valid-semver)
|
|
390
|
+
⚠ warning Summary is required for better documentation [summary] (best-practices/summary-required)
|
|
209
391
|
|
|
210
392
|
✖ 2 problems
|
|
211
393
|
|
|
212
394
|
domains/sales/index.mdx
|
|
213
|
-
✖ error Referenced service "order-service" does not exist [services] (
|
|
395
|
+
✖ error Referenced service "order-service" does not exist [services] (refs/resource-exists)
|
|
214
396
|
|
|
215
397
|
✖ 1 problem
|
|
216
398
|
|
|
217
399
|
flows/user-registration/index.mdx
|
|
218
|
-
✖ error Referenced service "notification-service" (version: 2.0.0) does not exist [steps[1].service] (
|
|
400
|
+
✖ error Referenced service "notification-service" (version: 2.0.0) does not exist [steps[1].service] (refs/valid-version-range)
|
|
219
401
|
|
|
220
402
|
✖ 1 problem
|
|
221
403
|
|
|
@@ -229,12 +411,12 @@ flows/user-registration/index.mdx
|
|
|
229
411
|
$ eventcatalog-linter --verbose
|
|
230
412
|
|
|
231
413
|
services/user-service/index.mdx
|
|
232
|
-
✖ error version: Invalid semantic version format [version] (
|
|
414
|
+
✖ error version: Invalid semantic version format [version] (schema/valid-semver)
|
|
233
415
|
|
|
234
416
|
✖ 1 problem
|
|
235
417
|
|
|
236
418
|
domains/sales/index.mdx
|
|
237
|
-
✖ error Referenced service "order-service" does not exist [services] (
|
|
419
|
+
✖ error Referenced service "order-service" does not exist [services] (refs/resource-exists)
|
|
238
420
|
|
|
239
421
|
✖ 1 problem
|
|
240
422
|
|
|
@@ -442,32 +624,43 @@ email: invalid-email # Should be john@example.com
|
|
|
442
624
|
---
|
|
443
625
|
```
|
|
444
626
|
|
|
445
|
-
## 🏷️ Error Codes
|
|
627
|
+
## 🏷️ Rule Names and Error Codes
|
|
628
|
+
|
|
629
|
+
The linter provides descriptive rule names in parentheses to help identify and fix issues quickly. Each error shows the specific rule that was violated:
|
|
446
630
|
|
|
447
|
-
|
|
631
|
+
### Schema Validation Rules
|
|
448
632
|
|
|
449
|
-
|
|
633
|
+
- `(schema/required-fields)` - Required field is missing
|
|
634
|
+
- `(schema/valid-type)` - Field has wrong data type
|
|
635
|
+
- `(schema/valid-semver)` - Invalid semantic version format
|
|
636
|
+
- `(schema/valid-email)` - Invalid email address format
|
|
637
|
+
- `(schema/validation-error)` - General schema validation error
|
|
450
638
|
|
|
451
|
-
|
|
452
|
-
- `@eventcatalog/invalid-type` - Field has wrong data type
|
|
453
|
-
- `@eventcatalog/schema-validation` - General schema validation error
|
|
454
|
-
- `@eventcatalog/schema` - Schema-related validation error
|
|
639
|
+
### Reference Validation Rules
|
|
455
640
|
|
|
456
|
-
|
|
641
|
+
- `(refs/owner-exists)` - Referenced owner (user/team) doesn't exist
|
|
642
|
+
- `(refs/valid-version-range)` - Referenced version doesn't exist or invalid pattern
|
|
643
|
+
- `(refs/resource-exists)` - Referenced resource doesn't exist
|
|
457
644
|
|
|
458
|
-
|
|
645
|
+
### Best Practice Rules
|
|
646
|
+
|
|
647
|
+
- `(best-practices/summary-required)` - Summary field is missing
|
|
648
|
+
- `(best-practices/owner-required)` - At least one owner is required
|
|
459
649
|
|
|
460
650
|
### Parse Errors
|
|
461
651
|
|
|
462
|
-
-
|
|
652
|
+
- `(@eventcatalog/parse-error)` - YAML/frontmatter parsing error
|
|
463
653
|
|
|
464
|
-
### Example with
|
|
654
|
+
### Example with Rule Names
|
|
465
655
|
|
|
466
656
|
```bash
|
|
467
657
|
services/user-service/index.mdx
|
|
468
|
-
✖ error name:
|
|
469
|
-
✖ error version: Invalid semantic version format [version] (
|
|
470
|
-
✖ error Referenced
|
|
658
|
+
✖ error name: Expected string, but received undefined [name] (schema/valid-type)
|
|
659
|
+
✖ error version: Invalid semantic version format [version] (schema/valid-semver)
|
|
660
|
+
✖ error Referenced user/team "missing-owner" does not exist [owners] (refs/owner-exists)
|
|
661
|
+
✖ error Summary is required for better documentation [summary] (best-practices/summary-required)
|
|
662
|
+
|
|
663
|
+
✖ 4 problems
|
|
471
664
|
```
|
|
472
665
|
|
|
473
666
|
## ⚠️ Warnings Support
|
|
@@ -542,14 +735,17 @@ npm test schema-validator.test.ts
|
|
|
542
735
|
```
|
|
543
736
|
src/
|
|
544
737
|
├── cli/ # Command-line interface
|
|
738
|
+
├── config/ # Configuration loading and rule management
|
|
545
739
|
├── schemas/ # Zod validation schemas
|
|
546
740
|
├── scanner/ # File system scanning
|
|
547
741
|
├── parser/ # Frontmatter parsing
|
|
548
|
-
├── validators/ # Validation logic
|
|
742
|
+
├── validators/ # Validation logic (schema, reference, best practices)
|
|
549
743
|
├── reporters/ # Error reporting
|
|
550
744
|
└── types/ # TypeScript definitions
|
|
551
745
|
|
|
552
746
|
tests/
|
|
747
|
+
├── config.test.ts
|
|
748
|
+
├── cli-integration.test.ts
|
|
553
749
|
├── schema-validator.test.ts
|
|
554
750
|
├── reference-validator.test.ts
|
|
555
751
|
├── scanner.test.ts
|
package/dist/cli/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const scanner_1 = require("../scanner");
|
|
|
12
12
|
const parser_1 = require("../parser");
|
|
13
13
|
const validators_1 = require("../validators");
|
|
14
14
|
const reporters_1 = require("../reporters");
|
|
15
|
+
const config_1 = require("../config");
|
|
15
16
|
const program = new commander_1.Command();
|
|
16
17
|
program
|
|
17
18
|
.name('eventcatalog-linter')
|
|
@@ -22,10 +23,21 @@ program
|
|
|
22
23
|
.option('--fail-on-warning', 'Exit with non-zero code on warnings', false)
|
|
23
24
|
.action(async (directory, options) => {
|
|
24
25
|
const rootDir = path_1.default.resolve(directory);
|
|
25
|
-
const spinner = (0, ora_1.default)('
|
|
26
|
+
const spinner = (0, ora_1.default)('Loading configuration...').start();
|
|
26
27
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// Load configuration
|
|
29
|
+
const config = (0, config_1.loadConfig)(rootDir);
|
|
30
|
+
spinner.text = 'Scanning EventCatalog files...';
|
|
31
|
+
const allFiles = await (0, scanner_1.scanCatalogFiles)(rootDir);
|
|
32
|
+
// Filter out ignored files
|
|
33
|
+
const files = allFiles.filter((file) => !(0, config_1.shouldIgnoreFile)(file.relativePath, config.ignorePatterns || []));
|
|
34
|
+
const ignoredCount = allFiles.length - files.length;
|
|
35
|
+
if (ignoredCount > 0) {
|
|
36
|
+
spinner.text = `Found ${files.length} catalog files (${ignoredCount} ignored)`;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
spinner.text = `Found ${files.length} catalog files`;
|
|
40
|
+
}
|
|
29
41
|
if (files.length === 0) {
|
|
30
42
|
spinner.warn('No EventCatalog files found');
|
|
31
43
|
process.exit(0);
|
|
@@ -33,7 +45,13 @@ program
|
|
|
33
45
|
spinner.text = 'Parsing frontmatter...';
|
|
34
46
|
const { parsed, errors: parseErrors } = await (0, parser_1.parseAllFiles)(files);
|
|
35
47
|
spinner.text = 'Validating catalog...';
|
|
36
|
-
const
|
|
48
|
+
const rawValidationErrors = (0, validators_1.validateCatalog)(parsed);
|
|
49
|
+
// Apply rule configuration to each file's errors
|
|
50
|
+
const validationErrors = parsed.flatMap((parsedFile) => {
|
|
51
|
+
const fileErrors = rawValidationErrors.filter((error) => error.file === parsedFile.file.relativePath);
|
|
52
|
+
const effectiveRules = (0, config_1.getEffectiveRules)(parsedFile.file.relativePath, config);
|
|
53
|
+
return (0, config_1.applyRuleSeverity)(fileErrors, effectiveRules);
|
|
54
|
+
});
|
|
37
55
|
spinner.stop();
|
|
38
56
|
const summary = (0, reporters_1.reportErrors)(validationErrors, parseErrors, options.verbose);
|
|
39
57
|
// Show scan summary
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AACtB,gDAAwB;AACxB,wCAA8C;AAC9C,sCAA0C;AAC1C,8CAAgD;AAChD,4CAA4C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AACtB,gDAAwB;AACxB,wCAA8C;AAC9C,sCAA0C;AAC1C,8CAAgD;AAChD,4CAA4C;AAE5C,sCAA+F;AAE/F,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,qBAAqB,CAAC;KAC3B,WAAW,CAAC,iEAAiE,CAAC;KAC9E,OAAO,CAAC,OAAO,CAAC;KAChB,QAAQ,CAAC,aAAa,EAAE,gCAAgC,EAAE,GAAG,CAAC;KAC9D,MAAM,CAAC,eAAe,EAAE,qBAAqB,EAAE,KAAK,CAAC;KACrD,MAAM,CAAC,mBAAmB,EAAE,qCAAqC,EAAE,KAAK,CAAC;KACzE,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,OAA+B,EAAE,EAAE;IACnE,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,0BAA0B,CAAC,CAAC,KAAK,EAAE,CAAC;IAExD,IAAI,CAAC;QACH,qBAAqB;QACrB,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,CAAC;QAEnC,OAAO,CAAC,IAAI,GAAG,gCAAgC,CAAC;QAChD,MAAM,QAA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IAAA,0BAAiB,EAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAC/E,OAAO,IAAA,0BAAiB,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,EAAE,CAAC;QAEf,MAAM,OAAO,GAAG,IAAA,wBAAY,EAAC,gBAAgB,EAAE,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE7E,oBAAoB;QACpB,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,OAAO,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACpF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ValidationError } from '../types';
|
|
2
|
+
export type RuleSeverity = 'error' | 'warn' | 'off';
|
|
3
|
+
export interface RuleConfig {
|
|
4
|
+
severity: RuleSeverity;
|
|
5
|
+
options?: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface ConfigOverride {
|
|
8
|
+
files: string[];
|
|
9
|
+
rules: Record<string, RuleSeverity | [RuleSeverity, Record<string, any>]>;
|
|
10
|
+
}
|
|
11
|
+
export interface LinterConfig {
|
|
12
|
+
rules: Record<string, RuleSeverity | [RuleSeverity, Record<string, any>]>;
|
|
13
|
+
ignorePatterns?: string[];
|
|
14
|
+
overrides?: ConfigOverride[];
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_RULES: Record<string, RuleSeverity>;
|
|
17
|
+
export declare const loadConfig: (rootDir: string) => LinterConfig;
|
|
18
|
+
export declare const parseRuleConfig: (rule: RuleSeverity | [RuleSeverity, Record<string, any>]) => RuleConfig;
|
|
19
|
+
export declare const shouldIgnoreFile: (filePath: string, ignorePatterns: string[]) => boolean;
|
|
20
|
+
export declare const getEffectiveRules: (filePath: string, config: LinterConfig) => Record<string, RuleConfig>;
|
|
21
|
+
export declare const applyRuleSeverity: (errors: ValidationError[], rules: Record<string, RuleConfig>) => ValidationError[];
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;CAC3E;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAYtD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,KAAG,YAiC5C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAG,UAW1F,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,EAAE,gBAAgB,MAAM,EAAE,KAAG,OAgB7E,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,EAAE,QAAQ,YAAY,KAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAwBnG,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,EAAE,EAAE,OAAO,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,KAAG,eAAe,EAmB/G,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.applyRuleSeverity = exports.getEffectiveRules = exports.shouldIgnoreFile = exports.parseRuleConfig = exports.loadConfig = exports.DEFAULT_RULES = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
exports.DEFAULT_RULES = {
|
|
10
|
+
'schema/required-fields': 'error',
|
|
11
|
+
'schema/valid-semver': 'error',
|
|
12
|
+
'schema/valid-email': 'error',
|
|
13
|
+
'refs/owner-exists': 'error',
|
|
14
|
+
'refs/valid-version-range': 'error',
|
|
15
|
+
'best-practices/summary-required': 'error',
|
|
16
|
+
'best-practices/owner-required': 'error',
|
|
17
|
+
'naming/service-id-format': 'error',
|
|
18
|
+
'naming/event-id-format': 'error',
|
|
19
|
+
'versions/consistent-format': 'error',
|
|
20
|
+
'versions/no-deprecated': 'error',
|
|
21
|
+
};
|
|
22
|
+
const loadConfig = (rootDir) => {
|
|
23
|
+
const configPath = path_1.default.join(rootDir, '.eventcatalogrc.js');
|
|
24
|
+
if (!fs_1.default.existsSync(configPath)) {
|
|
25
|
+
// Return default config if no config file exists
|
|
26
|
+
return {
|
|
27
|
+
rules: exports.DEFAULT_RULES,
|
|
28
|
+
ignorePatterns: [],
|
|
29
|
+
overrides: [],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
// Clear module cache to ensure fresh load
|
|
34
|
+
delete require.cache[require.resolve(configPath)];
|
|
35
|
+
const config = require(configPath);
|
|
36
|
+
// Merge with defaults
|
|
37
|
+
const mergedConfig = {
|
|
38
|
+
rules: { ...exports.DEFAULT_RULES, ...config.rules },
|
|
39
|
+
ignorePatterns: config.ignorePatterns || [],
|
|
40
|
+
overrides: config.overrides || [],
|
|
41
|
+
};
|
|
42
|
+
return mergedConfig;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.warn(`Warning: Could not load .eventcatalogrc.js: ${error instanceof Error ? error.message : String(error)}`);
|
|
46
|
+
return {
|
|
47
|
+
rules: exports.DEFAULT_RULES,
|
|
48
|
+
ignorePatterns: [],
|
|
49
|
+
overrides: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.loadConfig = loadConfig;
|
|
54
|
+
const parseRuleConfig = (rule) => {
|
|
55
|
+
if (Array.isArray(rule)) {
|
|
56
|
+
return {
|
|
57
|
+
severity: rule[0],
|
|
58
|
+
options: rule[1],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
severity: rule,
|
|
63
|
+
options: {},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.parseRuleConfig = parseRuleConfig;
|
|
67
|
+
const shouldIgnoreFile = (filePath, ignorePatterns) => {
|
|
68
|
+
if (!ignorePatterns || ignorePatterns.length === 0) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
72
|
+
for (const pattern of ignorePatterns) {
|
|
73
|
+
// Simple glob matching for now
|
|
74
|
+
const regex = new RegExp(pattern.replace(/\*\*/g, '.*').replace(/\*/g, '[^/]*'));
|
|
75
|
+
if (regex.test(normalizedPath)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
};
|
|
81
|
+
exports.shouldIgnoreFile = shouldIgnoreFile;
|
|
82
|
+
const getEffectiveRules = (filePath, config) => {
|
|
83
|
+
let effectiveRules = { ...config.rules };
|
|
84
|
+
// Apply overrides
|
|
85
|
+
if (config.overrides) {
|
|
86
|
+
for (const override of config.overrides) {
|
|
87
|
+
const matchesFile = override.files.some((pattern) => {
|
|
88
|
+
const regex = new RegExp(pattern.replace(/\*\*/g, '.*').replace(/\*/g, '[^/]*'));
|
|
89
|
+
return regex.test(filePath);
|
|
90
|
+
});
|
|
91
|
+
if (matchesFile) {
|
|
92
|
+
effectiveRules = { ...effectiveRules, ...override.rules };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Parse rules into RuleConfig objects
|
|
97
|
+
const parsedRules = {};
|
|
98
|
+
for (const [ruleName, ruleValue] of Object.entries(effectiveRules)) {
|
|
99
|
+
parsedRules[ruleName] = (0, exports.parseRuleConfig)(ruleValue);
|
|
100
|
+
}
|
|
101
|
+
return parsedRules;
|
|
102
|
+
};
|
|
103
|
+
exports.getEffectiveRules = getEffectiveRules;
|
|
104
|
+
const applyRuleSeverity = (errors, rules) => {
|
|
105
|
+
const result = [];
|
|
106
|
+
for (const error of errors) {
|
|
107
|
+
// Map validation errors to rule names
|
|
108
|
+
const ruleName = mapErrorToRuleName(error);
|
|
109
|
+
const rule = rules[ruleName];
|
|
110
|
+
if (!rule || rule.severity === 'off') {
|
|
111
|
+
continue; // Skip disabled rules
|
|
112
|
+
}
|
|
113
|
+
result.push({
|
|
114
|
+
...error,
|
|
115
|
+
severity: rule.severity === 'warn' ? 'warning' : 'error',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
exports.applyRuleSeverity = applyRuleSeverity;
|
|
121
|
+
const mapErrorToRuleName = (error) => {
|
|
122
|
+
// Map validation errors to rule names based on the error type and content
|
|
123
|
+
if (error.type === 'schema') {
|
|
124
|
+
// Check field-specific rules first
|
|
125
|
+
if (error.field === 'summary') {
|
|
126
|
+
return 'best-practices/summary-required';
|
|
127
|
+
}
|
|
128
|
+
if (error.field === 'owners') {
|
|
129
|
+
return 'best-practices/owner-required';
|
|
130
|
+
}
|
|
131
|
+
// Check message content for specific validation types
|
|
132
|
+
if (error.message.includes('email') || error.message.includes('Invalid email')) {
|
|
133
|
+
return 'schema/valid-email';
|
|
134
|
+
}
|
|
135
|
+
if (error.message.includes('version') || error.message.includes('semantic')) {
|
|
136
|
+
return 'schema/valid-semver';
|
|
137
|
+
}
|
|
138
|
+
if (error.message.includes('Required') || error.message.includes('Expected')) {
|
|
139
|
+
return 'schema/required-fields';
|
|
140
|
+
}
|
|
141
|
+
return 'schema/required-fields';
|
|
142
|
+
}
|
|
143
|
+
if (error.type === 'reference') {
|
|
144
|
+
if (error.message.includes('user') || error.message.includes('team')) {
|
|
145
|
+
return 'refs/owner-exists';
|
|
146
|
+
}
|
|
147
|
+
if (error.message.includes('version')) {
|
|
148
|
+
return 'refs/valid-version-range';
|
|
149
|
+
}
|
|
150
|
+
// Service, domain, entity, and other references are always validated and not configurable
|
|
151
|
+
return 'schema/required-fields'; // Map to a default rule so they remain as errors
|
|
152
|
+
}
|
|
153
|
+
return 'schema/required-fields';
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAqBX,QAAA,aAAa,GAAiC;IACzD,wBAAwB,EAAE,OAAO;IACjC,qBAAqB,EAAE,OAAO;IAC9B,oBAAoB,EAAE,OAAO;IAC7B,mBAAmB,EAAE,OAAO;IAC5B,0BAA0B,EAAE,OAAO;IACnC,iCAAiC,EAAE,OAAO;IAC1C,+BAA+B,EAAE,OAAO;IACxC,0BAA0B,EAAE,OAAO;IACnC,wBAAwB,EAAE,OAAO;IACjC,4BAA4B,EAAE,OAAO;IACrC,wBAAwB,EAAE,OAAO;CAClC,CAAC;AAEK,MAAM,UAAU,GAAG,CAAC,OAAe,EAAgB,EAAE;IAC1D,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAE5D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,iDAAiD;QACjD,OAAO;YACL,KAAK,EAAE,qBAAa;YACpB,cAAc,EAAE,EAAE;YAClB,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,0CAA0C;QAC1C,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QAEnC,sBAAsB;QACtB,MAAM,YAAY,GAAiB;YACjC,KAAK,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AC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5E,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7E,OAAO,wBAAwB,CAAC;QAClC,CAAC;QAED,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,OAAO,mBAAmB,CAAC;QAC7B,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,OAAO,0BAA0B,CAAC;QACpC,CAAC;QACD,0FAA0F;QAC1F,OAAO,wBAAwB,CAAC,CAAC,iDAAiD;IACpF,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./scanner"), exports);
|
|
|
20
20
|
__exportStar(require("./parser"), exports);
|
|
21
21
|
__exportStar(require("./validators"), exports);
|
|
22
22
|
__exportStar(require("./reporters"), exports);
|
|
23
|
+
__exportStar(require("./config"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,+CAA6B;AAC7B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,eAAe,EAAE,eAAc,OAAc,KAAG,MAelF,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,eAAe,EAAE,eAAc,OAAc,KAAG,MAelF,CAAC;AAsBF,eAAO,MAAM,gBAAgB,GAAI,OAAO,UAAU,EAAE,eAAc,OAAc,KAAG,MAWlF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAW1F,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,kBAAkB,eAAe,EAAE,EACnC,aAAa,UAAU,EAAE,EACzB,UAAS,OAAe,KACvB,aAyFF,CAAC"}
|
package/dist/reporters/index.js
CHANGED
|
@@ -21,6 +21,10 @@ const formatError = (error, showFilename = true) => {
|
|
|
21
21
|
};
|
|
22
22
|
exports.formatError = formatError;
|
|
23
23
|
const getErrorCode = (error) => {
|
|
24
|
+
if (error.rule) {
|
|
25
|
+
return `(${error.rule})`;
|
|
26
|
+
}
|
|
27
|
+
// Fallback to generic error codes
|
|
24
28
|
if (error.type === 'schema') {
|
|
25
29
|
if (error.field) {
|
|
26
30
|
if (error.message.includes('Required'))
|