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 - npm Package Compare versions

Comparing version 0.1.4 to 1.0.0

index.js

59

CHANGELOG.md

@@ -1,18 +0,59 @@

v0.1.4 - Tue, 22 Sep 2015 11:30:55 GMT
--------------------------------------
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
- [938d144](../../commit/938d144) [added] 'lodash-compat' into the check list
## [Unreleased][unreleased]
### Added
- (none)
[unreleased]: https://github.com/wix/eslint-plugin-lodash/compare/v1.0.0...HEAD
v0.1.3 - Mon, 13 Jul 2015 15:24:07 GMT
--------------------------------------
## [1.0.0] - 2016-01-27
### Added
- Added support for using a different pragma (symbol) as the Lodash object using [shared settings](http://eslint.org/docs/user-guide/configuring#adding-shared-settings). ([`e4dc506`][e4dc506])
- Added rule [`prefer-is-nil`][prefer-is-nil]. ([`ee23d5b`][ee23d5b])
- Added rule [`prefer-over-quantifier`][prefer-over-quantifier]. ([`b9aa62d`][b9aa62d])
- Added rule [`prefer-flat-map`][prefer-flat-map]. ([`8c0dfcb`][8c0dfcb])
- Added [Contribution guidelines][CONTRIBUTING]. ([`0acfdc8`][0acfdc8])
### Changed
- Changed rule `no-unnecessary-bind` to rule [`callback-binding`][callback-binding], that is dependent on major Lodash version specified in the shared settings. ([`a107ad5`][a107ad5])
- Changed all rules to be dependent on major Lodash version specified in settings for method aliases. ([`6f3e204`][6f3e204])
- Changed rule prefer-invoke to [`prefer-invoke-map`][prefer-invoke-map] and made it only relevant for version 4. ([`90d057c`][90d057c])
- Changed rule `no-commit` to not accept forEach cases, and made it only relevant for version 4. ([`c28ba30`][c28ba30])
- Changed rule [`matches-shorthand`][matches-shorthand] "always" option to report only when there are multiple properties or when the resulting object can be shortened to `{property}` syntax. ([`30fde0e`][30fde0e]).
- Changed rule [`matches-prop-shorthand`][matches-prop-shorthand] "never" option to report on the syntax depending on the version. ([`b17c145`][b17c145])
[e4dc506]: https://github.com/wix/eslint-plugin-lodash3/commit/e4dc50681ee667e3111fedd6dbd6147f9c4fa7b0
[ee23d5b]: https://github.com/wix/eslint-plugin-lodash3/commit/ee23d5bef217650f083f6f4b98e041b18c1be68c
[a107ad5]: https://github.com/wix/eslint-plugin-lodash3/commit/a107ad5f7ee523bc1131d5ebb9ffc68b1935038c
[6f3e204]: https://github.com/wix/eslint-plugin-lodash3/commit/6f3e2043bf30f925f7cd0840e115402dd5b40fbc
[b9aa62d]: https://github.com/wix/eslint-plugin-lodash3/commit/b9aa62db63698e9458062b240467d493eb94c0d5
[8c0dfcb]: https://github.com/wix/eslint-plugin-lodash3/commit/8c0dfcb4706d275ae669c65bb5942e462b7c5f65
[0acfdc8]: https://github.com/wix/eslint-plugin-lodash3/commit/0acfdc85afa70da7150c481048fa2fc124612f0b
[90d057c]: https://github.com/wix/eslint-plugin-lodash3/commit/90d057c3e298349a13ea2fcc0fcbae15702351f1
[c28ba30]: https://github.com/wix/eslint-plugin-lodash3/commit/c28ba30ed567d6ba15f7d048215aa7c6c5376d11
[30fde0e]: https://github.com/wix/eslint-plugin-lodash3/commit/30fde0e779eea7b14f60c6cd9ca8b211acd7dd7f
[b17c145]: https://github.com/wix/eslint-plugin-lodash3/commit/b17c1453ecf06fd2f1df686c26836f0615d5ca57
[1.0.0]: https://github.com/wix/eslint-plugin-lodash/compare/v1.0.0...v0.6.0
[CONTRIBUTING]: /CONTRIBUTING.md
[prefer-is-nil]: docs/rules/prefer-is-nil.md
[callback-binding]: docs/rules/callback-binding.md
[prefer-over-quantifier]: docs/rules/prefer-over-quantifier.md
[prefer-flat-map]: docs/rules/prefer-flat-map.md
[prefer-invoke-map]: docs/rules/prefer-invoke-map.md
[matches-shorthand]: docs/rules/matches-shorthand.md
[matches-prop-shorthand]: docs/rules/matches-prop-shorthand.md
v0.1.2 - Sat, 11 Jul 2015 10:01:38 GMT
--------------------------------------
- [aaebdd5](../../commit/aaebdd5) [fixed] exporting of rule
<!--
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
-->

51

package.json
{
"name": "eslint-plugin-lodash",
"version": "0.1.4",
"description": "ESLint Plugin for use with the lodash library",
"main": "lib/index.js",
"directories": {
"lib": "lib/"
"version": "1.0.0",
"author": "Omer Ganim <ganimomer@gmail.com>",
"description": "Lodash specific linting rules for ESLint",
"main": "index.js",
"scripts": {
"coveralls": "cat ./reports/coverage/lcov.info | coveralls",
"lint": "eslint ./",
"test": "npm run lint && npm run unit-test",
"unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --reporter dot"
},

@@ -12,37 +16,28 @@ "files": [

"README.md",
"index.js",
"lib"
],
"scripts": {
"test": "npm run lint && mocha",
"build": "rm -rf lib && babel src --out-dir lib",
"lint": "eslint ./",
"release": "release"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eslint-plugins/eslint-plugin-lodash.git"
"url": "https://github.com/wix/eslint-plugin-lodash"
},
"author": "Matthew L Smith <mtscout6@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/eslint-plugins/eslint-plugin-lodash/issues"
"homepage": "https://github.com/wix/eslint-plugin-lodash",
"bugs": "https://github.com/wix/eslint-plugin-lodash/issues",
"dependencies": {
"lodash": "4.0.0"
},
"homepage": "https://github.com/eslint-plugins/eslint-plugin-lodash#readme",
"devDependencies": {
"babel": "^5.6.7",
"babel-eslint": "^4.0.5",
"eslint": "^1.0.0",
"eslint-config-airbnb": "0.0.8",
"eslint-plugin-react": "^3.3.2",
"is-my-json-valid": "^2.12.0",
"mocha": "^2.2.5",
"mt-changelog": "^0.6.1",
"release-script": "^0.5.0"
"coveralls": "2.11.4",
"eslint": "1.9.0",
"eslint-config-wix-editor": "0.1.1",
"istanbul": "0.4.0",
"mocha": "2.3.3"
},
"keywords": [
"eslint",
"eslint-plugin",
"eslintplugin",
"eslint",
"lodash"
]
],
"license": "MIT"
}

@@ -1,8 +0,7 @@

ESLint-plugin-lodash
ESLint-Plugin-Lodash
===================
[![Travis Build Status][build-badge]][build]
[![devDependency Status][dev-deps-badge]][dev-deps]
[![Maintenance Status][status-image]][status-url] [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coverage-image]][coverage-url]
lodash specific linting rules for ESLint
Lodash-specific linting rules for ESLint.

