node-dependencies/compat-engines
enforce the versions of the engines of the dependencies to be compatible.
- ⚙️ This rule is included in
configs.recommended.
📖 Rule Details
This rule checks the engines of the dependencies and reports if they are compatible with the engines defined in package.json.
jsonc
/* eslint "node-dependencies/compat-engines": "error" */
{
"engines": {
"node": ">=8"
},
"dependencies": {
"semver": "^7.3.5" /* ✗ BAD: node>=10 is required. */
}
}🔧 Options
json
{
"node-dependencies/compat-engines": ["error", {
"deep": true,
"devDependencies": false,
"comparisonType": "normal",
"allows": []
}]
}deep... Iftrue, if the dependency does not haveengines, it will be checked further dependencies.devDependencies... Iftrue, the rule also checksdevDependencies.comparisonType... Defines the comparison method. Default is"normal""normal"... This is the normal comparison method."major"... If the versions match in the major version, it is considered a match. For example,node@>=10allows dependency modules fornode@>=10.12.
allows... An array of package names to skip. The rule does not check these packages or their dependencies. Withdeep, the packages are also skipped when they are found among the dependencies of other packages. An alias such as"ts7": "npm:typescript@^7"is skipped when either its name (ts7) or the package it points to (typescript) is listed.
💡 Example
jsonc
/* eslint "node-dependencies/compat-engines": ["error", {"allows": ["semver"]}] */
{
"engines": {
"node": ">=8"
},
"dependencies": {
"semver": "^7.3.5" /* ✓ GOOD: Not reported because it is in allows. */
}
}🚀 Version
This rule was introduced in eslint-plugin-node-dependencies v0.5.0