Banned
Find and remove dependencies which you’ve decided should never be used.
Examples
Example: Completely ban a dependency from being used
Ban a dependency from being used anywhere in your monorepo.
1. Add a version group
2. Look for mismatches
Now when you run any syncpack command, banned dependencies will be listed:
And can be removed:
Example: Ensure `@types` are only installed as `devDependencies`
Only allow TypeScript @types packages from being used anywhere other than in the devDependencies
section of package.json.
1. Add a version group
- Match all dependencies whose name starts with
@types/
. - Only match those dependencies when they appear anywhere except
devDependencies
. - Define the behaviour of this group as isBanned.
- Add a label to document the decision/expectation.
2. Look for mismatches
Any @types
packages which are in the wrong location can then be found and manually moved:
Configuration
isBanned
RequiredThis property activates this behaviour for a given Version Group.
dependencies
Optional- An array of names of dependencies you’ve installed or otherwise reference in your package.json files.
- If omitted, the default behaviour is to match every dependency.
- The strings can be any combination of exact matches or minimatch glob patterns:
dependencyTypes
Optional- When set, only dependencies present in the named locations will be assigned to this group.
- If omitted, the default behaviour is to match dependencies everywhere they are found.
- Negated types are also supported, so a value of
["!dev", "!prod"]
would assign everything exceptdependencies
anddevDependencies
to this group.
Default values
Value | Property in package.json |
---|---|
dev | devDependencies |
local | version |
overrides | overrides |
peer | peerDependencies |
pnpmOverrides | pnpm.overrides |
prod | dependencies |
resolutions | resolutions |
specifierTypes
Optional- When set, only dependencies whose version specifier matches the named formats will be assigned to this group.
- If omitted, the default behaviour is to match all dependencies.
- Negated types are also supported, so a value of
["!latest", "!file"]
would assign everything except specifiers of the format*
andfile:path/to/package.tgz
to this group.
Available values
Value | Example |
---|---|
alias | npm:foo@1.2.3 |
exact | 8.1.2 |
file | file:path/to/foo.tgz , file:path/to/directory |
hosted-git | git+https://github.com/user/foo , git+ssh://git@notgithub.com/user/foo#1.2.3 etc |
latest | * or latest |
range | ^4.1.1 , >=5.0.0 , ~1.2.1 etc |
tag | alpha , canary |
unsupported | $typescript , 1.typo.wat |
url | https://server.com/foo.tgz |
workspace-protocol | workspace:* , workspace:~ , workspace:^ |
label
Optional- A short name or description displayed as a header in syncpack’s output.
- If a label is not set then eg. “Version Group 3” will be used instead.
packages
Optional- An array of strings which should match the
name
properties of your package.json files. - If omitted, the default behaviour is to match every package.
- Negated types are also supported, so a value of
["!my-client", "!my-server"]
would assign everything except the packagesmy-client
andmy-server
to this group. - The strings can be any combination of exact matches or minimatch glob patterns: