mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-08 01:00:51 -04:00
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
33 lines
996 B
TypeScript
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.',
|
|
})
|
|
}
|