dependency-version-range
July 25, 2026 ยท View on GitHub
๐ Enforce a consistent version range style for dependencies.
๐ผ This rule is enabled in the โ
recommended config.
๐ก This rule is manually fixable by editor suggestions.
Teams often want a single, consistent version range style across their dependencies. This rule enforces one of caret (^), tilde (~), or exact ranges.
Only plain single-version specifiers (like 1.2.3, ^1.2.3, ~1.2.3) are checked. Complex ranges, tags (latest), workspace: protocols, git URLs, and other non-registry specifiers are ignored.
Changing a version range alters which versions npm will install, so this rule offers a suggestion rather than an autofix.
Options
range
Type: 'caret' | 'tilde' | 'exact' | 'consistent'
Default: 'caret'
The required version range style. 'consistent' does not mandate a specific style; instead it picks the style already used by most dependencies and flags the outliers, so a file using a single style throughout always passes. Ties are broken in favor of caret (^), then tilde (~), then exact.
dependencyTypes
Type: string[]
Default: ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']
Which dependency groups to check.
exceptions
Type: string[]
Default: []
Package names to skip.
{
'package-json/dependency-version-range': ['error', {
range: 'caret',
dependencyTypes: ['dependencies'],
exceptions: ['some-pinned-package']
}]
}
Examples
With {range: 'caret'} (the default):
// โ
{
"dependencies": {
"foo": "1.2.3"
}
}
// โ
{
"dependencies": {
"foo": "^1.2.3"
}
}