eslint-plugin-lodash
Advanced tools
Comparing version 2.1.7 to 2.1.8
@@ -11,4 +11,11 @@ # Change Log | ||
[unreleased]: https://github.com/wix/eslint-plugin-lodash/compare/v2.1.7...HEAD | ||
[unreleased]: https://github.com/wix/eslint-plugin-lodash/compare/v2.1.8...HEAD | ||
## [2.1.8] - 2016-11-08 | ||
### Fixed | ||
- Improve performance of shorthand rules ([`5eed1ec`][5eed1ec]) | ||
[5eed1ec]: https://github.com/wix/eslint-plugin-lodash/commit/5eed1ecc6900035f51cc72c336bf70abf88b4143 | ||
[2.1.8]: https://github.com/wix/eslint-plugin-lodash/compare/v2.1.8...v2.1.7 | ||
## [2.1.7] - 2016-10-27 | ||
@@ -15,0 +22,0 @@ ### Fixed |
@@ -14,4 +14,2 @@ /** | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
module.exports = { | ||
@@ -25,21 +23,18 @@ meta: { | ||
create: function create(context) { | ||
var _map = ['get', 'matches', 'overSome'].map(function (m) { | ||
return require('lodash/' + m); | ||
}); | ||
var get = require('lodash/get'); | ||
var matches = require('lodash/matches'); | ||
var overSome = require('lodash/overSome'); | ||
var _map2 = _slicedToArray(_map, 3); | ||
var _require = require('../util/methodDataUtil'); | ||
var get = _map2[0]; | ||
var matches = _map2[1]; | ||
var overSome = _map2[2]; | ||
var methodSupportsShorthand = _require.methodSupportsShorthand; | ||
var _require = require('../util/lodashUtil'); | ||
var _require2 = require('../util/lodashUtil'); | ||
var methodSupportsShorthand = _require.methodSupportsShorthand; | ||
var getShorthandVisitors = _require.getShorthandVisitors; | ||
var getShorthandVisitors = _require2.getShorthandVisitors; | ||
var _require2 = require('../util/astUtil'); | ||
var _require3 = require('../util/astUtil'); | ||
var getFirstParamName = _require2.getFirstParamName; | ||
var getValueReturnedInFirstStatement = _require2.getValueReturnedInFirstStatement; | ||
var getFirstParamName = _require3.getFirstParamName; | ||
var getValueReturnedInFirstStatement = _require3.getValueReturnedInFirstStatement; | ||
@@ -46,0 +41,0 @@ var settings = require('../util/settingsUtil').getSettings(context); |
@@ -103,12 +103,2 @@ 'use strict'; | ||
/** | ||
* Returns whether the node's method call supports using shorthands in the specified version | ||
* @param {Number} version | ||
* @param {object} node | ||
* @returns {boolean} | ||
*/ | ||
function methodSupportsShorthand(version, method) { | ||
return _.includes(methodDataUtil.getShorthandMethods(version), method); | ||
} | ||
function isLodashCallToMethod(node, method, lodashContext) { | ||
@@ -140,3 +130,3 @@ return lodashContext.isLodashCall(node) && isCallToMethod(node, lodashContext.version, method); | ||
if (methodSupportsShorthand(version, method) && checks.canUseShorthand(iteratee, lodashContext)) { | ||
if (methodDataUtil.methodSupportsShorthand(version, method) && checks.canUseShorthand(iteratee, lodashContext)) { | ||
context.report(iteratee, messages.always); | ||
@@ -173,3 +163,2 @@ } | ||
getLodashMethodCallExpVisitor: getLodashMethodCallExpVisitor, | ||
methodSupportsShorthand: methodSupportsShorthand, | ||
isCallToLodashMethod: isCallToLodashMethod, | ||
@@ -176,0 +165,0 @@ getShorthandVisitors: getShorthandVisitors, |
'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
@@ -8,2 +10,3 @@ | ||
var _methodDataByVersion = {}; | ||
var _shorthandMethodsByVersion = {}; | ||
function getMethodData(version) { | ||
@@ -75,2 +78,17 @@ _methodDataByVersion[version] = _methodDataByVersion[version] || require('./methodDataByVersion/' + version); | ||
} | ||
/** | ||
* Returns whether the node's method call supports using shorthands in the specified version | ||
* @param {Number} version | ||
* @param {string} method | ||
* @returns {boolean} | ||
*/ | ||
function methodSupportsShorthand(version, method) { | ||
if (!_shorthandMethodsByVersion[version]) { | ||
var methods = getShorthandMethods(version); | ||
_shorthandMethodsByVersion[version] = _.reduce(methods, function (obj, key) { | ||
return _.assign(obj, _defineProperty({}, key, true)); | ||
}, {}); | ||
} | ||
return _shorthandMethodsByVersion[version][method]; | ||
} | ||
@@ -151,2 +169,3 @@ /** | ||
getShorthandMethods: getShorthandMethods, | ||
methodSupportsShorthand: methodSupportsShorthand, | ||
getWrapperMethods: getWrapperMethods, | ||
@@ -153,0 +172,0 @@ getCollectionMethods: getCollectionMethods, |
{ | ||
"name": "eslint-plugin-lodash", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"author": "Omer Ganim <ganimomer@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Lodash specific linting rules for ESLint", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
188248
51
3749
3