UNPKG

eslint-plugin-lodash

Version:

Lodash specific linting rules for ESLint

31 lines (25 loc) 905 B
/** * @fileoverview Rule to prefer _.noop over an empty function */ 'use strict'; /** * @fileoverview Rule to prefer _.noop over an empty function */ //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { create: function create(context) { var _require = require('../util/astUtil'); var getFirstFunctionLine = _require.getFirstFunctionLine; function reportIfEmptyFunction(node) { if (!getFirstFunctionLine(node) && node.parent.type !== 'MethodDefinition') { context.report(node, 'Prefer _.noop over an empty function'); } } return { FunctionExpression: reportIfEmptyFunction, ArrowFunctionExpression: reportIfEmptyFunction }; } };