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

eslint-plugin-lodash-smells

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-lodash-smells

eslint rules for lodash code smells

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
89
decreased by-23.93%
Maintainers
1
Weekly downloads
 
Created
Source

ESLint-plugin-lodash-smells

Codeship Status for rayners/eslint-plugin-lodash-smells Coverage Status

ESLint rules for lodash uses I keep an eye out for when I am doing code reviews.

Installation

Install ESLint either locally or globally.

$ npm install eslint

If you installed ESLint globally, you have to install the lodash smells plugin globally as well. Otherwise, install it locally.

$ npm install eslint-plugin-lodash-smells

Configuration

Add a plugins section to your .eslintrc (if it is not there already), and add lodash-smells to the list:

{
    "plugins": [
        "lodash-smells"
    ]
}

And then enable the rules you would like to use:

{
    "rules": {
        "lodash-smells/no-big-ifs": 1,
        "lodash-smells/no-each-push": 1,
        "lodash-smells/no-get-length": 1
    }
}

Rules

no-big-ifs

Intended to avoid code in this form:

_.each(myList, function(item) {
    if (someCondition(item) {
        doSomething(item);
    }
})

Prefered:

_(myList)
    .filter(someCondition)
    .each(doSomething);

_.each(_.filter(myList, someCondition), doSomething);

no-each-push

Intended to avoid code in this form:

var myNewList = []
_.each(myList, function(item) {
    var newItem = doSomething(item);
    myNewList.push(newItem);
});

Preferred:

var myNewList = _.map(myList, doSomething);

no-get-length

Intended to avoid code in this form:

var l = _.get(myList, 'length', 0);

Preferred:

var l = _.size(myList);

Keywords

FAQs

Package last updated on 06 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