Code Monkey home page Code Monkey logo

eslint-plugin-lodash3's Introduction

ESLint-plugin-lodash3

Maintenance Status NPM version Build Status Coverage Status

Lodash3 specific linting rules for ESLint

Installation

Install ESLint either locally or globally.

npm install eslint

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

$ npm install eslint-plugin-lodash3

Configuration

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

{
  "plugins": ["lodash3"]
}

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

{
  "rules": {
    "lodash3/prop-shorthand": 1,
    "lodash3/matches-shorthand": [1,3],
    "lodash3/matches-prop-shorthand": 1,
    "lodash3/prefer-chain": 1,
    "lodash3/preferred-alias": 1,
    "lodash3/no-single-chain": 1,
    "lodash3/prefer-reject": [1,3],
    "lodash3/prefer-filter": [1,3],
    "lodash3/no-unnecessary-bind": 1,
    "lodash3/unwrap": 1,
    "lodash3/prefer-compact": 1,
    "lodash3/no-double-unwrap": 1,
    "lodash3/prefer-map": 1,
    "lodash3/prefer-wrapper-method": 1,
    "lodash3/prefer-invoke": 1,
    "lodash3/prefer-thru": 1,
    "lodash3/prefer-lodash-chain": 1,
    "lodash3/prefer-lodash-method": 1,
    "lodash3/prefer-lodash-typecheck": 1,
    "lodash3/no-commit": 1,
    "lodash3/prefer-get": 1,
    "lodash3/collection-return": 1,
    "lodash3/prefer-matches": 1,
    "lodash3/prefer-times": 1
  }
}

List of supported rules

  • prop-shorthand: Prefer property shorthand syntax
  • matches-prop-shorthand: Prefer matches property shorthand syntax
  • matches-shorthand: Prefer matches shorthand syntax
  • preferred-alias: Preferred aliases
  • prefer-chain: Prefer chain over nested lodash calls
  • no-single-chain: Prevent chaining syntax for single method, e.g. _(x).map().value()
  • prefer-reject: Prefer _.reject over filter with !(expression) or x.prop1 !== value
  • prefer-filter: Prefer _.filter over _.forEach with an if statement inside.
  • no-unnecessary-bind: Prefer passing thisArg over binding.
  • unwrap: Prevent chaining without evaluation via value() or non-chainable methods like max().,
  • prefer-compact: Prefer _.compact over _.filter for only truthy values.
  • no-double-unwrap: Do not use .value() on chains that have already ended (e.g. with max() or reduce())
  • prefer-map: Prefer _.map over _.forEach with a push inside.
  • prefer-wrapper-method: Prefer using array and string methods in the chain and not the initial value, e.g. _(str).split(' ')...
  • prefer-invoke: Prefer using _.invoke over _.map with a method call inside.
  • prefer-thru: Prefer using _.prototype.thru in the chain and not call functions in the initial value, e.g. _(x).thru(f).map(g)...
  • prefer-lodash-chain: Prefer using Lodash chains (e.g. _.map) over native and mixed chains.
  • prefer-lodash-method: Prefer using Lodash collection methods (e.g. _.map) over native array methods.
  • prefer-lodash-typecheck: Prefer using _.is* methods over typeof and instanceof checks when applicable.
  • no-commit: Do not use .commit() on chains that should end with .value()
  • prefer-get: Prefer using _.get or _.has over expression chains like a && a.b && a.b.c.
  • collection-return: Always return a value in iteratees of lodash collection methods that aren't forEach.
  • prefer-matches: Prefer _.matches over conditions like a.foo === 1 && a.bar === 2 && a.baz === 3.
  • prefer-times: Prefer _.times over _.map without using the iteratee's arguments.

License

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

eslint-plugin-lodash3's People

Contributors

ganimomer avatar mariawix avatar mischah avatar tomerlichtash avatar

Stargazers

Viacheslav Shabelnyk avatar

Watchers

James Cloos avatar Gajus Kuizinas avatar Viacheslav Shabelnyk avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.