UNPKG

canonical

Version:

Canonical code style linter and formatter for JavaScript, SCSS, CSS and JSON.

24 lines (19 loc) 666 B
/** * @fileoverview Rule to prefer _.noop over an empty function */ 'use strict'; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function (context) { var astUtil = require('../util/astUtil'); function reportIfEmptyFunction(node) { if (!astUtil.getFirstFunctionLine(node)) { context.report(node, 'Prefer _.noop over an empty function'); } } return { FunctionExpression: reportIfEmptyFunction, ArrowFunctionExpression: reportIfEmptyFunction }; };