Files
pnpm/patching/config/src/verifyPatches.ts
Zoltan Kochan 1c8c4e49f5 style: add eslint-plugin-simple-import-sort (#10947)
Add eslint-plugin-simple-import-sort to enforce consistent import ordering:
- Node.js builtins first
- External packages second
- Relative imports last
- Named imports sorted alphabetically within each statement
2026-03-13 02:02:38 +01:00

33 lines
996 B
TypeScript

import { PnpmError } from '@pnpm/error'
import { globalWarn } from '@pnpm/logger'
import type { PatchGroupRecord } from '@pnpm/patching.types'
import { allPatchKeys } from './allPatchKeys.js'
export interface VerifyPatchesOptions {
patchedDependencies: PatchGroupRecord
appliedPatches: Set<string>
allowUnusedPatches: boolean
}
export function verifyPatches ({
patchedDependencies,
appliedPatches,
allowUnusedPatches,
}: VerifyPatchesOptions): void {
const unusedPatches: string[] = []
for (const patchKey of allPatchKeys(patchedDependencies)) {
if (!appliedPatches.has(patchKey)) unusedPatches.push(patchKey)
}
if (!unusedPatches.length) return
const message = `The following patches were not used: ${unusedPatches.join(', ')}`
if (allowUnusedPatches) {
globalWarn(message)
return
}
throw new PnpmError('UNUSED_PATCH', message, {
hint: 'Either remove them from "patchedDependencies" or update them to match packages in your dependencies.',
})
}