PackageScriptsSettings
Defined in: policies/PackageScripts.ts:77
Policy settings for the PackageScripts repo policy.
Properties
Section titled “Properties”conditionalRequired?
Section titled “conditionalRequired?”
optionalconditionalRequired?:LegacyConditionalScriptRule[]
Defined in: policies/PackageScripts.ts:154
Conditional script requirements. If a script is present, other scripts must also exist.
Remarks
Section titled “Remarks”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
Example
Section titled “Example”// 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 defaultconditionalRequired: [{ ifPresent: "build", requires: ["test", { clean: "rimraf dist" }] }]exact?
Section titled “exact?”
optionalexact?:Record<string,string>
Defined in: policies/PackageScripts.ts:116
Scripts that must exist AND have exact content.
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”exact: { clean: "rimraf dist esm", format: "biome format --write .",}
optionalmust?:LegacyRequiredScriptEntry[]
Defined in: policies/PackageScripts.ts:97
Scripts that must be present in package.json.
Remarks
Section titled “Remarks”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
Example
Section titled “Example”must: [ "test", // Must exist, no auto-fix { lint: "biome lint ." }, // Must exist, auto-fix available { clean: "rimraf dist esm" }, // Must exist, auto-fix available]mutuallyExclusive?
Section titled “mutuallyExclusive?”
optionalmutuallyExclusive?: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.
Example
Section titled “Example”// Allow "test:unit" OR "test:vitest" OR neither, but not bothmutuallyExclusive: [["test:unit", "test:vitest"]]scriptMustContain?
Section titled “scriptMustContain?”
optionalscriptMustContain?:ScriptMustContainRule[]
Defined in: policies/PackageScripts.ts:175
Rules for validating script body content.
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”scriptMustContain: [ { script: "clean", mustContain: ["rimraf"] }, { script: "build", mustContain: ["tsc"] },]