Breaking: deprecate safe-buffer.Buffer calls #110
Merged
+4
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
safe-buffer.Buffer
function/constructor is just a re-export ofbuffer.Buffer
and should be deprecated likewise.Otherwise, using
Buffer = require('safe-buffer').Buffer
magically hides the deprecation message, which it shouldn't, as that code will actually cause runtime deprecation errors on Node.js >= 10.In fact, ecosystem analysis shows that people do that a lot to silence
standard
linter — they see a recommendation to usesafe-buffer
in the warning, they throw invar Buffer = require('buffer').Buffer
, the warning goes away, nothing actually changes.Example:
Also, even if they migrate to the new API and install
safe-buffer
for the actual polyfills, the fact that that line alone disables the deprecation message makes them overlook calls to the old API.Examples:
Old Buffer API is going to be runtime-deprecated in Node.js 10.0 (nodejs/node#19079) and
require('safe-buffer').Buffer(arg)
actually hits that deprecated API, so this change is needed for developers to spot those issues that would soon become runtime warnings, in advance.eslint-plugin-node
was already helping developers to spot that deprecated Buffer API usage in advance, but only until they putBuffer = require('safe-buffer').Buffer
into their code (and they do that a lot, since that's the recommended way to keep older Node.js versions support).Actually, I am not even sure if this should be a breaking or a bugfix change. Thoughts?
/cc @Trott, @feross .