Skip to content

RequiredScripts

const RequiredScripts: FilePolicyDefinition<RequiredScriptsConfig | undefined> & object

Defined in: policies/RequiredScripts.ts:167

A policy that validates required scripts exist in package.json.

requiresConfig: true

Use this policy when you want to ensure specific scripts are present. Scripts can be specified with optional default values that enable auto-fix.

Note: This policy only checks for script presence. It does NOT validate the script’s content. Use ExactScripts for content validation.

import { makePolicy } from "repopo";
import { RequiredScripts } from "repopo/policies";
makePolicy(RequiredScripts, { config: {
scripts: [
"test", // Must exist, no auto-fix
{ lint: "biome lint ." }, // Must exist, auto-fix adds default if missing
{ clean: "rimraf dist esm" }, // Must exist, auto-fix adds default if missing
],
} })