1/** 2 * @fileoverview Require use of new Buffer constructor methods in lib 3 * @author James M Snell 4 */ 5'use strict'; 6 7//------------------------------------------------------------------------------ 8// Rule Definition 9//------------------------------------------------------------------------------ 10const msg = 'Use of the Buffer() constructor has been deprecated. ' + 11 'Please use either Buffer.alloc(), Buffer.allocUnsafe(), ' + 12 'or Buffer.from()'; 13 14function test(context, node) { 15 if (node.callee.name === 'Buffer') { 16 context.report(node, msg); 17 } 18} 19 20module.exports = function(context) { 21 return { 22 'NewExpression': (node) => test(context, node), 23 'CallExpression': (node) => test(context, node) 24 }; 25}; 26