@@ -13,30 +12,97 @@ # Installation

npm install eslint
$ npm install eslint
If you installed `ESLint` globally, you have to install lodash plugin globally too. Otherwise, install it locally.
If you installed `ESLint` globally, you have to install the Lodash plugin globally too. Otherwise, install it locally.
$ npm install eslint-plugin-lodash
The rules are specifically written to target ES6 JavaScript, so you'll want to
use the [babel-eslint](https://github.com/babel/babel-eslint) parser.
# Configuration
Add `plugins` section and specify ESLint-plugin-lodash as a plugin.
Add `plugins` section and specify ESLint-Plugin-Lodash as a plugin.
You can additionally add settings for the plugin.
### Shared Rule Settings
These are settings that can be shared by all of the rules. All settings are under the `lodash` inside the general `settings` object. For more info about shared settings, read the [ESLint Configuration Guide](http://eslint.org/docs/user-guide/configuring#adding-shared-settings).
* __pragma__: specifies the name you use for the Lodash variable in your code. Default is `_`.
* __version__: specifies the major Lodash Version you are using (default is `4`).
If you wish to use this plugin with Lodash v3, change this value to 3.
Finally, enable all of the rules that you would like to use.
```json
{
"parser": "babel-eslint",
"plugins": [
"lodash"
]
"plugins": ["lodash"],
"rules": {
"lodash/prop-shorthand": 2,
"lodash/matches-shorthand": [2, "always", 3],
"lodash/matches-prop-shorthand": [2, "always"],
"lodash/prefer-chain": [2, 3],
"lodash/preferred-alias": 2,
"lodash/no-single-chain": 2,
"lodash/prefer-reject": [2, 3],
"lodash/prefer-filter": [2, 3],
"lodash/callback-binding": 2,
"lodash/unwrap": 2,
"lodash/prefer-compact": 2,
"lodash/no-double-unwrap": 2,
"lodash/prefer-map": 2,
"lodash/prefer-wrapper-method": 2,
"lodash/prefer-invoke-map": 2,
"lodash/prefer-thru": 2,
"lodash/prefer-lodash-chain": 2,
"lodash/prefer-lodash-method": 2,
"lodash/prefer-lodash-typecheck": 2,
"lodash/no-commit": 2,
"lodash/prefer-get": [2, 3],
"lodash/collection-return": 2,
"lodash/prefer-matches": [2, 3],
"lodash/prefer-times": 2,
"lodash/prefer-startswith": 2,
"lodash/prefer-noop": 2,
"lodash/prefer-constant": 2,
"lodash/chain-style": [2, "as-needed"],
"lodash/prefer-is-nil": 2,
"lodash/prefer-over-quantifier": 2
}
}
```
Finally, enable all of the rules that you would like to use.
## Configuration for Using with Lodash v3
Out of the box, this plugin supports the use of Lodash v4. To use with Lodash v3, the config needs to specify the version in the `settings`, and can't use some rules:
```json
{
"settings": {
"lodash": {
"version": 3
}
},
"rules": {
"lodash/import": 1,
"lodash/prop-shorthand": 2,
"lodash/matches-shorthand": [2, "always", 3],
"lodash/matches-prop-shorthand": [2, "always"],
"lodash/prefer-chain": [2, 3],
"lodash/preferred-alias": 2,
"lodash/no-single-chain": 2,
"lodash/prefer-reject": [2, 3],
"lodash/prefer-filter": [2, 3],
"lodash/callback-binding": 2,
"lodash/unwrap": 2,
"lodash/prefer-compact": 2,
"lodash/no-double-unwrap": 2,
"lodash/prefer-map": 2,
"lodash/prefer-wrapper-method": 2,
"lodash/prefer-thru": 2,
"lodash/prefer-lodash-chain": 2,
"lodash/prefer-lodash-method": 2,
"lodash/prefer-lodash-typecheck": 2,
"lodash/no-commit": 2,
"lodash/prefer-get": [2, 3],
"lodash/collection-return": 2,
"lodash/prefer-matches": [2, 3],
"lodash/prefer-times": 2,
"lodash/prefer-startswith": 2,
"lodash/prefer-noop": 2,
"lodash/prefer-constant": 2,
"lodash/chain-style": [2, "as-needed"]
}

@@ -46,20 +112,65 @@ }

# List of supported rules
# List of provided rules
Rules are divided into categories for your convenience. All rules are off by default.
### Possible Errors
The following rules point out areas where you might have made mistakes.
* [import](docs/rules/import.md): Prevent importing the entire lodash (or lodash-compat) library.
* [callback-binding](docs/rules/callback-binding.md): Use or avoid `thisArg` for Lodash method callbacks, depending on major version.
* [unwrap](docs/rules/unwrap.md): Prevent chaining without evaluation via `value()` or non-chainable methods like `max()`.,
* [no-double-unwrap](docs/rules/no-double-unwrap.md): Do not use `.value()` on chains that have already ended (e.g. with `max()` or `reduce()`)
* [collection-return](docs/rules/collection-return.md): Always return a value in iteratees of Lodash collection methods that aren't `forEach`.
## To Do
### Stylistic Issues
These rules are purely matters of style and are quite subjective.
* [prop-shorthand](docs/rules/prop-shorthand.md): Use/forbid property shorthand syntax.
* [matches-prop-shorthand](docs/rules/matches-prop-shorthand.md): Prefer matches property shorthand syntax
* [matches-shorthand](docs/rules/matches-shorthand.md): Prefer matches shorthand syntax
* [preferred-alias](docs/rules/preferred-alias.md): Prefer using main method names instead of aliases
* [prefer-chain](docs/rules/prefer-chain.md): Prefer a Lodash chain over nested Lodash calls
* [no-single-chain](docs/rules/no-single-chain.md): Prevent chaining syntax for single method, e.g. `_(x).map().value()`
* [prefer-reject](docs/rules/prefer-reject.md): Prefer `_.reject` over filter with `!(expression)` or `x.prop1 !== value`
* [prefer-filter](docs/rules/prefer-filter.md): Prefer `_.filter` over `_.forEach` with an `if` statement inside.
* [prefer-compact](docs/rules/prefer-compact.md): Prefer `_.compact` over `_.filter` for only truthy values.
* [prefer-map](docs/rules/prefer-map.md): Prefer `_.map` over `_.forEach` with a `push` inside.
* [prefer-wrapper-method](docs/rules/prefer-wrapper-method.md): Prefer using array and string methods in the chain and not the initial value, e.g. `_(str).split(' ')...`
* [prefer-invoke-map](docs/rules/prefer-invoke-map.md): Prefer using `_.invoke` over `_.map` with a method call inside.
* [prefer-thru](docs/rules/prefer-thru.md): Prefer using `_.prototype.thru` in the chain and not call functions in the initial value, e.g. `_(x).thru(f).map(g)...`
* [no-commit](docs/rules/no-commit.md): Do not use `.commit()` on chains that should end with `.value()`
* [chain-style](docs/rules/chain-style.md): Enforce a specific chain style: explicit, implicit, or explicit only when necessary.
* [prefer-flat-map](docs/rules/prefer-flat-map.md) Prefer `_.flatMap` over consecutive `map` and `flatten`.
* Add Contributing Guide, until then PRs welcome!
#### Preference over native
These rules are also stylistic choices, but they also recommend using Lodash instead of native functions and constructs.
* [prefer-lodash-chain](docs/rules/prefer-lodash-chain.md): Prefer using Lodash chains (e.g. `_.map`) over native and mixed chains.
* [prefer-lodash-method](docs/rules/prefer-lodash-method.md): Prefer using Lodash collection methods (e.g. `_.map`) over native array methods.
* [prefer-lodash-typecheck](docs/rules/prefer-lodash-typecheck.md): Prefer using `_.is*` methods over `typeof` and `instanceof` checks when applicable.
* [prefer-get](docs/rules/prefer-get.md): Prefer using `_.get` or `_.has` over expression chains like `a && a.b && a.b.c`.
* [prefer-matches](docs/rules/prefer-matches.md): Prefer `_.matches` over conditions like `a.foo === 1 && a.bar === 2 && a.baz === 3`.
* [prefer-times](docs/rules/prefer-times.md): Prefer `_.times` over `_.map` without using the iteratee's arguments.
* [prefer-startswth](docs/rules/prefer-startswith.md): Prefer `_.startsWith` over `a.indexOf(b) === 0`.
* [prefer-noop](docs/rules/prefer-noop.md): Prefer `_.noop` over empty functions.
* [prefer-constant](docs/rules/prefer-constant.md): Prefer `_.constant` over functions returning literals.
* [prefer-is-nil](docs/rules/prefer-is-nil.md): Prefer `_.isNil` over checks for both null and undefined.
* [prefer-over-quantifier](docs/rules/prefer-over-quantifier.md) Prefer `_.overSome` and `_.overEvery` instead of checks with `&&` and `||` for methods that have a boolean check iteratee.
[Any rule idea is welcome !](https://github.com/eslint-plugins/eslint-plugin-lodash/issues)
# Contributing
Contributions are always welcome! For more info, read our [contribution guide](/CONTRIBUTING.md).
# License
ESLint-plugin-lodash is licensed under the [MIT License](LICENSE).
ESLint-plugin-lodash is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
[build-badge]: https://travis-ci.org/eslint-plugins/eslint-plugin-lodash.svg?branch=master
[build]: https://travis-ci.org/eslint-plugins/eslint-plugin-lodash
[npm-url]: https://npmjs.org/package/eslint-plugin-lodash
[npm-image]: http://img.shields.io/npm/v/eslint-plugin-lodash.svg?style=flat-square
[dev-deps-badge]: https://david-dm.org/eslint-plugins/eslint-plugin-lodash/dev-status.svg
[dev-deps]: https://david-dm.org/eslint-plugins/eslint-plugin-lodash#info=devDependencies
[travis-url]: https://travis-ci.org/wix/eslint-plugin-lodash
[travis-image]: http://img.shields.io/travis/wix/eslint-plugin-lodash/master.svg?style=flat-square
[deps-url]: https://david-dm.org/wix/eslint-plugin-lodash
[deps-image]: https://img.shields.io/david/dev/wix/eslint-plugin-lodash.svg?style=flat-square
[coverage-url]: https://coveralls.io/r/wix/eslint-plugin-lodash?branch=master
[coverage-image]: http://img.shields.io/coveralls/wix/eslint-plugin-lodash/master.svg?style=flat-square
[status-url]: https://github.com/wix/eslint-plugin-lodash/pulse
[status-image]: http://img.shields.io/badge/status-maintained-brightgreen.svg?style=flat-square
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