vesln/stylec

View on GitHub
lib/stylec/rule/fn-max-params.js

Summary

Maintainability
A
1 hr
Test Coverage
/**
 * Internal dependencies.
 */

var Rule = require('../rule');

var MaxParams = Rule.create({
  error: 'The function has too many parameters',

  option: {
    key: 'fnparams',
    type: 'number'
  },

  on: {
    FunctionDeclaration: 'check',
    FunctionExpression: 'check'
  },
});

/**
 * Perform the check.
 *
 * @param {Object} node
 * @api public
 */

MaxParams.prototype.check = function(node) {
  if (node.params.length > this.option()) {
    this.badToken(node);
  }
};

/**
 * Primary export.
 */

module.exports = MaxParams;