mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
0c1dee5089
PR-URL: https://github.com/nodejs/node/pull/17572 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
21 lines
707 B
JavaScript
21 lines
707 B
JavaScript
/**
|
|
* @fileoverview Require use of new Buffer constructor methods in lib
|
|
* @author James M Snell
|
|
*/
|
|
'use strict';
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
const msg = 'Use of the Buffer() constructor has been deprecated. ' +
|
|
'Please use either Buffer.alloc(), Buffer.allocUnsafe(), ' +
|
|
'or Buffer.from()';
|
|
const astSelector = 'NewExpression[callee.name="Buffer"],' +
|
|
'CallExpression[callee.name="Buffer"]';
|
|
|
|
module.exports = function(context) {
|
|
return {
|
|
[astSelector]: (node) => context.report(node, msg)
|
|
};
|
|
};
|