Blame view

node_modules/eslint/lib/rules/max-params.js 1.17 KB
c39994410   Ryan Glover   wip converting to...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  /**
   * @fileoverview Rule to flag when a function has too many parameters
   * @author Ilya Volodin
   * @copyright 2014 Nicholas C. Zakas. All rights reserved.
   * @copyright 2013 Ilya Volodin. All rights reserved.
   */
  
  "use strict";
  
  //------------------------------------------------------------------------------
  // Rule Definition
  //------------------------------------------------------------------------------
  
  module.exports = function(context) {
  
      var numParams = context.options[0] || 3;
  
      /**
       * Checks a function to see if it has too many parameters.
       * @param {ASTNode} node The node to check.
       * @returns {void}
       * @private
       */
      function checkFunction(node) {
          if (node.params.length > numParams) {
              context.report(node, "This function has too many parameters ({{count}}). Maximum allowed is {{max}}.", {
                  count: node.params.length,
                  max: numParams
              });
          }
      }
  
      return {
          "FunctionDeclaration": checkFunction,
          "ArrowFunctionExpression": checkFunction,
          "FunctionExpression": checkFunction
      };
  
  };
  
  module.exports.schema = [
      {
          "type": "integer"
      }
  ];