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 3.0.0 to 3.1.0

10

CHANGELOG.md

@@ -11,4 +11,12 @@ # Change Log

[unreleased]: https://github.com/wix/eslint-plugin-lodash/compare/v3.0.0...HEAD
[unreleased]: https://github.com/wix/eslint-plugin-lodash/compare/v3.1.0...HEAD
## [3.1.0] - 2018-09-19
### Added
- Added `implicit` option to `chaining`. ([`c4cbbce`][c4cbbce])
[170e31f]: https://github.com/wix/eslint-plugin-lodash/commit/c4cbbcee438ca5c069f95da90e6aaaee34230296
[3.1.0]: https://github.com/wix/eslint-plugin-lodash/compare/v3.1.0...v3.0.0
## [3.0.0] - 2018-09-19

@@ -15,0 +23,0 @@ ### Fixed

2

lib/index.js

@@ -77,3 +77,3 @@ 'use strict';

'lodash/chain-style': [2, 'as-needed'],
'lodash/chaining': [2, 'always'],
'lodash/chaining': [2, 'implicit'],
'lodash/collection-method-value': 2,

@@ -80,0 +80,0 @@ 'lodash/collection-return': 2,

@@ -18,7 +18,12 @@ /**

schema: [{
enum: ['always', 'never']
enum: ['always', 'never', 'implicit']
}, {
type: 'integer',
minimum: 2
}]
}],
messages: {
single: 'Do not use chain syntax for single method',
never: 'Prefer composition to Lodash chaining',
always: 'Prefer chaining to composition'
}
},

@@ -33,4 +38,8 @@

isMethodCall = _require2.isMethodCall,
isObjectOfMethodCall = _require2.isObjectOfMethodCall;
isObjectOfMethodCall = _require2.isObjectOfMethodCall,
getMethodName = _require2.getMethodName;
var _require3 = require('../util/methodDataUtil'),
isChainable = _require3.isChainable;
var DEFAULT_LENGTH = 3;

@@ -50,18 +59,32 @@ var lodashContext = getLodashContext(context);

function isNestedNLevels(node, n) {
function isNestedNLevelsInner(node, n, includeUnchainable) {
if (n === 0) {
return true;
} else if (lodashContext.isLodashCall(node) || lodashContext.getImportedLodashMethod(node)) {
return isNestedNLevels(node.arguments[0], n - 1);
}
if (lodashContext.isLodashCall(node) && (includeUnchainable || isChainable(version, getMethodName(node)))) {
return isNestedNLevelsInner(node.arguments[0], n - 1);
}
var importedLodashMethod = lodashContext.getImportedLodashMethod(node);
if (importedLodashMethod && (includeUnchainable || isChainable(version, importedLodashMethod))) {
return isNestedNLevelsInner(node.arguments[0], n - 1);
}
}
function isNestedNLevels(node, n, includeUnchainable) {
if (includeUnchainable) {
return isNestedNLevelsInner(node, n, includeUnchainable);
}
if (lodashContext.isLodashCall(node) || lodashContext.getImportedLodashMethod(node)) {
return isNestedNLevelsInner(node.arguments[0], n - 1, false);
}
}
var callExpressionVisitors = {
always: function always(node) {
if (isNestedNLevels(node, ruleDepth)) {
context.report({ node: node, message: 'Prefer chaining to composition' });
if (isNestedNLevels(node, ruleDepth, true)) {
context.report({ node: node, messageId: 'always' });
} else if (lodashContext.isLodashChainStart(node)) {
var firstCall = node.parent.parent;
if (isMethodCall(firstCall) && (isEndOfChain(firstCall) || isBeforeChainBreaker(firstCall))) {
context.report({ node: firstCall, message: 'Do not use chain syntax for single method' });
context.report({ node: firstCall, messageId: 'single' });
}

@@ -72,4 +95,14 @@ }

if (lodashContext.isLodashChainStart(node)) {
context.report({ node: node, message: 'Prefer composition to Lodash chaining' });
context.report({ node: node, messageId: 'never' });
}
},
implicit: function implicit(node) {
if (isNestedNLevels(node, ruleDepth, false)) {
context.report({ node: node, messageId: 'always' });
} else if (lodashContext.isLodashChainStart(node)) {
var firstCall = node.parent.parent;
if (isMethodCall(firstCall) && (isEndOfChain(firstCall) || isBeforeChainBreaker(firstCall))) {
context.report({ node: firstCall, messageId: 'single' });
}
}
}

@@ -76,0 +109,0 @@ };

{
"name": "eslint-plugin-lodash",
"version": "3.0.0",
"version": "3.1.0",
"author": "Omer Ganim <ganimomer@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Lodash specific linting rules for ESLint",

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