UNPKG

eslint-plugin-lodash

Version:

Lodash specific linting rules for ESLint

35 lines (28 loc) 1.4 kB
/** * @fileoverview Rule to check if there's a method in the chain start that can be in the chain */ 'use strict'; /** * @fileoverview Rule to check if there's a method in the chain start that can be in the chain */ //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { create: function create(context) { var _require = require('../util/lodashUtil'); var isLodashChainStart = _require.isLodashChainStart; var isLodashWrapperMethod = _require.isLodashWrapperMethod; var getLodashImportVisitors = _require.getLodashImportVisitors; var settings = require('../util/settingsUtil').getSettings(context); var _require2 = require('../util/ruleUtil'); var combineVisitorObjects = _require2.combineVisitorObjects; return combineVisitorObjects({ CallExpression: function CallExpression(node) { if (isLodashChainStart(node, settings.pragma, context) && isLodashWrapperMethod(node.arguments[0], settings.version)) { context.report(node, 'Prefer {{name}} with wrapper method over inside the chain start.', { name: node.arguments[0].callee.property.name }); } } }, getLodashImportVisitors(context)); } };