UNPKG

eslint-plugin-lodash

Version:

Lodash specific linting rules for ESLint

33 lines (26 loc) 1.09 kB
/** * @fileoverview Rule to check if a call to map should be a call to times */ 'use strict'; /** * @fileoverview Rule to check if a call to map should be a call to times */ //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { create: function create(context) { var _require = require('../util/lodashUtil'); var getLodashMethodVisitors = _require.getLodashMethodVisitors; var _require2 = require('../util/methodDataUtil'); var isAliasOfMethod = _require2.isAliasOfMethod; var get = require('lodash/get'); return getLodashMethodVisitors(context, function (node, iteratee, _ref) { var method = _ref.method; var version = _ref.version; if (isAliasOfMethod(version, 'map', method) && get(iteratee, 'params.length') === 0) { context.report(node, 'Prefer _.times over _.map without using arguments'); } }); } };