ESLint rules for Underscore
Clone or download
Pull request Compare This branch is 93 commits ahead, 325 commits behind wix:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
tests Merge pull request #22 from captbaritone/prefer-pick Feb 24, 2016

Build Status

Forked from eslint-plugin-lodash


Linting rules for Underscore


Install ESLint either locally or globally.

npm install eslint

If you installed ESLint globally, you have to install the Underscore plugin globally too. Otherwise, install it locally.

$ npm install eslint-plugin-underscore


Add plugins section and specify ESLint-plugin-underscore as a plugin.

  "plugins": ["underscore"]

Finally, enable all of the rules that you would like to use.

  "rules": {
    "underscore/collection-return": 2,
    "underscore/identity-shorthand": [2, "always"],
    "underscore/jquery-each": [2, "never"],
    "underscore/jquery-extend": [2, "never"],
    "underscore/jquery-proxy": [2, "never"],
    "underscore/matches-shorthand": [2, "always"],
    "underscore/no-return-value-from-each-iteratee": 2,
    "underscore/no-unnecessary-bind": 2,
    "underscore/prefer-chain": [2, 3],
    "underscore/prefer-compact": 2,
    "underscore/prefer-constant": 2,
    "underscore/prefer-filter": 2,
    "underscore/prefer-findwhere": 2,
    "underscore/prefer-invoke": 2,
    "underscore/prefer-map": 2,
    "underscore/prefer-matches": 2,
    "underscore/prefer-noop": 2,
    "underscore/prefer-pick": [2, {objectsLargerThan: 3}],
    "underscore/prefer-pluck": 2,
    "underscore/prefer-reject": 2,
    "underscore/prefer-times": 2,
    "underscore/prefer-underscore-method": 2,
    "underscore/prefer-underscore-typecheck": 2,
    "underscore/prefer-where": 2,
    "underscore/preferred-alias": 2,
    "underscore/prop-shorthand": [2, "always"],

    // The below rules are not (yet) supported
    "underscore/no-single-chain": 2,
    "underscore/unwrap": 2,
    "underscore/no-double-unwrap": 2,
    "underscore/prefer-wrapper-method": 2,
    "underscore/prefer-lodash-chain": 2,
    "underscore/chain-style": [2, "as-needed"]

List of supported rules

List of Lodash rules which are not yet supported

  • no-single-chain: Prevent chaining syntax for single method, e.g. _(x).map().value().
  • unwrap: Prevent chaining without evaluation via value() or non-chainable methods like max().
  • no-double-unwrap: Do not use .value() on chains that have already ended (e.g. with max() or reduce()).
  • prefer-wrapper-method: Prefer using array and string methods in the chain and not the initial value, e.g. _(str).split(' ')...
  • prefer-lodash-chain: Prefer using Lodash chains (e.g. over native and mixed chains.
  • chain-style: Enforce a specific chain style: explicit, implicit, or explicit only when necessary.


ESLint-plugin-underscore is licensed under the MIT License.