Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buffer-eslint

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffer-eslint

eslint rule for Buffer constructor deprecation

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Buffer constructor lint rule

A eslint rule for checking for Buffer() and new Buffer() usage.

Starting in Node.js 6.0.0, the Buffer() and new Buffer() constructor was deprecated in favor of the new Buffer.alloc(), Buffer.allocUnsafe(), and Buffer.from() construction methods due to usability and security concerns.

buffer_constructor

The buffer_constructor rule checks for uses of Buffer() and new Buffer().

Example

File sample.js:

// Invalid

new Buffer(1);
Buffer(1);

new Buffer('test');
Buffer('test');

// Valid

Buffer.alloc(1);
Buffer.allocUnsafe(1);
Buffer.from('test');

Configuration .eslintrc:

{
  "rules": {
    "buffer_constructor": 2
  }
}

Running eslint --rulesdir {path-to-rule} sample.js

Generates:

  3:1  error  Use of the Buffer() constructor has been deprecated. Please use either Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from()  buffer_constructor
  4:1  error  Use of the Buffer() constructor has been deprecated. Please use either Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from()  buffer_constructor
  6:1  error  Use of the Buffer() constructor has been deprecated. Please use either Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from()  buffer_constructor
  7:1  error  Use of the Buffer() constructor has been deprecated. Please use either Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from()  buffer_constructor

✖ 4 problems (4 errors, 0 warnings)

FAQs

Package last updated on 07 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc