UNPKG

@codemod-utils/json

Version:
22 lines (21 loc) 620 B
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;