Blame view

node_modules/eslint/lib/rules/no-new-func.js 1008 Bytes
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
  /**
   * @fileoverview Rule to flag when using new Function
   * @author Ilya Volodin
   */
  
  "use strict";
  
  //------------------------------------------------------------------------------
  // Rule Definition
  //------------------------------------------------------------------------------
  
  module.exports = function(context) {
  
      //--------------------------------------------------------------------------
      // Helpers
      //--------------------------------------------------------------------------
  
      /**
       * Checks if the callee if the Function constructor, and if so, reports an issue.
       * @param {ASTNode} node The node to check and report on
       * @returns {void}
       * @private
       */
      function validateCallee(node) {
          if (node.callee.name === "Function") {
              context.report(node, "The Function constructor is eval.");
          }
      }
  
      return {
          "NewExpression": validateCallee,
          "CallExpression": validateCallee
      };
  
  };
  
  module.exports.schema = [];