Many methods provided by utility libraries like Lodash and Underscore.js have native equivalents in modern JavaScript environments (ES6 and later).
Using native methods reduces the dependency on external libraries, decreases the bundle size of an application, and often improves performance because JavaScript engines heavily optimize built-in APIs.
When the standard API already covers the same use case, keeping the Lodash or Underscore.js call adds unnecessary indirection. Readers must translate a library-specific helper into a platform feature they already know, and the project keeps a dependency for behavior that the runtime already exposes.
Instead of importing and using lodash or underscore methods, prefer the native standard libraries unless the code
specifically relies on the extra edge-case handling or null-safety the external library provides.
Using utility wrappers when the platform already provides the same behavior makes code less idiomatic and harder to maintain. It also keeps an unnecessary dependency surface in the codebase.
Replace the library call with the standard API that matches the current behavior. This rule only recommends alternatives that are available for the configured ECMAScript version.
import _ from "lodash"; const uniqueIds = _.uniq(ids); // Noncompliant const isList = _.isArray(value); // Noncompliant
const uniqueIds = [...new Set(ids)]; // Compliant const isList = Array.isArray(value); // Compliant
Do not assume that every Lodash or Underscore.js helper maps directly to the same standard API.
null and undefined, while native APIs such as
Object.keys() and Array.prototype.slice() throw for those values.