detect-eval-with-expression.js 578 B

123456789101112131415161718192021
  1. /**
  2. * Idnetifies eval with expression
  3. * @author Adam Baldwin
  4. */
  5. //------------------------------------------------------------------------------
  6. // Rule Definition
  7. //------------------------------------------------------------------------------
  8. module.exports = function(context) {
  9. "use strict";
  10. return {
  11. "CallExpression": function(node) {
  12. if (node.callee.name === "eval" && node.arguments[0].type !== 'Literal') {
  13. context.report(node, "eval with argument of type " + node.arguments[0].type);
  14. }
  15. }
  16. };
  17. };