Unused require() should be removed

  • Code Quality
  • Low
  • nodejs

This rule applies when a variable holding a require() result is not used.

For maintainability, it is recommended to remove unused module dependencies. If just module loading was intended, it is more explicit to require the module without variable assignment.

Noncompliant Code Example

View with compliant examples side by side
let init = require("initialize"); // UNUSED_REQUIRE alarm
let foo = require("foo"); // UNUSED_REQUIRE alarm
module.exports = function () { }

Compliant Code Example

View with noncompliant examples side by side
module.exports = function () { }


This rule was introduced in DeepScan 1.1.0-alpha.

Was this documentation helpful?