Skip to content

unicorn/no-new-buffer Pedantic ​

🚧 An auto-fix is still under development.

What it does ​

Disallows the deprecated new Buffer() constructor.

Why is this bad? ​

Enforces the use of Buffer.from and Buffer.alloc() instead of new Buffer(), which has been deprecated since Node.js 4.

Example ​

Examples of incorrect code for this rule:

javascript
const buffer = new Buffer(10);

Examples of correct code for this rule:

javascript
const buffer = Buffer.alloc(10);

References ​

Released under the MIT License.