Skip to content

Commit c969ef7

Browse files
committed
lib: rename functions named value
1 parent a44ccac commit c969ef7

File tree

10 files changed

+55
-47
lines changed

10 files changed

+55
-47
lines changed

eslint.config.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ export default [
173173
'default-case-last': 'error',
174174
'dot-notation': 'error',
175175
'eqeqeq': ['error', 'smart'],
176-
'func-name-matching': 'error',
176+
177+
// TODO: make this rule consider primordials
178+
'func-name-matching': ['error', { considerPropertyDescriptor: true }],
179+
177180
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
178181
'no-constant-condition': ['error', { checkLoops: false }],
179182
'no-constructor-return': 'error',

lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function exists(path, callback) {
253253

254254
ObjectDefineProperty(exists, kCustomPromisifiedSymbol, {
255255
__proto__: null,
256-
value: function exists(path) { // eslint-disable-line func-name-matching
256+
value: function exists(path) {
257257
return new Promise((resolve) => fs.exists(path, resolve));
258258
},
259259
});

lib/internal/bootstrap/web/exposed-window-or-worker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ObjectDefineProperty(globalThis, 'fetch', {
7575
configurable: true,
7676
enumerable: true,
7777
writable: true,
78-
value: function fetch(input, init = undefined) { // eslint-disable-line func-name-matching
78+
value: function fetch(input, init = undefined) {
7979
if (!fetchImpl) { // Implement lazy loading of undici module for fetch function
8080
const undiciModule = require('internal/deps/undici/undici');
8181
fetchImpl = undiciModule.fetch;

lib/internal/console/constructor.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const {
4949
} = require('internal/validators');
5050
const { previewEntries } = internalBinding('util');
5151
const { Buffer: { isBuffer } } = require('buffer');
52+
const { assignFunctionName } = require('internal/util');
5253
const {
5354
inspect,
5455
formatWithOptions,
@@ -172,9 +173,9 @@ const consolePropAttributes = {
172173
// Fixup global.console instanceof global.console.Console
173174
ObjectDefineProperty(Console, SymbolHasInstance, {
174175
__proto__: null,
175-
value(instance) {
176+
value: assignFunctionName(SymbolHasInstance, function(instance) {
176177
return instance[kIsConsole];
177-
},
178+
}),
178179
});
179180

180181
const kColorInspectOptions = { colors: true };
@@ -187,19 +188,19 @@ ObjectDefineProperties(Console.prototype, {
187188
__proto__: null,
188189
...consolePropAttributes,
189190
// Eager version for the Console constructor
190-
value: function(stdout, stderr) {
191+
value: assignFunctionName(kBindStreamsEager, function(stdout, stderr) {
191192
ObjectDefineProperties(this, {
192193
'_stdout': { __proto__: null, ...consolePropAttributes, value: stdout },
193194
'_stderr': { __proto__: null, ...consolePropAttributes, value: stderr },
194195
});
195-
},
196+
}),
196197
},
197198
[kBindStreamsLazy]: {
198199
__proto__: null,
199200
...consolePropAttributes,
200201
// Lazily load the stdout and stderr from an object so we don't
201202
// create the stdio streams when they are not even accessed
202-
value: function(object) {
203+
value: assignFunctionName(kBindStreamsLazy, function(object) {
203204
let stdout;
204205
let stderr;
205206
ObjectDefineProperties(this, {
@@ -222,12 +223,12 @@ ObjectDefineProperties(Console.prototype, {
222223
set(value) { stderr = value; },
223224
},
224225
});
225-
},
226+
}),
226227
},
227228
[kBindProperties]: {
228229
__proto__: null,
229230
...consolePropAttributes,
230-
value: function(ignoreErrors, colorMode, groupIndentation = 2) {
231+
value: assignFunctionName(kBindProperties, function(ignoreErrors, colorMode, groupIndentation = 2) {
231232
ObjectDefineProperties(this, {
232233
'_stdoutErrorHandler': {
233234
__proto__: null,
@@ -262,12 +263,12 @@ ObjectDefineProperties(Console.prototype, {
262263
value: 'console',
263264
},
264265
});
265-
},
266+
}),
266267
},
267268
[kWriteToConsole]: {
268269
__proto__: null,
269270
...consolePropAttributes,
270-
value: function(streamSymbol, string) {
271+
value: assignFunctionName(kWriteToConsole, function(streamSymbol, string) {
271272
const ignoreErrors = this._ignoreErrors;
272273
const groupIndent = internalIndentationMap.get(this) || '';
273274

@@ -305,12 +306,12 @@ ObjectDefineProperties(Console.prototype, {
305306
} finally {
306307
stream.removeListener('error', noop);
307308
}
308-
},
309+
}),
309310
},
310311
[kGetInspectOptions]: {
311312
__proto__: null,
312313
...consolePropAttributes,
313-
value: function(stream) {
314+
value: assignFunctionName(kGetInspectOptions, function(stream) {
314315
let color = this[kColorMode];
315316
if (color === 'auto') {
316317
color = lazyUtilColors().shouldColorize(stream);
@@ -325,25 +326,25 @@ ObjectDefineProperties(Console.prototype, {
325326
}
326327

327328
return color ? kColorInspectOptions : kNoColorInspectOptions;
328-
},
329+
}),
329330
},
330331
[kFormatForStdout]: {
331332
__proto__: null,
332333
...consolePropAttributes,
333-
value: function(args) {
334+
value: assignFunctionName(kFormatForStdout, function(args) {
334335
const opts = this[kGetInspectOptions](this._stdout);
335336
ArrayPrototypeUnshift(args, opts);
336337
return ReflectApply(formatWithOptions, null, args);
337-
},
338+
}),
338339
},
339340
[kFormatForStderr]: {
340341
__proto__: null,
341342
...consolePropAttributes,
342-
value: function(args) {
343+
value: assignFunctionName(kFormatForStderr, function(args) {
343344
const opts = this[kGetInspectOptions](this._stderr);
344345
ArrayPrototypeUnshift(args, opts);
345346
return ReflectApply(formatWithOptions, null, args);
346-
},
347+
}),
347348
},
348349
});
349350

lib/internal/per_context/domexception.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function throwInvalidThisError(Base, type) {
2626
},
2727
toString: {
2828
__proto__: null,
29-
value() {
29+
value: function toString() {
3030
return `${this.name} [${key}]: ${this.message}`;
3131
},
3232
enumerable: false,

lib/internal/streams/writable.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const {
8585
kOnConstructed,
8686
} = require('internal/streams/utils');
8787

88+
const { assignFunctionName } = require('internal/util');
89+
8890
const { errorOrDestroy } = destroyImpl;
8991

9092
ObjectSetPrototypeOf(Writable.prototype, Stream.prototype);
@@ -435,12 +437,12 @@ function Writable(options) {
435437

436438
ObjectDefineProperty(Writable, SymbolHasInstance, {
437439
__proto__: null,
438-
value: function(object) {
439-
if (FunctionPrototypeSymbolHasInstance(this, object)) return true;
440+
value: assignFunctionName(SymbolHasInstance, function(instance) {
441+
if (FunctionPrototypeSymbolHasInstance(this, instance)) return true;
440442
if (this !== Writable) return false;
441443

442-
return object && object._writableState instanceof WritableState;
443-
},
444+
return instance && instance._writableState instanceof WritableState;
445+
}),
444446
});
445447

446448
// Otherwise people can pipe Writable streams, which is just wrong.

lib/internal/util/types.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -76,40 +76,40 @@ module.exports = {
7676
isBigUint64Array,
7777
};
7878

79-
let isCryptoKey;
80-
let isKeyObject;
79+
let isCryptoKeyFn;
80+
let isKeyObjectFn;
8181

8282
ObjectDefineProperties(module.exports, {
8383
isKeyObject: {
8484
__proto__: null,
8585
configurable: false,
8686
enumerable: true,
87-
value(obj) {
87+
value: function isKeyObject(obj) {
8888
if (!process.versions.openssl) {
8989
return false;
9090
}
9191

92-
if (!isKeyObject) {
93-
({ isKeyObject } = require('internal/crypto/keys'));
92+
if (!isKeyObjectFn) {
93+
({ isKeyObject: isKeyObjectFn } = require('internal/crypto/keys'));
9494
}
9595

96-
return isKeyObject(obj);
96+
return isKeyObjectFn(obj);
9797
},
9898
},
9999
isCryptoKey: {
100100
__proto__: null,
101101
configurable: false,
102102
enumerable: true,
103-
value(obj) {
103+
value: function isCryptoKey(obj) {
104104
if (!process.versions.openssl) {
105105
return false;
106106
}
107107

108-
if (!isCryptoKey) {
109-
({ isCryptoKey } = require('internal/crypto/keys'));
108+
if (!isCryptoKeyFn) {
109+
({ isCryptoKey: isCryptoKeyFn } = require('internal/crypto/keys'));
110110
}
111111

112-
return isCryptoKey(obj);
112+
return isCryptoKeyFn(obj);
113113
},
114114
},
115115
});

lib/internal/worker/io.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
} = primordials;
1919

2020
const {
21+
assignFunctionName,
2122
kEnumerableProperty,
2223
setOwnProperty,
2324
} = require('internal/util');
@@ -131,14 +132,14 @@ ObjectDefineProperty(
131132
kCreateEvent,
132133
{
133134
__proto__: null,
134-
value: function(data, type) {
135+
value: assignFunctionName(kCreateEvent, function(data, type) {
135136
if (type !== 'message' && type !== 'messageerror') {
136137
return ReflectApply(originalCreateEvent, this, arguments);
137138
}
138139
const ports = this[kCurrentlyReceivingPorts];
139140
this[kCurrentlyReceivingPorts] = undefined;
140141
return lazyMessageEvent(type, { data, ports });
141-
},
142+
}),
142143
configurable: false,
143144
writable: false,
144145
enumerable: false,
@@ -189,7 +190,7 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, {
189190
__proto__: null,
190191
enumerable: false,
191192
writable: false,
192-
value: function inspect() { // eslint-disable-line func-name-matching
193+
value: function inspect() {
193194
let ref;
194195
try {
195196
// This may throw when `this` does not refer to a native object,

lib/test/reporters.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const {
77

88
let dot;
99
let junit;
10-
let spec;
10+
let specFn;
1111
let tap;
12-
let lcov;
12+
let lcovFn;
1313

1414
ObjectDefineProperties(module.exports, {
1515
__proto__: null,
@@ -35,9 +35,9 @@ ObjectDefineProperties(module.exports, {
3535
__proto__: null,
3636
configurable: true,
3737
enumerable: true,
38-
value: function value() {
39-
spec ??= require('internal/test_runner/reporter/spec');
40-
return ReflectConstruct(spec, arguments);
38+
value: function spec() {
39+
specFn ??= require('internal/test_runner/reporter/spec');
40+
return ReflectConstruct(specFn, arguments);
4141
},
4242
},
4343
tap: {
@@ -53,9 +53,9 @@ ObjectDefineProperties(module.exports, {
5353
__proto__: null,
5454
configurable: true,
5555
enumerable: true,
56-
value: function value() {
57-
lcov ??= require('internal/test_runner/reporter/lcov');
58-
return ReflectConstruct(lcov, arguments);
56+
value: function lcov() {
57+
lcovFn ??= require('internal/test_runner/reporter/lcov');
58+
return ReflectConstruct(lcovFn, arguments);
5959
},
6060
},
6161
});

lib/zlib.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const {
4848
} = require('internal/errors');
4949
const { Transform, finished } = require('stream');
5050
const {
51+
assignFunctionName,
5152
deprecateInstantiation,
5253
} = require('internal/util');
5354
const {
@@ -914,9 +915,9 @@ function createProperty(ctor) {
914915
__proto__: null,
915916
configurable: true,
916917
enumerable: true,
917-
value: function(options) {
918+
value: assignFunctionName(`create${ctor.name}`, function(options) {
918919
return new ctor(options);
919-
},
920+
}),
920921
};
921922
}
922923

0 commit comments

Comments
 (0)