tools: add lint rule to keep primordials in ASCII order

PR-URL: https://github.com/nodejs/node/pull/52592
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
Antoine du Hamel 2024-04-21 18:53:08 +02:00 committed by GitHub
parent 461722d64c
commit a596af0819
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
96 changed files with 337 additions and 190 deletions

View File

@ -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
@ -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}]

View File

@ -23,8 +23,8 @@
const {
MathMin,
Symbol,
RegExpPrototypeExec,
Symbol,
} = primordials;
const { setImmediate } = require('timers');

View File

@ -29,9 +29,9 @@ const {
NumberPrototypeToString,
ObjectDefineProperty,
ObjectKeys,
ObjectValues,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
ObjectValues,
RegExpPrototypeExec,
SafeSet,
StringPrototypeToLowerCase,

View File

@ -28,8 +28,8 @@ const {
MathMin,
ObjectKeys,
ObjectSetPrototypeOf,
RegExpPrototypeExec,
ReflectApply,
RegExpPrototypeExec,
Symbol,
SymbolAsyncDispose,
SymbolFor,

View File

@ -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,

View File

@ -9,10 +9,10 @@ const {
FunctionPrototypeBind,
NumberIsSafeInteger,
ObjectDefineProperties,
ObjectFreeze,
ObjectIs,
ReflectApply,
Symbol,
ObjectFreeze,
} = primordials;
const {

View File

@ -41,10 +41,10 @@ const {
StringPrototypeTrim,
SymbolSpecies,
SymbolToPrimitive,
TypedArrayPrototypeFill,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeGetByteOffset,
TypedArrayPrototypeFill,
TypedArrayPrototypeGetLength,
TypedArrayPrototypeSet,
TypedArrayPrototypeSlice,

View File

@ -28,11 +28,11 @@ const {
ArrayPrototypeJoin,
ArrayPrototypeLastIndexOf,
ArrayPrototypePush,
ArrayPrototypePushApply,
ArrayPrototypeSlice,
ArrayPrototypeSort,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
ArrayPrototypePushApply,
NumberIsInteger,
ObjectAssign,
ObjectDefineProperty,

View File

@ -25,8 +25,8 @@
'use strict';
const {
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
} = primordials;
const {

View File

@ -5,15 +5,15 @@ const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
ArrayPrototypeSplice,
SafeFinalizationRegistry,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Promise,
PromisePrototypeThen,
PromiseResolve,
PromiseReject,
PromiseResolve,
ReflectApply,
SafeFinalizationRegistry,
SafeMap,
SymbolHasInstance,
} = primordials;

View File

@ -34,8 +34,8 @@ const {
FunctionPrototypeBind,
FunctionPrototypeCall,
NumberMAX_SAFE_INTEGER,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Promise,
@ -46,9 +46,9 @@ const {
String,
StringPrototypeSplit,
Symbol,
SymbolFor,
SymbolAsyncIterator,
SymbolDispose,
SymbolFor,
} = primordials;
const kRejection = SymbolFor('nodejs.rejection');

View File

@ -3,8 +3,8 @@
const {
ArrayPrototypeSlice,
ErrorCaptureStackTrace,
ObjectPrototypeHasOwnProperty,
ObjectDefineProperty,
ObjectPrototypeHasOwnProperty,
Symbol,
} = primordials;

View File

@ -10,8 +10,8 @@ const {
PromiseReject,
RegExpPrototypeExec,
RegExpPrototypeSymbolReplace,
StringPrototypeToLowerCase,
StringPrototypeSplit,
StringPrototypeToLowerCase,
Symbol,
SymbolIterator,
SymbolToStringTag,

View File

@ -59,9 +59,9 @@ const {
Number,
NumberIsNaN,
ObjectDefineProperty,
ObjectFreeze,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
ObjectFreeze,
SymbolToStringTag,
globalThis,
} = primordials;

View File

@ -64,8 +64,8 @@ const {
SafeMap,
SafeSet,
String,
StringPrototypeStartsWith,
StringPrototypeSlice,
StringPrototypeStartsWith,
TypeError,
} = primordials;

View File

@ -1,6 +1,9 @@
'use strict';
const { ObjectDefineProperty } = primordials;
const {
ObjectDefineProperty,
} = primordials;
const rawMethods = internalBinding('process_methods');
const {
namespace: {

View File

@ -1,6 +1,8 @@
'use strict';
const { ObjectDefineProperty } = primordials;
const {
ObjectDefineProperty,
} = primordials;
delete process._debugProcess;
delete process._debugEnd;

View File

@ -9,9 +9,9 @@
*/
const {
globalThis,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
globalThis,
} = primordials;
const {

View File

@ -1,10 +1,10 @@
'use strict';
const {
ArrayPrototypePush,
JSONParse,
JSONStringify,
StringPrototypeSplit,
ArrayPrototypePush,
Symbol,
TypedArrayPrototypeSubarray,
} = primordials;

View File

@ -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');

View File

@ -26,8 +26,8 @@ const {
RegExpPrototypeSymbolReplace,
SafeArrayIterator,
SafeMap,
SafeWeakMap,
SafeSet,
SafeWeakMap,
StringPrototypeIncludes,
StringPrototypePadStart,
StringPrototypeRepeat,

View File

@ -7,6 +7,7 @@ const {
ArrayPrototypeIncludes,
ArrayPrototypePush,
MathFloor,
PromiseReject,
SafeSet,
TypedArrayPrototypeSlice,
} = primordials;
@ -47,8 +48,6 @@ const {
promisify,
} = require('internal/util');
const { PromiseReject } = primordials;
const {
InternalCryptoKey,
SecretKeyObject,

View File

@ -3,8 +3,8 @@
const {
ArrayFrom,
ArrayPrototypeSlice,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
SymbolToStringTag,

View File

@ -1,9 +1,9 @@
'use strict';
const {
ArrayPrototypeMap,
ObjectDefineProperty,
ReflectApply,
ArrayPrototypeMap,
Symbol,
} = primordials;

View File

@ -1,6 +1,5 @@
'use strict';
const Buffer = require('buffer').Buffer;
const {
ArrayPrototypeForEach,
Error,
@ -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;

View File

@ -33,10 +33,10 @@ const {
Number,
NumberIsInteger,
ObjectAssign,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectIsExtensible,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
ObjectIsExtensible,
ObjectKeys,
ObjectPrototypeHasOwnProperty,
RangeError,

View File

@ -103,6 +103,8 @@ const {
TypeErrorPrototype,
TypedArray,
TypedArrayPrototype,
URIError,
URIErrorPrototype,
Uint16Array,
Uint16ArrayPrototype,
Uint32Array,
@ -111,8 +113,6 @@ const {
Uint8ArrayPrototype,
Uint8ClampedArray,
Uint8ClampedArrayPrototype,
URIError,
URIErrorPrototype,
WeakMap,
WeakMapPrototype,
WeakRef,

View File

@ -1,4 +1,19 @@
'use strict';
const {
ArrayFrom,
ArrayPrototypeAt,
ArrayPrototypeFlatMap,
ArrayPrototypeMap,
ArrayPrototypePop,
ArrayPrototypePush,
ArrayPrototypeSome,
PromisePrototypeThen,
SafeMap,
SafeSet,
StringPrototypeEndsWith,
} = primordials;
const { lstatSync, readdirSync } = require('fs');
const { lstat, readdir } = require('fs/promises');
const { join, resolve } = require('path');
@ -13,20 +28,6 @@ const {
validateStringArray,
} = require('internal/validators');
const {
ArrayFrom,
ArrayPrototypeAt,
ArrayPrototypeMap,
ArrayPrototypeFlatMap,
ArrayPrototypePop,
ArrayPrototypePush,
ArrayPrototypeSome,
PromisePrototypeThen,
SafeMap,
SafeSet,
StringPrototypeEndsWith,
} = primordials;
let minimatch;
function lazyMinimatch() {
minimatch ??= require('internal/deps/minimatch/index');

View File

@ -1,22 +1,22 @@
'use strict';
const {
ArrayPrototypePush,
ArrayPrototypePop,
ArrayPrototypePush,
Error,
ErrorCaptureStackTrace,
FunctionPrototypeBind,
MathMax,
MathMin,
Promise,
PromisePrototypeThen,
PromiseResolve,
PromiseReject,
PromiseResolve,
SafeArrayIterator,
SafePromisePrototypeFinally,
Symbol,
SymbolAsyncDispose,
Uint8Array,
FunctionPrototypeBind,
uncurryThis,
} = primordials;

View File

@ -8,10 +8,10 @@ const {
DatePrototypeGetTime,
ErrorCaptureStackTrace,
FunctionPrototypeCall,
Number,
NumberIsFinite,
MathMin,
MathRound,
Number,
NumberIsFinite,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectIs,

View File

@ -1,8 +1,8 @@
'use strict';
const {
ArrayPrototypeMap,
Symbol,
Uint8Array,
ArrayPrototypeMap,
} = primordials;
const {
kUpdateTimer,

View File

@ -1,10 +1,10 @@
'use strict';
const {
Symbol,
Date,
DatePrototypeGetMilliseconds,
DatePrototypeToUTCString,
Symbol,
} = primordials;
const { setUnrefTimeout } = require('internal/timers');

View File

@ -11,8 +11,8 @@ const {
Proxy,
ReflectApply,
ReflectGetPrototypeOf,
StringPrototypeIncludes,
SafeArrayIterator,
StringPrototypeIncludes,
StringPrototypeToLowerCase,
StringPrototypeTrim,
Symbol,

View File

@ -11,9 +11,9 @@ const {
MathMin,
Number,
ObjectAssign,
ObjectKeys,
ObjectDefineProperty,
ObjectEntries,
ObjectKeys,
ObjectPrototypeHasOwnProperty,
Promise,
PromisePrototypeThen,

View File

@ -1,12 +1,12 @@
'use strict';
let hook;
let config;
const {
SafeSet,
} = primordials;
let hook;
let config;
function lazyHookCreation() {
const inspector = internalBinding('inspector');
const { createHook } = require('async_hooks');

View File

@ -2,8 +2,8 @@
const {
ArrayPrototypeFilter,
ArrayPrototypeIncludes,
ObjectFromEntries,
ObjectEntries,
ObjectFromEntries,
SafeArrayIterator,
} = primordials;
const { types } = require('util');

View File

@ -9,11 +9,11 @@ const {
ObjectKeys,
RegExp,
RegExpPrototypeSymbolReplace,
SafeMap,
StringPrototypeLocaleCompare,
StringPrototypeRepeat,
StringPrototypeSlice,
StringPrototypeTrimStart,
StringPrototypeRepeat,
SafeMap,
} = primordials;
const { types } = internalBinding('options');

View File

@ -1,6 +1,8 @@
'use strict';
const { RegExpPrototypeExec } = primordials;
const {
RegExpPrototypeExec,
} = primordials;
const {
prepareMainThreadExecution,

View File

@ -1,4 +1,11 @@
'use strict';
const {
NumberParseInt,
RegExpPrototypeExec,
StringPrototypeSplit,
} = primordials;
const {
prepareMainThreadExecution,
markBootstrapComplete,
@ -13,11 +20,7 @@ const {
ERR_INVALID_ARG_VALUE,
},
} = require('internal/errors');
const {
NumberParseInt,
RegExpPrototypeExec,
StringPrototypeSplit,
} = primordials;
let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
debug = fn;
});

View File

@ -4,8 +4,8 @@ const {
ArrayPrototypeFilter,
ArrayPrototypeIncludes,
ObjectKeys,
ObjectValues,
ObjectPrototypeHasOwnProperty,
ObjectValues,
} = primordials;
const { validateString } = require('internal/validators');

View File

@ -1,6 +1,9 @@
'use strict';
const { RegExpPrototypeExec } = primordials;
const {
RegExpPrototypeExec,
} = primordials;
const { getOptionValue } = require('internal/options');
const { getValidatedPath } = require('internal/fs/utils');
const pathModule = require('path');

View File

@ -1,13 +1,13 @@
'use strict';
const {
RegExpPrototypeExec,
ObjectPrototypeHasOwnProperty,
PromisePrototypeThen,
PromiseResolve,
RegExpPrototypeExec,
SafeSet,
StringPrototypeIncludes,
StringPrototypeCharCodeAt,
StringPrototypeIncludes,
StringPrototypeSlice,
} = primordials;
const { getOptionValue } = require('internal/options');

View File

@ -1,6 +1,9 @@
'use strict';
const { StringPrototypeStartsWith } = primordials;
const {
StringPrototypeStartsWith,
} = primordials;
const { getOptionValue } = require('internal/options');
const { fileURLToPath } = require('internal/url');
const { dirname } = require('path');

View File

@ -1,11 +1,5 @@
'use strict';
// This is needed to avoid cycles in esm/resolve <-> cjs/loader
const {
kIsExecuting,
kRequiredModuleSymbol,
} = require('internal/modules/cjs/loader');
const {
ArrayPrototypeJoin,
ArrayPrototypeMap,
@ -18,6 +12,13 @@ const {
hardenRegExp,
} = primordials;
// This is needed to avoid cycles in esm/resolve <-> cjs/loader
const {
kIsExecuting,
kRequiredModuleSymbol,
} = require('internal/modules/cjs/loader');
const { imported_cjs_symbol } = internalBinding('symbols');
const assert = require('internal/assert');

View File

@ -6,11 +6,11 @@ const {
ArrayPrototypeSome,
FunctionPrototype,
ObjectSetPrototypeOf,
PromiseResolve,
PromisePrototypeThen,
PromiseResolve,
ReflectApply,
RegExpPrototypeExec,
RegExpPrototypeSymbolReplace,
ReflectApply,
SafePromiseAllReturnArrayLike,
SafePromiseAllReturnVoid,
SafeSet,

View File

@ -5,8 +5,8 @@ const {
Boolean,
JSONParse,
ObjectGetPrototypeOf,
ObjectPrototypeHasOwnProperty,
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ReflectApply,
SafeArrayIterator,
SafeMap,

View File

@ -2,9 +2,9 @@
const {
ArrayIsArray,
ObjectFreeze,
SafeSet,
SafeWeakMap,
ObjectFreeze,
} = primordials;
const {

View File

@ -3,9 +3,9 @@
const {
ArrayIsArray,
JSONParse,
StringPrototypeSlice,
StringPrototypeLastIndexOf,
ObjectDefineProperty,
StringPrototypeLastIndexOf,
StringPrototypeSlice,
} = primordials;
const modulesBinding = internalBinding('modules');
const { resolve, sep } = require('path');

View File

@ -2,12 +2,12 @@
const {
ObjectDefineProperties,
ObjectFreeze,
StringPrototypeIndexOf,
StringPrototypeSlice,
StringPrototypeToUpperCase,
ObjectFreeze,
globalThis,
Symbol,
globalThis,
} = primordials;
const {

View File

@ -1,14 +1,14 @@
'use strict';
const {
StringPrototypeSlice,
} = primordials;
const {
getCLIOptions,
getEmbedderOptions: getEmbedderOptionsFromBinding,
} = internalBinding('options');
const {
StringPrototypeSlice,
} = primordials;
let warnOnAllowUnauthorized = true;
let optionsMap;

View File

@ -6,9 +6,9 @@ const {
ObjectDefineProperties,
ObjectDefineProperty,
ObjectSetPrototypeOf,
SafeWeakMap,
SafeMap,
SafeSet,
SafeWeakMap,
SymbolToStringTag,
TypeError,
} = primordials;

View File

@ -287,8 +287,8 @@ const {
PromiseResolve,
ReflectApply,
ReflectConstruct,
ReflectSet,
ReflectGet,
ReflectSet,
RegExp,
RegExpPrototype,
RegExpPrototypeExec,

View File

@ -2,8 +2,8 @@
const {
FunctionPrototypeBind,
ObjectDefineProperties,
MathCeil,
ObjectDefineProperties,
ReflectApply,
ReflectConstruct,
} = primordials;

View File

@ -2,9 +2,9 @@
const {
ObjectDefineProperties,
SafeArrayIterator,
SafeMap,
SafeSet,
SafeArrayIterator,
Symbol,
SymbolToStringTag,
} = primordials;

View File

@ -9,9 +9,9 @@ const {
ObjectKeys,
ObjectSetPrototypeOf,
RegExpPrototypeExec,
RegExpPrototypeSymbolReplace,
SafeMap,
SafeSet,
RegExpPrototypeSymbolReplace,
StringPrototypeEndsWith,
StringPrototypeStartsWith,
Symbol,

View File

@ -1,8 +1,8 @@
'use strict';
const {
Symbol,
RegExpPrototypeExec,
Symbol,
globalThis,
} = primordials;

View File

@ -14,8 +14,8 @@ const {
BigUint64Array,
Float64Array,
NumberMAX_SAFE_INTEGER,
ObjectFreeze,
ObjectDefineProperty,
ObjectFreeze,
ReflectApply,
RegExpPrototypeExec,
SafeArrayIterator,

View File

@ -1,4 +1,9 @@
'use strict';
const {
JSONParse,
} = primordials;
const {
ERR_SYNTHETIC,
} = require('internal/errors').codes;
@ -10,9 +15,7 @@ const {
validateString,
} = require('internal/validators');
const nr = internalBinding('report');
const {
JSONParse,
} = primordials;
const report = {
writeReport(file, err) {
if (typeof file === 'object' && file !== null) {

View File

@ -3,10 +3,10 @@
const {
ArrayIsArray,
Error,
ErrorPrototypeToString,
ErrorCaptureStackTrace,
String,
ErrorPrototypeToString,
SafeSet,
String,
} = primordials;
const {

View File

@ -2,9 +2,9 @@
const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
ArrayPrototypeSlice,
ArrayPrototypeSplice,
ArrayPrototypePush,
FunctionPrototypeBind,
} = primordials;

View File

@ -9,8 +9,8 @@ const {
ArrayPrototypePop,
ArrayPrototypePush,
ArrayPrototypeReverse,
ArrayPrototypeSplice,
ArrayPrototypeShift,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
DateNow,
FunctionPrototypeCall,
@ -21,6 +21,7 @@ const {
NumberIsFinite,
ObjectSetPrototypeOf,
RegExpPrototypeExec,
SafeStringIterator,
StringPrototypeCodePointAt,
StringPrototypeEndsWith,
StringPrototypeRepeat,
@ -28,9 +29,8 @@ const {
StringPrototypeStartsWith,
StringPrototypeTrim,
Symbol,
SymbolDispose,
SymbolAsyncIterator,
SafeStringIterator,
SymbolDispose,
} = primordials;
const { codes } = require('internal/errors');

View File

@ -6,10 +6,10 @@ const {
ArrayPrototypeMap,
ErrorPrototypeToString,
RegExpPrototypeSymbolSplit,
SafeStringIterator,
StringPrototypeRepeat,
StringPrototypeSlice,
StringPrototypeStartsWith,
SafeStringIterator,
} = primordials;
let debug = require('internal/util/debuglog').debuglog('source_map', (fn) => {

View File

@ -1,5 +1,8 @@
'use strict';
const {
Symbol,
} = primordials;
const {
aggregateTwoErrors,
codes: {
@ -7,9 +10,6 @@ const {
},
AbortError,
} = require('internal/errors');
const {
Symbol,
} = primordials;
const {
kIsDestroyed,
isDestroyed,

View File

@ -1,5 +1,9 @@
'use strict';
const {
FunctionPrototypeCall,
} = primordials;
const {
isReadable,
isWritable,
@ -31,10 +35,6 @@ const {
} = require('internal/blob');
const { AbortController } = require('internal/abort_controller');
const {
FunctionPrototypeCall,
} = primordials;
// This is needed for pre node 17.
class Duplexify extends Duplex {
constructor(options) {

View File

@ -3,6 +3,12 @@
'use strict';
const {
Promise,
PromisePrototypeThen,
SymbolDispose,
} = primordials;
const {
AbortError,
codes,
@ -22,12 +28,6 @@ const {
validateBoolean,
} = require('internal/validators');
const {
Promise,
PromisePrototypeThen,
SymbolDispose,
} = primordials;
const {
isClosed,
isReadable,

View File

@ -1,5 +1,18 @@
'use strict';
const {
ArrayPrototypePush,
Boolean,
MathFloor,
Number,
NumberIsNaN,
Promise,
PromisePrototypeThen,
PromiseReject,
PromiseResolve,
Symbol,
} = primordials;
const { AbortController, AbortSignal } = require('internal/abort_controller');
const {
@ -24,19 +37,6 @@ const {
} = require('internal/streams/add-abort-signal');
const { isWritable, isNodeStream } = require('internal/streams/utils');
const {
ArrayPrototypePush,
Boolean,
MathFloor,
Number,
NumberIsNaN,
Promise,
PromiseReject,
PromiseResolve,
PromisePrototypeThen,
Symbol,
} = primordials;
const kEmpty = Symbol('kEmpty');
const kEof = Symbol('kEof');

View File

@ -1,10 +1,10 @@
'use strict';
const {
SymbolAsyncIterator,
SymbolIterator,
SymbolFor,
Symbol,
SymbolAsyncIterator,
SymbolFor,
SymbolIterator,
} = primordials;
// We need to use SymbolFor to make these globally available

View File

@ -29,8 +29,8 @@ const {
ArrayPrototypeSlice,
Error,
FunctionPrototypeSymbolHasInstance,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectSetPrototypeOf,
StringPrototypeToLowerCase,
Symbol,

View File

@ -5,6 +5,8 @@ const {
ArrayPrototypePush,
JSONParse,
MathFloor,
MathMax,
MathMin,
NumberParseInt,
ObjectAssign,
RegExpPrototypeExec,
@ -14,8 +16,6 @@ const {
StringPrototypeIncludes,
StringPrototypeLocaleCompare,
StringPrototypeStartsWith,
MathMax,
MathMin,
} = primordials;
const {
copyFileSync,

View File

@ -1,9 +1,5 @@
'use strict';
const {
emitExperimentalWarning,
} = require('internal/util');
const {
ArrayPrototypeAt,
ArrayPrototypeForEach,
@ -13,23 +9,27 @@ const {
FunctionPrototypeApply,
FunctionPrototypeBind,
FunctionPrototypeToString,
globalThis,
NumberIsNaN,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptor,
ObjectGetOwnPropertyDescriptors,
Promise,
Symbol,
SymbolAsyncIterator,
SymbolDispose,
globalThis,
} = primordials;
const {
validateAbortSignal,
validateArray,
validateNumber,
} = require('internal/validators');
const {
emitExperimentalWarning,
} = require('internal/util');
const {
AbortError,
codes: { ERR_INVALID_STATE, ERR_INVALID_ARG_VALUE },

View File

@ -1,5 +1,8 @@
'use strict';
const { MathMax } = primordials;
const {
MathMax,
} = primordials;
module.exports = async function* dot(source) {
let count = 0;

View File

@ -1,8 +1,8 @@
'use strict';
const {
ArrayPrototypeFilter,
ArrayPrototypeMap,
ArrayPrototypeJoin,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeSome,
NumberPrototypeToFixed,

View File

@ -6,10 +6,10 @@ const {
ArrayPrototypePush,
ArrayPrototypeShift,
ArrayPrototypeUnshift,
hardenRegExp,
RegExpPrototypeSymbolSplit,
SafeMap,
StringPrototypeRepeat,
hardenRegExp,
} = primordials;
const assert = require('assert');
const Transform = require('internal/streams/transform');

View File

@ -9,8 +9,8 @@ const {
RegExpPrototypeSymbolSplit,
SafeMap,
SafeSet,
StringPrototypeReplaceAll,
StringPrototypeRepeat,
StringPrototypeReplaceAll,
} = primordials;
const { inspectWithNoCustomRetry } = require('internal/errors');
const { isError, kEmptyObject } = require('internal/util');

View File

@ -5,8 +5,8 @@ const {
ArrayPrototypeFilter,
ArrayPrototypeForEach,
ArrayPrototypeIncludes,
ArrayPrototypeMap,
ArrayPrototypeJoin,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeShift,
ArrayPrototypeSlice,
@ -14,11 +14,11 @@ const {
ArrayPrototypeSort,
ObjectAssign,
PromisePrototypeThen,
PromiseResolve,
SafeMap,
SafePromiseAll,
SafePromiseAllReturnVoid,
SafePromiseAllSettledReturnVoid,
PromiseResolve,
SafeMap,
SafeSet,
StringPrototypeIndexOf,
StringPrototypeSlice,

View File

@ -11,21 +11,21 @@ const {
FunctionPrototype,
MathMax,
Number,
ObjectDefineProperty,
ObjectSeal,
PromisePrototypeThen,
PromiseResolve,
SafePromisePrototypeFinally,
StringPrototypeStartsWith,
StringPrototypeTrim,
ReflectApply,
RegExpPrototypeExec,
SafeMap,
SafeSet,
SafePromiseAll,
SafePromisePrototypeFinally,
SafePromiseRace,
SymbolDispose,
ObjectDefineProperty,
SafeSet,
StringPrototypeStartsWith,
StringPrototypeTrim,
Symbol,
SymbolDispose,
} = primordials;
const { getCallerLocation } = internalBinding('util');
const { addAbortListener } = require('internal/events/abort_listener');

View File

@ -1,22 +1,22 @@
'use strict';
const {
ArrayPrototypeFlatMap,
ArrayPrototypeJoin,
ArrayPrototypeMap,
ArrayPrototypeFlatMap,
ArrayPrototypePush,
ArrayPrototypeReduce,
ArrayPrototypeSome,
ObjectGetOwnPropertyDescriptor,
MathFloor,
MathMax,
MathMin,
NumberPrototypeToFixed,
SafePromiseAllReturnArrayLike,
ObjectGetOwnPropertyDescriptor,
RegExp,
RegExpPrototypeExec,
SafeMap,
StringPrototypePadStart,
SafePromiseAllReturnArrayLike,
StringPrototypePadEnd,
StringPrototypePadStart,
StringPrototypeRepeat,
StringPrototypeSlice,
} = primordials;

View File

@ -1,16 +1,16 @@
'use strict';
const {
ReflectConstruct,
Symbol,
} = primordials;
const EventEmitter = require('events');
const { kEmptyObject } = require('internal/util');
const { Duplex } = require('stream');
const _tls_wrap = require('_tls_wrap');
const _tls_common = require('_tls_common');
const {
Symbol,
ReflectConstruct,
} = primordials;
const kCallback = Symbol('Callback');
const kOtherSide = Symbol('Other');

View File

@ -12,10 +12,10 @@ const {
FunctionPrototypeCall,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectFreeze,
ObjectGetOwnPropertyDescriptor,
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
ObjectFreeze,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
ObjectValues,
@ -28,9 +28,9 @@ const {
RegExpPrototypeGetHasIndices,
RegExpPrototypeGetIgnoreCase,
RegExpPrototypeGetMultiline,
RegExpPrototypeGetSource,
RegExpPrototypeGetSticky,
RegExpPrototypeGetUnicode,
RegExpPrototypeGetSource,
SafeMap,
SafeSet,
SafeWeakMap,

View File

@ -20,8 +20,8 @@ const {
SafeSet,
StringPrototypeValueOf,
SymbolPrototypeValueOf,
TypedArrayPrototypeGetSymbolToStringTag,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeGetSymbolToStringTag,
Uint8Array,
} = primordials;

View File

@ -13,8 +13,8 @@ const {
ArrayPrototypePush,
ArrayPrototypePushApply,
ArrayPrototypeSlice,
ArrayPrototypeSplice,
ArrayPrototypeSort,
ArrayPrototypeSplice,
ArrayPrototypeUnshift,
BigIntPrototypeValueOf,
BooleanPrototypeValueOf,
@ -26,8 +26,8 @@ const {
FunctionPrototypeCall,
FunctionPrototypeToString,
JSONStringify,
MapPrototypeGetSize,
MapPrototypeEntries,
MapPrototypeGetSize,
MathFloor,
MathMax,
MathMin,
@ -61,14 +61,15 @@ const {
RegExpPrototypeSymbolReplace,
RegExpPrototypeSymbolSplit,
RegExpPrototypeToString,
SafeStringIterator,
SafeMap,
SafeSet,
SafeStringIterator,
SetPrototypeGetSize,
SetPrototypeValues,
String,
StringPrototypeCharCodeAt,
StringPrototypeCodePointAt,
StringPrototypeEndsWith,
StringPrototypeIncludes,
StringPrototypeIndexOf,
StringPrototypeLastIndexOf,
@ -79,14 +80,13 @@ const {
StringPrototypeReplaceAll,
StringPrototypeSlice,
StringPrototypeSplit,
StringPrototypeEndsWith,
StringPrototypeStartsWith,
StringPrototypeToLowerCase,
StringPrototypeTrim,
StringPrototypeValueOf,
SymbolIterator,
SymbolPrototypeToString,
SymbolPrototypeValueOf,
SymbolIterator,
SymbolToStringTag,
TypedArrayPrototypeGetLength,
TypedArrayPrototypeGetSymbolToStringTag,

View File

@ -1,8 +1,8 @@
'use strict';
const {
ArrayPrototypeSome,
ArrayPrototypePushApply,
ArrayPrototypeSome,
FunctionPrototypeBind,
ObjectDefineProperty,
ObjectKeys,

View File

@ -1,6 +1,5 @@
'use strict';
const assert = require('internal/assert');
const {
ArrayIsArray,
ArrayPrototypeForEach,
@ -18,6 +17,7 @@ const {
TypeError,
} = primordials;
const assert = require('internal/assert');
const {
isModuleNamespaceObject,
} = require('internal/util/types');

View File

@ -10,10 +10,10 @@ const {
SafePromiseAll,
SafePromisePrototypeFinally,
SafeSet,
TypeError,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeGetByteOffset,
TypeError,
Uint8Array,
} = primordials;

View File

@ -15,8 +15,8 @@ const {
ObjectSetPrototypeOf,
Promise,
PromisePrototypeThen,
PromiseResolve,
PromiseReject,
PromiseResolve,
SafePromiseAll,
Symbol,
SymbolAsyncIterator,

View File

@ -5,8 +5,8 @@ const {
ObjectDefineProperties,
ObjectSetPrototypeOf,
PromisePrototypeThen,
SymbolToStringTag,
Symbol,
SymbolToStringTag,
} = primordials;
const {

View File

@ -9,8 +9,8 @@ const {
ObjectSetPrototypeOf,
Promise,
PromisePrototypeThen,
PromiseResolve,
PromiseReject,
PromiseResolve,
Symbol,
SymbolToStringTag,
} = primordials;

View File

@ -8,8 +8,8 @@ const {
FunctionPrototypeCall,
ObjectAssign,
ObjectCreate,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,

View File

@ -87,9 +87,9 @@ const {
StringPrototypeSlice,
StringPrototypeSplit,
StringPrototypeStartsWith,
StringPrototypeToLocaleLowerCase,
StringPrototypeTrim,
StringPrototypeTrimStart,
StringPrototypeToLocaleLowerCase,
Symbol,
SyntaxError,
SyntaxErrorPrototype,

View File

@ -1,5 +1,10 @@
'use strict';
const { ObjectAssign, ObjectDefineProperty } = primordials;
const {
ObjectAssign,
ObjectDefineProperty,
} = primordials;
const { test, suite, before, after, beforeEach, afterEach } = require('internal/test_runner/harness');
const { run } = require('internal/test_runner/runner');

View File

@ -1,6 +1,9 @@
'use strict';
const { ObjectDefineProperties, ReflectConstruct } = primordials;
const {
ObjectDefineProperties,
ReflectConstruct,
} = primordials;
let dot;
let junit;

View File

@ -23,8 +23,8 @@
const {
MathTrunc,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
SymbolDispose,
SymbolToPrimitive,
} = primordials;

View File

@ -25,6 +25,7 @@ const {
Int16Array,
Int32Array,
Int8Array,
JSONParse,
ObjectPrototypeToString,
Uint16Array,
Uint32Array,
@ -64,7 +65,6 @@ const {
} = require('internal/heap_utils');
const promiseHooks = require('internal/promise_hooks');
const { getOptionValue } = require('internal/options');
const { JSONParse } = primordials;
/**
* Generates a snapshot of the current V8 heap
* and writes it to a JSON file.

View File

@ -24,9 +24,9 @@
const {
ArrayPrototypeForEach,
ObjectFreeze,
Symbol,
PromiseReject,
ReflectApply,
Symbol,
} = primordials;
const {

View File

@ -0,0 +1,57 @@
'use strict';
const common = require('../common');
if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skip('ESLint tests require crypto and Intl');
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/alphabetize-primordials');
new RuleTester({
parserOptions: { ecmaVersion: 6 },
env: { es6: true }
})
.run('alphabetize-primordials', rule, {
valid: [
'new Array()',
'"use strict";const {\nArray\n} = primordials;',
'"use strict";const {\n\tArray,\n\tDate,\n} = primordials',
'"use strict";const {\nDate,Array\n} = notPrimordials',
'"use strict";const {\nDate,globalThis:{Array}\n} = primordials',
'"use strict";const {\nBigInt,globalThis:{Array,Date,SharedArrayBuffer,parseInt}\n} = primordials',
'"use strict";const {\nFunctionPrototypeBind,Uint32Array,globalThis:{SharedArrayBuffer}\n} = primordials',
{
code: '"use strict";const fs = require("fs");const {\nArray\n} = primordials',
options: [{ enforceTopPosition: false }],
},
],
invalid: [
{
code: '"use strict";const {Array} = primordials;',
errors: [{ message: /destructuring from primordials should be multiline/ }],
},
{
code: '"use strict";const fs = require("fs");const {Date,Array} = primordials',
errors: [
{ message: /destructuring from primordials should be multiline/ },
{ message: /destructuring from primordials should be the first expression/ },
{ message: /Date >= Array/ },
],
},
{
code: 'function fn() {"use strict";const {\nArray,\n} = primordials}',
errors: [{ message: /destructuring from primordials should be the first expression/ }],
},
{
code: '"use strict";const {\nDate,Array} = primordials',
errors: [{ message: /Date >= Array/ }],
},
{
code: '"use strict";const {\nglobalThis:{Date, Array}} = primordials',
errors: [{ message: /Date >= Array/ }],
},
]
});

View File

@ -0,0 +1,49 @@
'use strict';
const prefix = 'Out of ASCIIbetical order - ';
const opStr = ' >= ';
module.exports = {
meta: {
schema: [{
type: 'object',
properties: {
enforceTopPosition: { type: 'boolean' },
},
additionalProperties: false,
}],
},
create: function(context) {
const enforceTopPosition = context.options.every((option) => option.enforceTopPosition !== false);
return {
'VariableDeclaration:not(Program>:first-child+*) > VariableDeclarator[init.name="primordials"]'(node) {
if (enforceTopPosition) {
context.report({
node,
message: 'destructuring from primordials should be the first expression after "use strict"',
});
}
},
'VariableDeclaration > VariableDeclarator[init.name="primordials"]'({ id: node }) {
const { loc } = node;
if (loc.start.line === loc.end.line) {
context.report({
node,
message: 'destructuring from primordials should be multiline',
});
}
},
'VariableDeclaration > VariableDeclarator[init.name="primordials"] Property:not(:first-child)'(node) {
const { properties } = node.parent;
const prev = properties[properties.indexOf(node) - 1].key.name;
const curr = node.key.name;
if (prev >= curr) {
const message = [prefix, prev, opStr, curr].join('');
context.report({ node, message });
}
},
};
},
};