Skip to content

PackageScriptsSettings

Defined in: policies/PackageScripts.ts:77

Policy settings for the PackageScripts repo policy.

optional conditionalRequired?: LegacyConditionalScriptRule[]

Defined in: policies/PackageScripts.ts:154

Conditional script requirements. If a script is present, other scripts must also exist.

This is useful for enforcing that packages with a “build” script also have a “clean” script, or packages with “test” also have “test:coverage”.

The requires field accepts the same format as PackageScriptsSettings.must:

  • Strings: Script must exist, no auto-fix available
  • Objects { scriptName: "default" }: Script must exist, auto-fix adds the default if missing
// If "build" exists, "clean" must also exist (with auto-fix default)
conditionalRequired: [{ ifPresent: "build", requires: [{ clean: "rimraf dist" }] }]
// Mixed: "test" required without default, "clean" with default
conditionalRequired: [{ ifPresent: "build", requires: ["test", { clean: "rimraf dist" }] }]

optional exact?: Record<string, string>

Defined in: policies/PackageScripts.ts:116

Scripts that must exist AND have exact content.

Unlike PackageScriptsSettings.must, scripts in exact are validated against the specified value. If a script exists but has different content, it fails validation. Both missing and mismatched scripts are auto-fixable.

exact: {
clean: "rimraf dist esm",
format: "biome format --write .",
}

optional must?: LegacyRequiredScriptEntry[]

Defined in: policies/PackageScripts.ts:97

Scripts that must be present in package.json.

Each entry can be:

  • A string: Script must exist, no auto-fix available, content not validated
  • An object { scriptName: "default value" }: Script must exist, auto-fix adds the default value if missing, but existing scripts with different content still pass
must: [
"test", // Must exist, no auto-fix
{ lint: "biome lint ." }, // Must exist, auto-fix available
{ clean: "rimraf dist esm" }, // Must exist, auto-fix available
]

optional mutuallyExclusive?: string[][]

Defined in: policies/PackageScripts.ts:131

List of mutually exclusive script groups. Each group is an array of script names where at most one script from the group can be present.

Packages can have zero scripts from the group (all optional), but cannot have multiple scripts from the same group.

// Allow "test:unit" OR "test:vitest" OR neither, but not both
mutuallyExclusive: [["test:unit", "test:vitest"]]

optional scriptMustContain?: ScriptMustContainRule[]

Defined in: policies/PackageScripts.ts:175

Rules for validating script body content.

This allows you to ensure that specific scripts contain required commands or patterns without requiring an exact match. For example, requiring that the “clean” script uses “rimraf” or that “build” includes “tsc”.

For exact content matching, use PackageScriptsSettings.exact instead.

scriptMustContain: [
{ script: "clean", mustContain: ["rimraf"] },
{ script: "build", mustContain: ["tsc"] },
]