Skip to content

Commit f9ddd77

Browse files
committed
tools: add lint rule to keep primordials in ASCII order
PR-URL: #52592 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent eeb80ad commit f9ddd77

File tree

96 files changed

+336
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+336
-189
lines changed

lib/.eslintrc.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ rules:
185185
- groups: [['&&', '||']]
186186

187187
# Custom rules in tools/eslint-rules
188+
node-core/alphabetize-primordials: error
188189
node-core/avoid-prototype-pollution: error
189190
node-core/lowercase-name-for-primitive: error
190191
node-core/non-ascii-character: error
@@ -266,3 +267,7 @@ globals:
266267
module: false
267268
internalBinding: false
268269
primordials: false
270+
overrides:
271+
- files: [internal/per_context/primordials.js]
272+
rules:
273+
node-core/alphabetize-primordials: [error, {enforceTopPosition: false}]

lib/_http_common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
const {
2525
MathMin,
26-
Symbol,
2726
RegExpPrototypeExec,
27+
Symbol,
2828
} = primordials;
2929
const { setImmediate } = require('timers');
3030

lib/_http_outgoing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ const {
2929
NumberPrototypeToString,
3030
ObjectDefineProperty,
3131
ObjectKeys,
32-
ObjectValues,
3332
ObjectPrototypeHasOwnProperty,
3433
ObjectSetPrototypeOf,
34+
ObjectValues,
3535
RegExpPrototypeExec,
3636
SafeSet,
3737
StringPrototypeToLowerCase,

lib/_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const {
2828
MathMin,
2929
ObjectKeys,
3030
ObjectSetPrototypeOf,
31-
RegExpPrototypeExec,
3231
ReflectApply,
32+
RegExpPrototypeExec,
3333
Symbol,
3434
SymbolAsyncDispose,
3535
SymbolFor,

lib/_tls_common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121

2222
'use strict';
2323

24-
const tls = require('tls');
25-
2624
const {
2725
ArrayPrototypePush,
2826
JSONParse,
2927
RegExpPrototypeSymbolReplace,
3028
} = primordials;
3129

30+
const tls = require('tls');
31+
3232
const {
3333
codes: {
3434
ERR_TLS_INVALID_PROTOCOL_VERSION,

lib/async_hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const {
99
FunctionPrototypeBind,
1010
NumberIsSafeInteger,
1111
ObjectDefineProperties,
12+
ObjectFreeze,
1213
ObjectIs,
1314
ReflectApply,
1415
Symbol,
15-
ObjectFreeze,
1616
} = primordials;
1717

1818
const {

lib/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ const {
4141
StringPrototypeTrim,
4242
SymbolSpecies,
4343
SymbolToPrimitive,
44+
TypedArrayPrototypeFill,
4445
TypedArrayPrototypeGetBuffer,
4546
TypedArrayPrototypeGetByteLength,
4647
TypedArrayPrototypeGetByteOffset,
47-
TypedArrayPrototypeFill,
4848
TypedArrayPrototypeGetLength,
4949
TypedArrayPrototypeSet,
5050
TypedArrayPrototypeSlice,

lib/child_process.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const {
2828
ArrayPrototypeJoin,
2929
ArrayPrototypeLastIndexOf,
3030
ArrayPrototypePush,
31+
ArrayPrototypePushApply,
3132
ArrayPrototypeSlice,
3233
ArrayPrototypeSort,
3334
ArrayPrototypeSplice,
3435
ArrayPrototypeUnshift,
35-
ArrayPrototypePushApply,
3636
NumberIsInteger,
3737
ObjectAssign,
3838
ObjectDefineProperty,

lib/crypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
'use strict';
2626

2727
const {
28-
ObjectDefineProperty,
2928
ObjectDefineProperties,
29+
ObjectDefineProperty,
3030
} = primordials;
3131

3232
const {

lib/diagnostics_channel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const {
55
ArrayPrototypeIndexOf,
66
ArrayPrototypePush,
77
ArrayPrototypeSplice,
8-
SafeFinalizationRegistry,
98
ObjectDefineProperty,
109
ObjectGetPrototypeOf,
1110
ObjectSetPrototypeOf,
1211
Promise,
1312
PromisePrototypeThen,
14-
PromiseResolve,
1513
PromiseReject,
14+
PromiseResolve,
1615
ReflectApply,
16+
SafeFinalizationRegistry,
1717
SafeMap,
1818
SymbolHasInstance,
1919
} = primordials;

lib/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const {
3434
FunctionPrototypeBind,
3535
FunctionPrototypeCall,
3636
NumberMAX_SAFE_INTEGER,
37-
ObjectDefineProperty,
3837
ObjectDefineProperties,
38+
ObjectDefineProperty,
3939
ObjectGetPrototypeOf,
4040
ObjectSetPrototypeOf,
4141
Promise,
@@ -46,9 +46,9 @@ const {
4646
String,
4747
StringPrototypeSplit,
4848
Symbol,
49-
SymbolFor,
5049
SymbolAsyncIterator,
5150
SymbolDispose,
51+
SymbolFor,
5252
} = primordials;
5353
const kRejection = SymbolFor('nodejs.rejection');
5454

lib/internal/async_hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const {
44
ArrayPrototypeSlice,
55
ErrorCaptureStackTrace,
6-
ObjectPrototypeHasOwnProperty,
76
ObjectDefineProperty,
7+
ObjectPrototypeHasOwnProperty,
88
Symbol,
99
} = primordials;
1010

lib/internal/blob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const {
1010
PromiseReject,
1111
RegExpPrototypeExec,
1212
RegExpPrototypeSymbolReplace,
13-
StringPrototypeToLowerCase,
1413
StringPrototypeSplit,
14+
StringPrototypeToLowerCase,
1515
Symbol,
1616
SymbolIterator,
1717
SymbolToStringTag,

lib/internal/bootstrap/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ const {
5959
Number,
6060
NumberIsNaN,
6161
ObjectDefineProperty,
62+
ObjectFreeze,
6263
ObjectGetPrototypeOf,
6364
ObjectSetPrototypeOf,
64-
ObjectFreeze,
6565
SymbolToStringTag,
6666
globalThis,
6767
} = primordials;

lib/internal/bootstrap/realm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ const {
6464
SafeMap,
6565
SafeSet,
6666
String,
67-
StringPrototypeStartsWith,
6867
StringPrototypeSlice,
68+
StringPrototypeStartsWith,
6969
TypeError,
7070
} = primordials;
7171

lib/internal/bootstrap/switches/is_main_thread.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
'use strict';
22

3-
const { ObjectDefineProperty } = primordials;
3+
const {
4+
ObjectDefineProperty,
5+
} = primordials;
6+
47
const rawMethods = internalBinding('process_methods');
58
const {
69
namespace: {

lib/internal/bootstrap/switches/is_not_main_thread.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

3-
const { ObjectDefineProperty } = primordials;
3+
const {
4+
ObjectDefineProperty,
5+
} = primordials;
46

57
delete process._debugProcess;
68
delete process._debugEnd;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*/
1010

1111
const {
12-
globalThis,
1312
ObjectDefineProperty,
13+
globalThis,
1414
} = primordials;
1515

1616
const {

lib/internal/child_process/serialization.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

33
const {
4+
ArrayPrototypePush,
45
JSONParse,
56
JSONStringify,
67
StringPrototypeSplit,
7-
ArrayPrototypePush,
88
Symbol,
99
TypedArrayPrototypeSubarray,
1010
} = primordials;

lib/internal/cluster/shared_handle.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
2-
const { SafeMap } = primordials;
2+
3+
const {
4+
SafeMap,
5+
} = primordials;
6+
37
const assert = require('internal/assert');
48
const dgram = require('internal/dgram');
59
const net = require('net');

lib/internal/console/constructor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const {
2626
RegExpPrototypeSymbolReplace,
2727
SafeArrayIterator,
2828
SafeMap,
29-
SafeWeakMap,
3029
SafeSet,
30+
SafeWeakMap,
3131
StringPrototypeIncludes,
3232
StringPrototypePadStart,
3333
StringPrototypeRepeat,

lib/internal/crypto/aes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
ArrayPrototypeIncludes,
88
ArrayPrototypePush,
99
MathFloor,
10+
PromiseReject,
1011
SafeSet,
1112
TypedArrayPrototypeSlice,
1213
} = primordials;
@@ -47,8 +48,6 @@ const {
4748
promisify,
4849
} = require('internal/util');
4950

50-
const { PromiseReject } = primordials;
51-
5251
const {
5352
InternalCryptoKey,
5453
SecretKeyObject,

lib/internal/crypto/keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const {
44
ArrayFrom,
55
ArrayPrototypeSlice,
6-
ObjectDefineProperty,
76
ObjectDefineProperties,
7+
ObjectDefineProperty,
88
ObjectSetPrototypeOf,
99
Symbol,
1010
SymbolToStringTag,

lib/internal/dns/callback_resolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
const {
4+
ArrayPrototypeMap,
45
ObjectDefineProperty,
56
ReflectApply,
6-
ArrayPrototypeMap,
77
Symbol,
88
} = primordials;
99

lib/internal/error_serdes.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const Buffer = require('buffer').Buffer;
43
const {
54
ArrayPrototypeForEach,
65
Error,
@@ -19,15 +18,17 @@ const {
1918
SafeSet,
2019
StringFromCharCode,
2120
StringPrototypeSubstring,
21+
SymbolFor,
2222
SymbolToStringTag,
2323
SyntaxError,
24-
SymbolFor,
2524
TypeError,
2625
TypedArrayPrototypeGetBuffer,
27-
TypedArrayPrototypeGetByteOffset,
2826
TypedArrayPrototypeGetByteLength,
27+
TypedArrayPrototypeGetByteOffset,
2928
URIError,
3029
} = primordials;
30+
31+
const { Buffer } = require('buffer');
3132
const { inspect: { custom: customInspectSymbol } } = require('util');
3233

3334
const kSerializedError = 0;

lib/internal/errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ const {
3333
Number,
3434
NumberIsInteger,
3535
ObjectAssign,
36-
ObjectDefineProperty,
3736
ObjectDefineProperties,
38-
ObjectIsExtensible,
37+
ObjectDefineProperty,
3938
ObjectGetOwnPropertyDescriptor,
39+
ObjectIsExtensible,
4040
ObjectKeys,
4141
ObjectPrototypeHasOwnProperty,
4242
RangeError,

lib/internal/freeze_intrinsics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ const {
103103
TypeErrorPrototype,
104104
TypedArray,
105105
TypedArrayPrototype,
106+
URIError,
107+
URIErrorPrototype,
106108
Uint16Array,
107109
Uint16ArrayPrototype,
108110
Uint32Array,
@@ -111,8 +113,6 @@ const {
111113
Uint8ArrayPrototype,
112114
Uint8ClampedArray,
113115
Uint8ClampedArrayPrototype,
114-
URIError,
115-
URIErrorPrototype,
116116
WeakMap,
117117
WeakMapPrototype,
118118
WeakRef,

lib/internal/fs/glob.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
'use strict';
2-
const { lstatSync, readdirSync } = require('fs');
3-
const { lstat, readdir } = require('fs/promises');
4-
const { join, resolve } = require('path');
5-
6-
const {
7-
kEmptyObject,
8-
} = require('internal/util');
9-
const {
10-
validateFunction,
11-
validateObject,
12-
validateString,
13-
validateStringArray,
14-
} = require('internal/validators');
152

163
const {
174
ArrayFrom,
185
ArrayPrototypeAt,
19-
ArrayPrototypeMap,
206
ArrayPrototypeFlatMap,
7+
ArrayPrototypeMap,
218
ArrayPrototypePop,
229
ArrayPrototypePush,
2310
ArrayPrototypeSome,
@@ -27,6 +14,20 @@ const {
2714
StringPrototypeEndsWith,
2815
} = primordials;
2916

17+
const { lstatSync, readdirSync } = require('fs');
18+
const { lstat, readdir } = require('fs/promises');
19+
const { join, resolve } = require('path');
20+
21+
const {
22+
kEmptyObject,
23+
} = require('internal/util');
24+
const {
25+
validateFunction,
26+
validateObject,
27+
validateString,
28+
validateStringArray,
29+
} = require('internal/validators');
30+
3031
let minimatch;
3132
function lazyMinimatch() {
3233
minimatch ??= require('internal/deps/minimatch/index');

0 commit comments

Comments
 (0)