Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
buffer-eslint
Advanced tools
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.
The buffer_constructor
rule checks for uses of Buffer()
and new Buffer()
.
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
eslint rule for Buffer constructor deprecation
The npm package buffer-eslint receives a total of 0 weekly downloads. As such, buffer-eslint popularity was classified as not popular.
We found that buffer-eslint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.