{"_id":"@umbrelladocs/rdformat-validator","_rev":"2-3e3b2aad3931a29005c7050ae129a1e0","name":"@umbrelladocs/rdformat-validator","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@umbrelladocs/rdformat-validator","version":"1.0.0","keywords":["reviewdog","validator","diagnostic","format","json","linter","cli","rdformat","validation","typescript","nodejs","code-quality","static-analysis","json-schema"],"author":{"url":"https://github.com/UmbrellaDocs/rdformat-validator","name":"Gaurav Nelson"},"license":"Apache-2.0","_id":"@umbrelladocs/rdformat-validator@1.0.0","maintainers":[{"name":"gaurav-nelson","email":"gaurav.nelson@gmail.com"}],"homepage":"https://github.com/UmbrellaDocs/rdformat-validator#readme","bugs":{"url":"https://github.com/UmbrellaDocs/rdformat-validator/issues"},"bin":{"rdformat-validator":"bin/rdformat-validator.js"},"dist":{"shasum":"b6c5f02eac658c44b0aea974fd481120975d9a1f","tarball":"https://registry.npmjs.org/@umbrelladocs/rdformat-validator/-/rdformat-validator-1.0.0.tgz","fileCount":69,"integrity":"sha512-HRQI1QbbQJoVIlPhn/P30aW2fEyLj2gvZQt/Gbkae/dtCEeB9fEvWdpoI6GMY0eVRzg9KWL16I9Q7Awg3M77hA==","signatures":[{"sig":"MEUCIEAI7otC2tS6RS4ZhbcqCVKtGwXcdtarDNL02s2c8eSnAiEAw/gc/uarmD2MaaGmgeyf0Yu9AzAg+bA4wDxAufD586Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":542054},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/esm/index.js","engines":{"npm":">=6.0.0","node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","require":"./dist/index.js"}},"funding":{"url":"https://github.com/sponsors/UmbrellaDocs","type":"github"},"gitHead":"a17355512f8e518a6f02effd9ef2bde730abaf3d","scripts":{"dev":"ts-node src/index.ts","lint":"eslint src/**/*.ts --max-warnings 200","test":"jest","build":"npm run build:cjs && npm run build:esm && npm run build:cli","clean":"rimraf dist","start":"node dist/index.js","lint:ci":"eslint src/**/*.ts --config eslint.config.ci.js","release":"semantic-release","test:ci":"jest --ci --coverage --watchAll=false","lint:fix":"eslint src/**/*.ts --fix --max-warnings 200","prebuild":"rimraf dist","validate":"npm run type-check && npm run test","build:cjs":"tsc","build:cli":"npm run build:cjs && node scripts/prepare-cli.js","build:esm":"tsc -p tsconfig.esm.json && node scripts/fix-esm-imports.js","preversion":"npm run validate","test:watch":"jest --watch","type-check":"tsc --noEmit","build:check":"tsc --noEmit","lint:strict":"eslint src/**/*.ts","postpublish":"echo 'Package published successfully!'","postversion":"git push && git push --tags","release:dry":"semantic-release --dry-run","release:debug":"semantic-release --debug","release:local":"semantic-release --extends ./.releaserc.local.json --dry-run","test:coverage":"jest --coverage","validate:full":"npm run type-check && npm run lint && npm run test","prepublishOnly":"npm run validate && npm run build"},"_npmUser":{"name":"gaurav-nelson","email":"gaurav.nelson@gmail.com"},"categories":["Linters","Other"],"repository":{"url":"git+https://github.com/UmbrellaDocs/rdformat-validator.git","type":"git"},"_npmVersion":"11.4.2","description":"Validate and fix Reviewdog Diagnostic Format (RD Format) - A comprehensive library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification","directories":{},"_nodeVersion":"24.3.0","dependencies":{"commander":"^14.0.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.0.4","eslint":"^9.31.0","rimraf":"^6.0.1","ts-jest":"^29.4.0","ts-node":"^10.9.2","@eslint/js":"^9.31.0","typescript":"^5.8.3","@types/jest":"^30.0.0","@types/node":"^24.0.15","semantic-release":"^24.2.7","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^12.0.2","@semantic-release/github":"^11.0.3","@typescript-eslint/parser":"^8.37.0","@semantic-release/changelog":"^6.0.3","@typescript-eslint/eslint-plugin":"^8.37.0"},"_npmOperationalInternal":{"tmp":"tmp/rdformat-validator_1.0.0_1752935588890_0.2833820235614881","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@umbrelladocs/rdformat-validator","version":"1.0.1","description":"Validate and fix Reviewdog Diagnostic Format (RD Format) - A comprehensive library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification","author":{"name":"Gaurav Nelson","url":"https://github.com/UmbrellaDocs/rdformat-validator"},"maintainers":[{"name":"gaurav-nelson","email":"gaurav.nelson@gmail.com"}],"main":"dist/index.js","module":"dist/esm/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/esm/index.js","require":"./dist/index.js","types":"./dist/index.d.ts"}},"bin":{"rdformat-validator":"bin/rdformat-validator.js"},"scripts":{"build":"npm run build:cjs && npm run build:esm && npm run build:cli","build:cjs":"tsc","build:esm":"tsc -p tsconfig.esm.json && node scripts/fix-esm-imports.js","build:cli":"npm run build:cjs && node scripts/prepare-cli.js","prebuild":"rimraf dist","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ci":"jest --ci --coverage --watchAll=false","lint":"eslint src/**/*.ts --max-warnings 200","lint:fix":"eslint src/**/*.ts --fix --max-warnings 200","lint:strict":"eslint src/**/*.ts","lint:ci":"eslint src/**/*.ts --config eslint.config.ci.js","type-check":"tsc --noEmit","build:check":"tsc --noEmit","validate":"npm run type-check && npm run test","validate:full":"npm run type-check && npm run lint && npm run test","clean":"rimraf dist","dev":"ts-node src/index.ts","start":"node dist/index.js","prepublishOnly":"npm run validate && npm run build","postpublish":"echo 'Package published successfully!'","preversion":"npm run validate","postversion":"git push && git push --tags"},"keywords":["reviewdog","validator","diagnostic","format","json","linter","cli","rdformat","validation","typescript","nodejs","code-quality","static-analysis","json-schema"],"categories":["Linters","Other"],"engines":{"node":">=14.0.0","npm":">=6.0.0"},"repository":{"type":"git","url":"git+https://github.com/UmbrellaDocs/rdformat-validator.git"},"funding":{"type":"github","url":"https://github.com/sponsors/UmbrellaDocs"},"dependencies":{"commander":"^14.0.0"},"devDependencies":{"@eslint/js":"^10.0.1","@types/jest":"^30.0.0","@types/node":"^26.0.1","@typescript-eslint/eslint-plugin":"^8.62.1","@typescript-eslint/parser":"^8.62.1","eslint":"^10.0.1","jest":"^30.4.2","rimraf":"^6.1.3","ts-jest":"^29.4.11","ts-node":"^10.9.2","typescript":"^6.0.3"},"license":"Apache-2.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"bugs":{"url":"https://github.com/UmbrellaDocs/rdformat-validator/issues"},"homepage":"https://github.com/UmbrellaDocs/rdformat-validator#readme","_id":"@umbrelladocs/rdformat-validator@1.0.1","gitHead":"ef2fbbe29a9a3d831d30ccbdce5f031007886fa6","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-yOQbzkvQBshV0fLfjw4S1QEv+dsYs6RRqR+4W2njaHzPchyWj/rYvK5ogJ8Jo+GRtX1hKPxyRFtIN18GFwVQVA==","shasum":"49d1e528e4c66716ccff1660e58bc3d51bc4ff72","tarball":"https://registry.npmjs.org/@umbrelladocs/rdformat-validator/-/rdformat-validator-1.0.1.tgz","fileCount":77,"unpackedSize":671301,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEaJU0CwrZCQI0vbG8+J8DyFKmsABnORJOcPVUx3NKvbAiBhziJLI12qfR1mrm+neoY1ER+6eU7XcxIqxH0v8S7gwg=="}]},"_npmUser":{"name":"gaurav-nelson","email":"gaurav.nelson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rdformat-validator_1.0.1_1782891491603_0.5866878663326509"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-19T14:33:08.783Z","modified":"2026-07-01T07:38:11.882Z","1.0.0":"2025-07-19T14:33:09.100Z","1.0.1":"2026-07-01T07:38:11.729Z"},"bugs":{"url":"https://github.com/UmbrellaDocs/rdformat-validator/issues"},"author":{"name":"Gaurav Nelson","url":"https://github.com/UmbrellaDocs/rdformat-validator"},"license":"Apache-2.0","homepage":"https://github.com/UmbrellaDocs/rdformat-validator#readme","keywords":["reviewdog","validator","diagnostic","format","json","linter","cli","rdformat","validation","typescript","nodejs","code-quality","static-analysis","json-schema"],"repository":{"type":"git","url":"git+https://github.com/UmbrellaDocs/rdformat-validator.git"},"description":"Validate and fix Reviewdog Diagnostic Format (RD Format) - A comprehensive library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification","maintainers":[{"name":"gaurav-nelson","email":"gaurav.nelson@gmail.com"}],"readme":"# RDFormat Validator\n\nA NodeJS library and CLI tool for validating JSON data against the [Reviewdog Diagnostic Format](https://github.com/reviewdog/reviewdog/blob/master/proto/rdf/reviewdog.proto) specification.\n\n## Features\n\n- ✅ **JSON Schema Validation** - Validates against the official RDFormat specification\n- 🔧 **Automatic Fixing** - Attempts to fix common formatting issues\n- 📝 **Detailed Error Reporting** - Provides clear error messages with location information\n- 🎯 **TypeScript Support** - Full type definitions included\n- 🖥️ **CLI Tool** - Standalone command-line interface\n- 📚 **Library Usage** - Import as a module in your NodeJS projects\n- 🔄 **Multiple Input Formats** - Supports single diagnostics, arrays, and structured results\n\n## Installation\n\n### As a Library\n\n```bash\nnpm install @umbrelladocs/rdformat-validator\n```\n\n### As a CLI Tool\n\n```bash\n# Install globally\nnpm install -g @umbrelladocs/rdformat-validator\n\n# Or use with npx\nnpx @umbrelladocs/rdformat-validator --help\n```\n\n## Quick Start\n\n### Library Usage\n\n```typescript\nimport { validate, validateAndFix, RDFormatValidator } from '@umbrelladocs/rdformat-validator';\n\n// Quick validation\nconst result = await validate('{\"diagnostics\": []}');\nconsole.log(result.valid); // true\n\n// Validation with automatic fixing\nconst fixResult = await validateAndFix(invalidData, { fixLevel: 'basic' });\nif (fixResult.fixedData) {\n  console.log('Fixed data:', fixResult.fixedData);\n}\n\n// Using the main validator class\nconst validator = new RDFormatValidator({\n  strictMode: true,\n  allowExtraFields: false\n});\n\nconst result = await validator.validateFile('./diagnostics.json');\n```\n\n### CLI Usage\n\n```bash\n# Validate a single file\nrdformat-validator diagnostics.json\n\n# Validate multiple files\nrdformat-validator file1.json file2.json\n\n# Validate from stdin\ncat diagnostics.json | rdformat-validator\n\n# Validate and fix issues\nrdformat-validator --fix diagnostics.json\n\n# Output in JSON format\nrdformat-validator --format json diagnostics.json\n\n# Strict validation mode\nrdformat-validator --strict --no-extra-fields diagnostics.json\n```\n\n## RDFormat Overview\n\nThe Reviewdog Diagnostic Format (RDFormat) is a standardized JSON format for representing code analysis results. It supports two main structures:\n\n### 1. Diagnostic Array Format\nAn array of individual diagnostic objects:\n\n```json\n[\n  {\n    \"message\": \"Line too long\",\n    \"location\": {\n      \"path\": \"src/main.js\",\n      \"range\": {\n        \"start\": { \"line\": 10, \"column\": 1 },\n        \"end\": { \"line\": 10, \"column\": 120 }\n      }\n    },\n    \"severity\": \"WARNING\",\n    \"source\": {\n      \"name\": \"eslint\",\n      \"url\": \"https://eslint.org\"\n    }\n  }\n]\n```\n\n### 2. Diagnostic Result Format\nA structured result object containing diagnostics and metadata:\n\n```json\n{\n  \"diagnostics\": [\n    {\n      \"message\": \"Missing semicolon\",\n      \"location\": {\n        \"path\": \"src/app.js\",\n        \"range\": {\n          \"start\": { \"line\": 15, \"column\": 25 }\n        }\n      },\n      \"severity\": \"ERROR\",\n      \"source\": {\n        \"name\": \"jshint\"\n      }\n    }\n  ],\n  \"source\": {\n    \"name\": \"multi-linter\",\n    \"url\": \"https://example.com/multi-linter\"\n  },\n  \"severity\": \"ERROR\"\n}\n```\n\n## Library API\n\n### Main Classes\n\n#### `RDFormatValidator`\n\nThe primary validator class providing comprehensive validation functionality.\n\n```typescript\nconst validator = new RDFormatValidator({\n  strictMode: false,        // Enable strict validation\n  allowExtraFields: true,   // Allow extra fields not in spec\n  fixLevel: 'basic'         // Fix level: 'basic' or 'aggressive'\n});\n```\n\n**Methods:**\n- `validateString(input: string, fix?: boolean)` - Validate JSON string\n- `validateFile(filePath: string, fix?: boolean)` - Validate JSON file\n- `validateObject(data: any, fix?: boolean)` - Validate JavaScript object\n- `getSchema()` - Get the JSON schema used for validation\n- `setOptions(options)` - Update validator options\n\n### Convenience Functions\n\n#### `validate(input, options?)`\nSimple validation without fixing:\n\n```typescript\nconst result = await validate('{\"diagnostics\": []}');\nconsole.log(result.valid); // boolean\nconsole.log(result.errors); // ValidationError[]\nconsole.log(result.warnings); // ValidationWarning[]\n```\n\n#### `validateAndFix(input, options?)`\nValidation with automatic fixing:\n\n```typescript\nconst result = await validateAndFix(invalidData, { fixLevel: 'aggressive' });\nif (result.fixedData) {\n  console.log('Data was fixed:', result.fixedData);\n  console.log('Applied fixes:', result.appliedFixes);\n}\n```\n\n#### `isValidRDFormat(input, options?)`\nQuick validation check:\n\n```typescript\nconst isValid = await isValidRDFormat(data);\nconsole.log(isValid); // boolean\n```\n\n### Batch Processing\n\n#### `validateBatch(inputs, options?)`\nValidate multiple inputs simultaneously:\n\n```typescript\nconst results = await validateBatch([\n  '{\"diagnostics\": []}',\n  { diagnostics: [] },\n  invalidData\n]);\n\nresults.forEach((result, index) => {\n  console.log(`Input ${index}: ${result.valid ? 'valid' : 'invalid'}`);\n});\n```\n\n#### `validateAndFixBatch(inputs, options?)`\nBatch validation with fixing:\n\n```typescript\nconst results = await validateAndFixBatch(inputs, { fixLevel: 'basic' });\n```\n\n### Utility Functions\n\n#### `createValidationSummary(results)`\nCreate a summary of validation results:\n\n```typescript\nconst summary = createValidationSummary(results);\nconsole.log(`Valid: ${summary.validCount}/${summary.totalCount}`);\nconsole.log(`Total errors: ${summary.totalErrors}`);\n```\n\n#### `formatValidationErrors(errors, options?)`\nFormat errors for display:\n\n```typescript\nconst formattedErrors = formatValidationErrors(result.errors, {\n  includeCode: true,\n  includeExpected: true\n});\nformattedErrors.forEach(error => console.log(error));\n```\n\n## CLI Reference\n\n### Basic Usage\n\n```bash\nrdformat-validator [options] [files...]\n```\n\n### Options\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `-f, --fix` | Attempt to automatically fix common issues | `false` |\n| `-o, --output <file>` | Output file (default: stdout) | - |\n| `-v, --verbose` | Enable verbose output | `false` |\n| `-s, --silent` | Suppress non-error output | `false` |\n| `--format <format>` | Output format: `json` or `text` | `text` |\n| `--strict` | Enable strict validation mode | `false` |\n| `--no-extra-fields` | Disallow extra fields not in specification | `false` |\n| `--fix-level <level>` | Fix level: `basic` or `aggressive` | `basic` |\n\n### Examples\n\n#### Basic Validation\n```bash\n# Validate a single file\nrdformat-validator diagnostics.json\n\n# Validate multiple files\nrdformat-validator file1.json file2.json file3.json\n\n# Validate from stdin\ncat diagnostics.json | rdformat-validator\necho '{\"diagnostics\": []}' | rdformat-validator\n```\n\n#### Validation with Fixing\n```bash\n# Fix common issues\nrdformat-validator --fix diagnostics.json\n\n# Aggressive fixing\nrdformat-validator --fix --fix-level aggressive diagnostics.json\n\n# Save fixed output to file\nrdformat-validator --fix --output fixed.json diagnostics.json\n```\n\n#### Output Formats\n```bash\n# JSON output format\nrdformat-validator --format json diagnostics.json\n\n# Verbose text output\nrdformat-validator --verbose diagnostics.json\n\n# Silent mode (only errors)\nrdformat-validator --silent diagnostics.json\n```\n\n#### Strict Validation\n```bash\n# Strict mode with no extra fields\nrdformat-validator --strict --no-extra-fields diagnostics.json\n\n# Combine with other options\nrdformat-validator --strict --verbose --format json diagnostics.json\n```\n\n### Exit Codes\n\n- `0` - Success (all files are valid)\n- `1` - Validation errors found or other errors occurred\n\n## Configuration Options\n\n### Validation Options\n\n```typescript\ninterface RDFormatValidatorOptions {\n  strictMode?: boolean;        // Enable strict validation (default: false)\n  allowExtraFields?: boolean;  // Allow extra fields (default: true)\n  fixLevel?: 'basic' | 'aggressive'; // Fix level (default: 'basic')\n}\n```\n\n### Fix Levels\n\n- **`basic`** - Safe fixes that don't change data semantics\n  - Add missing required fields with sensible defaults\n  - Fix simple type mismatches (string to number, etc.)\n  - Correct basic structural issues\n\n- **`aggressive`** - More extensive fixes that may change data\n  - Remove invalid fields\n  - Restructure nested objects\n  - Apply more complex transformations\n\n## Error Handling\n\n### Validation Errors\n\n```typescript\ninterface ValidationError {\n  path: string;        // JSON path to error location\n  message: string;     // Human-readable error message\n  code: string;        // Error code for programmatic handling\n  value?: any;         // The value that caused the error\n  expected?: string;   // Description of expected value/format\n}\n```\n\n### Common Error Codes\n\n- `REQUIRED_PROPERTY_MISSING` - Missing required field\n- `TYPE_MISMATCH` - Wrong data type\n- `ENUM_VALIDATION_FAILED` - Invalid enum value\n- `UNKNOWN_PROPERTY` - Extra field not in specification\n- `INVALID_JSON` / `PARSE_ERROR` - JSON parsing error (`PARSE_ERROR` at the top-level API; `INVALID_JSON` from the validator)\n- `UNEXPECTED_ERROR` - Unexpected system error\n\n### Error Examples\n\n```typescript\nconst result = await validate(invalidData);\nif (!result.valid) {\n  result.errors.forEach(error => {\n    console.log(`${error.path}: ${error.message} (${error.code})`);\n  });\n}\n```\n\n## TypeScript Support\n\nFull TypeScript definitions are included:\n\n```typescript\nimport {\n  RDFormatValidator,\n  RDFormatValidatorOptions,\n  RDFormatValidatorResult,\n  ValidationError,\n  ValidationWarning,\n  Diagnostic,\n  DiagnosticResult,\n  Location,\n  Range,\n  Position,\n  Severity,\n  Source,\n  Code,\n  Suggestion\n} from '@umbrelladocs/rdformat-validator';\n```\n\n## Integration Examples\n\n### CI/CD Pipeline\n\n```bash\n#!/bin/bash\n# Validate diagnostic output in CI\nif ! rdformat-validator --silent diagnostics.json; then\n  echo \"Invalid RDFormat data detected\"\n  exit 1\nfi\n```\n\n### Node.js Script\n\n```javascript\nconst { RDFormatValidator } = require('@umbrelladocs/rdformat-validator');\n\nasync function validateDiagnostics() {\n  try {\n    const validator = new RDFormatValidator();\n    const result = await validator.validateFile('./output/diagnostics.json');\n    if (!result.valid) {\n      console.error('Validation failed:', result.errors);\n      process.exit(1);\n    }\n    console.log('Diagnostics are valid!');\n  } catch (error) {\n    console.error('Error:', error.message);\n    process.exit(1);\n  }\n}\n\nvalidateDiagnostics();\n```\n\n### Express.js Middleware\n\n```javascript\nconst { validate } = require('@umbrelladocs/rdformat-validator');\n\nfunction validateRDFormat(req, res, next) {\n  validate(req.body)\n    .then(result => {\n      if (!result.valid) {\n        return res.status(400).json({\n          error: 'Invalid RDFormat data',\n          details: result.errors\n        });\n      }\n      next();\n    })\n    .catch(next);\n}\n\napp.post('/diagnostics', validateRDFormat, (req, res) => {\n  // Handle valid RDFormat data\n  res.json({ status: 'success' });\n});\n```\n\n## Requirements\n\n- Node.js 14.0.0 or higher\n- TypeScript 5.8+ (for development)\n\n## Documentation\n\nBrowse the full documentation locally with [Docsify](https://docsify.js.org/):\n\n```bash\nnpx serve docs\n# Open http://localhost:3000\n```\n\nSee also:\n\n- [API Reference](docs/API.md)\n- [CLI Reference](docs/CLI.md)\n\n## License\n\nApache-2.0\n\n## Contributing\n\nContributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.\n\n## Links\n\n- [Reviewdog Project](https://github.com/reviewdog/reviewdog)\n- [RDFormat Specification](https://github.com/reviewdog/reviewdog/blob/master/proto/rdf/reviewdog.proto)\n- [NPM Package](https://www.npmjs.com/package/@umbrelladocs/rdformat-validator)","readmeFilename":"README.md"}