lib: remove env: node in eslint config for lib files

This patch removes the redundant `require-globals` custom
eslint rule by removing `env: node` in the eslint config
and whitelist the globals that can be accessed in native
modules instead of black listing them. This makes sense
for our `lib/` files because here we are creating the
Node.js environment instead of running in a normal user
land Node.js environment.

PR-URL: https://github.com/nodejs/node/pull/27082
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Joyee Cheung committed 2019-04-06 12:04:36 +08:00
1 parent 864860e9f3
commit de23055536
12 files changed
+57 -117

No files matched your search

+15 -8
View File
@@ -654,9 +654,10 @@ Buffer.prototype.equals = function equals(otherBuffer) {
return _compare(this, otherBuffer) === 0;
};
let INSPECT_MAX_BYTES = 50;
// Override how buffers are presented by util.inspect().
Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
const max = exports.INSPECT_MAX_BYTES;
const max = INSPECT_MAX_BYTES;
const actualMax = Math.min(max, this.length);
const remaining = this.length - max;
let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
@@ -1089,19 +1090,25 @@ if (internalBinding('config').hasIntl) {
};
}
module.exports = exports = {
module.exports = {
Buffer,
SlowBuffer,
transcode,
INSPECT_MAX_BYTES: 50,
// Legacy
kMaxLength,
kStringMaxLength
};
Object.defineProperty(exports, 'constants', {
configurable: false,
enumerable: true,
value: constants
Object.defineProperties(module.exports, {
constants: {
configurable: false,
enumerable: true,
value: constants
},
INSPECT_MAX_BYTES: {
configurable: true,
enumerable: true,
get() { return INSPECT_MAX_BYTES; },
set(val) { INSPECT_MAX_BYTES = val; }
}
});