Skip to content

Commit

Permalink
tools: add lint rule to keep primordials in ASCII order
Browse files Browse the repository at this point in the history
PR-URL: #52592
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
  • Loading branch information
aduh95 committed Apr 29, 2024
1 parent eeb80ad commit f9ddd77
Show file tree
Hide file tree
Showing 96 changed files with 336 additions and 189 deletions.
5 changes: 5 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ rules:
- groups: [['&&', '||']]

# Custom rules in tools/eslint-rules
node-core/alphabetize-primordials: error
node-core/avoid-prototype-pollution: error
node-core/lowercase-name-for-primitive: error
node-core/non-ascii-character: error
Expand Down Expand Up @@ -266,3 +267,7 @@ globals:
module: false
internalBinding: false
primordials: false
overrides:
- files: [internal/per_context/primordials.js]
rules:
node-core/alphabetize-primordials: [error, {enforceTopPosition: false}]
2 changes: 1 addition & 1 deletion lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

const {
MathMin,
Symbol,
RegExpPrototypeExec,
Symbol,
} = primordials;
const { setImmediate } = require('timers');

Expand Down
2 changes: 1 addition & 1 deletion lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const {
NumberPrototypeToString,
ObjectDefineProperty,
ObjectKeys,
ObjectValues,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
ObjectValues,
RegExpPrototypeExec,
SafeSet,
StringPrototypeToLowerCase,
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const {
MathMin,
ObjectKeys,
ObjectSetPrototypeOf,
RegExpPrototypeExec,
ReflectApply,
RegExpPrototypeExec,
Symbol,
SymbolAsyncDispose,
SymbolFor,
Expand Down
4 changes: 2 additions & 2 deletions lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

'use strict';

const tls = require('tls');

const {
ArrayPrototypePush,
JSONParse,
RegExpPrototypeSymbolReplace,
} = primordials;

const tls = require('tls');

const {
codes: {
ERR_TLS_INVALID_PROTOCOL_VERSION,
Expand Down
2 changes: 1 addition & 1 deletion lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const {
FunctionPrototypeBind,
NumberIsSafeInteger,
ObjectDefineProperties,
ObjectFreeze,
ObjectIs,
ReflectApply,
Symbol,
ObjectFreeze,
} = primordials;

const {
Expand Down
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ const {
StringPrototypeTrim,
SymbolSpecies,
SymbolToPrimitive,
TypedArrayPrototypeFill,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeGetByteOffset,
TypedArrayPrototypeFill,
TypedArrayPrototypeGetLength,
TypedArrayPrototypeSet,
TypedArrayPrototypeSlice,
Expand Down
2 changes: 1 addition & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const {
ArrayPrototypeJoin,
ArrayPrototypeLastIndexOf,
ArrayPrototypePush,
ArrayPrototypePushApply,
ArrayPrototypeSlice,
ArrayPrototypeSort,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
ArrayPrototypePushApply,
NumberIsInteger,
ObjectAssign,
ObjectDefineProperty,
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
'use strict';

const {
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
} = primordials;

const {
Expand Down
4 changes: 2 additions & 2 deletions lib/diagnostics_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
ArrayPrototypeSplice,
SafeFinalizationRegistry,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Promise,
PromisePrototypeThen,
PromiseResolve,
PromiseReject,
PromiseResolve,
ReflectApply,
SafeFinalizationRegistry,
SafeMap,
SymbolHasInstance,
} = primordials;
Expand Down
4 changes: 2 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const {
FunctionPrototypeBind,
FunctionPrototypeCall,
NumberMAX_SAFE_INTEGER,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Promise,
Expand All @@ -46,9 +46,9 @@ const {
String,
StringPrototypeSplit,
Symbol,
SymbolFor,
SymbolAsyncIterator,
SymbolDispose,
SymbolFor,
} = primordials;
const kRejection = SymbolFor('nodejs.rejection');

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const {
ArrayPrototypeSlice,
ErrorCaptureStackTrace,
ObjectPrototypeHasOwnProperty,
ObjectDefineProperty,
ObjectPrototypeHasOwnProperty,
Symbol,
} = primordials;

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const {
PromiseReject,
RegExpPrototypeExec,
RegExpPrototypeSymbolReplace,
StringPrototypeToLowerCase,
StringPrototypeSplit,
StringPrototypeToLowerCase,
Symbol,
SymbolIterator,
SymbolToStringTag,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const {
Number,
NumberIsNaN,
ObjectDefineProperty,
ObjectFreeze,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
ObjectFreeze,
SymbolToStringTag,
globalThis,
} = primordials;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const {
SafeMap,
SafeSet,
String,
StringPrototypeStartsWith,
StringPrototypeSlice,
StringPrototypeStartsWith,
TypeError,
} = primordials;

Expand Down
5 changes: 4 additions & 1 deletion lib/internal/bootstrap/switches/is_main_thread.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const { ObjectDefineProperty } = primordials;
const {
ObjectDefineProperty,
} = primordials;

const rawMethods = internalBinding('process_methods');
const {
namespace: {
Expand Down
4 changes: 3 additions & 1 deletion lib/internal/bootstrap/switches/is_not_main_thread.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const { ObjectDefineProperty } = primordials;
const {
ObjectDefineProperty,
} = primordials;

delete process._debugProcess;
delete process._debugEnd;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/web/exposed-window-or-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

const {
globalThis,
ObjectDefineProperty,
globalThis,
} = primordials;

const {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process/serialization.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

const {
ArrayPrototypePush,
JSONParse,
JSONStringify,
StringPrototypeSplit,
ArrayPrototypePush,
Symbol,
TypedArrayPrototypeSubarray,
} = primordials;
Expand Down
6 changes: 5 additions & 1 deletion lib/internal/cluster/shared_handle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';
const { SafeMap } = primordials;

const {
SafeMap,
} = primordials;

const assert = require('internal/assert');
const dgram = require('internal/dgram');
const net = require('net');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const {
RegExpPrototypeSymbolReplace,
SafeArrayIterator,
SafeMap,
SafeWeakMap,
SafeSet,
SafeWeakMap,
StringPrototypeIncludes,
StringPrototypePadStart,
StringPrototypeRepeat,
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/crypto/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
ArrayPrototypeIncludes,
ArrayPrototypePush,
MathFloor,
PromiseReject,
SafeSet,
TypedArrayPrototypeSlice,
} = primordials;
Expand Down Expand Up @@ -47,8 +48,6 @@ const {
promisify,
} = require('internal/util');

const { PromiseReject } = primordials;

const {
InternalCryptoKey,
SecretKeyObject,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const {
ArrayFrom,
ArrayPrototypeSlice,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
SymbolToStringTag,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/dns/callback_resolver.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const {
ArrayPrototypeMap,
ObjectDefineProperty,
ReflectApply,
ArrayPrototypeMap,
Symbol,
} = primordials;

Expand Down
7 changes: 4 additions & 3 deletions lib/internal/error_serdes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const Buffer = require('buffer').Buffer;
const {
ArrayPrototypeForEach,
Error,
Expand All @@ -19,15 +18,17 @@ const {
SafeSet,
StringFromCharCode,
StringPrototypeSubstring,
SymbolFor,
SymbolToStringTag,
SyntaxError,
SymbolFor,
TypeError,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteOffset,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeGetByteOffset,
URIError,
} = primordials;

const { Buffer } = require('buffer');
const { inspect: { custom: customInspectSymbol } } = require('util');

const kSerializedError = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const {
Number,
NumberIsInteger,
ObjectAssign,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectIsExtensible,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
ObjectIsExtensible,
ObjectKeys,
ObjectPrototypeHasOwnProperty,
RangeError,
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/freeze_intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ const {
TypeErrorPrototype,
TypedArray,
TypedArrayPrototype,
URIError,
URIErrorPrototype,
Uint16Array,
Uint16ArrayPrototype,
Uint32Array,
Expand All @@ -111,8 +113,6 @@ const {
Uint8ArrayPrototype,
Uint8ClampedArray,
Uint8ClampedArrayPrototype,
URIError,
URIErrorPrototype,
WeakMap,
WeakMapPrototype,
WeakRef,
Expand Down
29 changes: 15 additions & 14 deletions lib/internal/fs/glob.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
'use strict';
const { lstatSync, readdirSync } = require('fs');
const { lstat, readdir } = require('fs/promises');
const { join, resolve } = require('path');

const {
kEmptyObject,
} = require('internal/util');
const {
validateFunction,
validateObject,
validateString,
validateStringArray,
} = require('internal/validators');

const {
ArrayFrom,
ArrayPrototypeAt,
ArrayPrototypeMap,
ArrayPrototypeFlatMap,
ArrayPrototypeMap,
ArrayPrototypePop,
ArrayPrototypePush,
ArrayPrototypeSome,
Expand All @@ -27,6 +14,20 @@ const {
StringPrototypeEndsWith,
} = primordials;

const { lstatSync, readdirSync } = require('fs');
const { lstat, readdir } = require('fs/promises');
const { join, resolve } = require('path');

const {
kEmptyObject,
} = require('internal/util');
const {
validateFunction,
validateObject,
validateString,
validateStringArray,
} = require('internal/validators');

let minimatch;
function lazyMinimatch() {
minimatch ??= require('internal/deps/minimatch/index');
Expand Down
Loading

0 comments on commit f9ddd77

Please sign in to comment.