Skip to content

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 ... If true, if the dependency does not have engines, it will be checked further dependencies.
  • devDependencies ... If true, the rule also checks devDependencies.
  • 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@>=10 allows dependency modules for node@>=10.12.
  • allows ... An array of package names to skip. The rule does not check these packages or their dependencies. With deep, 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

🔍 Implementation ​