PackageAllowedScopes
constPackageAllowedScopes:FilePolicyDefinition<PackageAllowedScopesConfig|undefined> &object
Defined in: policies/PackageAllowedScopes.ts:143
A policy that ensures packages use only allowed scopes and package names.
This policy prevents accidental introduction of new npm scopes or unscoped packages in a monorepo. It helps maintain naming consistency and prevents typos or mistakes when creating new packages.
Type Declaration
Section titled “Type Declaration”requiresConfig
Section titled “requiresConfig”requiresConfig:
true
Remarks
Section titled “Remarks”The policy checks packages in the following order:
- If the package is scoped (starts with
@), check if its scope is inallowedScopes - If the package is unscoped, check if it’s in
unscopedPackages - If neither check passes, the policy fails
The “root” package (common in monorepos) is automatically skipped.
Example
Section titled “Example”import { makePolicy } from "repopo";import { PackageAllowedScopes } from "repopo/policies";
const config: RepopoConfig = { policies: [ makePolicy(PackageAllowedScopes, { config: { allowedScopes: ["@myorg", "@internal"], unscopedPackages: ["legacy-package"], }, }), ],};