Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-lodash

Package Overview
Dependencies
Maintainers
3
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-lodash

Lodash specific linting rules for ESLint

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
485K
decreased by-4.32%
Maintainers
3
Weekly downloads
 
Created

What is eslint-plugin-lodash?

eslint-plugin-lodash is an ESLint plugin that provides linting rules for Lodash, a popular JavaScript utility library. The plugin helps ensure that Lodash is used in an optimal and consistent manner, promoting best practices and preventing common mistakes.

What are eslint-plugin-lodash's main functionalities?

Prefer Lodash methods over native

This rule enforces the use of Lodash methods over native JavaScript methods. It ensures consistency and leverages Lodash's optimizations.

/* eslint lodash/prefer-lodash-method: [2] */
const _ = require('lodash');
const arr = [1, 2, 3];
// Bad: using native method
const doubled = arr.map(x => x * 2);
// Good: using Lodash method
const doubled = _.map(arr, x => x * 2);

Prefer _.get over direct property access

This rule encourages the use of _.get for property access, which is safer and avoids potential errors when accessing deeply nested properties.

/* eslint lodash/prefer-get: [2] */
const _ = require('lodash');
const obj = { a: { b: 2 } };
// Bad: direct property access
const value = obj.a.b;
// Good: using _.get
const value = _.get(obj, 'a.b');

Prefer _.isNil over _.isNull and _.isUndefined

This rule prefers the use of _.isNil, which checks for both null and undefined, over using _.isNull and _.isUndefined separately.

/* eslint lodash/prefer-is-nil: [2] */
const _ = require('lodash');
const value = null;
// Bad: using _.isNull and _.isUndefined
if (_.isNull(value) || _.isUndefined(value)) {
  // do something
}
// Good: using _.isNil
if (_.isNil(value)) {
  // do something
}

Other packages similar to eslint-plugin-lodash

Keywords

FAQs

Package last updated on 31 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc