detect-new-buffer.js 406 B

12345678910111213141516171819
  1. module.exports = function (context) {
  2. // Detects instances of new Buffer(argument)
  3. // where argument is any non literal value.
  4. return {
  5. "NewExpression": function (node) {
  6. if (node.callee.name === 'Buffer' &&
  7. node.arguments[0] &&
  8. node.arguments[0].type != 'Literal') {
  9. return context.report(node, "Found new Buffer");
  10. }
  11. }
  12. };
  13. }