definePackagePolicy
definePackagePolicy<
J,C>(args):PolicyShape<C>
Defined in: policyDefiners/definePackagePolicy.ts:97
Define a repo policy for package.json files.
Type Parameters
Section titled “Type Parameters”J = PackageJson
C = undefined
Parameters
Section titled “Parameters”DefinePackagePolicyArgs<J, C>
Policy metadata, parsed-JSON handler, and optional defaults.
Returns
Section titled “Returns”PolicyShape<C>
A file policy that reads and parses matching package.json files.
Remarks
Section titled “Remarks”This is a helper function that creates a policy pre-configured to match package.json files. The handler receives the parsed JSON content.
Example
Section titled “Example”const MyPackagePolicy = definePackagePolicy({ name: "MyPackagePolicy", description: "Ensures package.json has required fields", handler: async (json, { file }) => { if (!json.name) { return { error: "Missing name", fixable: false }; } return true; },});