node-dependencies/absolute-version
require or disallow absolute version of dependency.
📖 Rule Details
This rule enforces the use of absolute version of dependency.
jsonc
/* eslint "node-dependencies/absolute-version": "error" */
{
"devDependencies": {
"semver": "^7.3.5", /* ✗ BAD */
"typescript": "4.6.2" /* ✓ GOOD */
}
}
🔧 Options
String Option
jsonc
{
"node-dependencies/absolute-version": ["error",
"always" // or "never"
]
}
"always"
... Enforces to use the absolute version."never"
... Enforces not to use the absolute version.
Object Option
jsonc
{
"node-dependencies/absolute-version": ["error", {
"dependencies": "ignore", // , "always" or "never"
"peerDependencies": "ignore", // , "always" or "never"
"optionalDependencies": "ignore", // , "always" or "never"
"devDependencies": "always" // , "never" or "ignore"
}]
}
dependencies
... Configuration fordependencies
.peerDependencies
... Configuration fordependencies
.optionalDependencies
... Configuration fordependencies
.devDependencies
... Configuration fordependencies
.- Value
"always"
... Enforces to use the absolute version."never"
... Enforces not to use the absolute version."ignore"
... Ignored from the check.
By default, always
applies only to devDependencies
.
Override Option for Each Package
jsonc
{
"node-dependencies/absolute-version": ["error", {
// "dependencies": "ignore",
// "peerDependencies": "ignore",
// "optionalDependencies": "ignore",
// "devDependencies": "always",
"overridePackages": {
"foo": "always" // Always use an absolute version for the "foo" package.
}
}]
}
overridePackages
... Configure an object with the package name as the key.- Property Key ... Specify the package name, or the pattern such as
/^@babel\//
. - Property Value ... Can use the Object Option or the String Option.
- Property Key ... Specify the package name, or the pattern such as
🚀 Version
This rule was introduced in eslint-plugin-node-dependencies v0.7.0