@codemod-utils/json
Version:
Utilities for handling JSON
22 lines (21 loc) • 620 B
TypeScript
import type { PackageJson, ValidatedPackageJson } from '../types/index.js';
/**
* (Type-)Checks that the fields `name` and `version` exist, in the
* sense that their values are a non-empty string.
*
* @param packageJson
*
* A JSON that represents `package.json`.
*
* @example
*
* ```ts
* const packageJson = readPackageJson({ projectRoot });
*
* validatePackageJson(packageJson);
*
* // Both guaranteed to be `string` (not `undefined`)
* const { name, version } = packageJson;
* ```
*/
export declare function validatePackageJson(packageJson: PackageJson): asserts packageJson is ValidatedPackageJson;