eslint-plugin-lodash
Version:
Lodash specific linting rules for ESLint
31 lines (25 loc) • 905 B
JavaScript
/**
* @fileoverview Rule to prefer _.noop over an empty function
*/
;
/**
* @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
};
}
};