Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add sort-requires rule to enforce {a, b, c} = require() is in alphabetical order #44116

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ rules:
node-core/lowercase-name-for-primitive: error
node-core/non-ascii-character: error
node-core/no-array-destructuring: error
node-core/sort-requires: error
node-core/prefer-primordials:
- error
- name: AggregateError
Expand Down
18 changes: 9 additions & 9 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,31 @@ const {
once,
} = require('internal/util');
const {
HTTPParser,
_checkIsHttpToken: checkIsHttpToken,
freeParser,
parsers,
HTTPParser,
isLenient,
parsers,
prepareError,
} = require('_http_common');
const {
OutgoingMessage,
kUniqueHeaders,
parseUniqueHeadersOption,
OutgoingMessage
parseUniqueHeadersOption
} = require('_http_outgoing');
const Agent = require('_http_agent');
const { Buffer } = require('buffer');
const { defaultTriggerAsyncIdScope } = require('internal/async_hooks');
const { URL, urlToHttpOptions, searchParamsSymbol } = require('internal/url');
const { URL, searchParamsSymbol, urlToHttpOptions } = require('internal/url');
const {
kOutHeaders,
kNeedDrain,
getNextTraceEventId,
isTraceHTTPEnabled,
kNeedDrain,
kOutHeaders,
traceBegin,
traceEnd,
getNextTraceEventId,
} = require('internal/http');
const { connResetException, codes } = require('internal/errors');
const { codes, connResetException } = require('internal/errors');
const {
ERR_HTTP_HEADERS_SENT,
ERR_INVALID_ARG_TYPE,
Expand Down
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
8 changes: 4 additions & 4 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const {
ObjectCreate,
ObjectDefineProperty,
ObjectKeys,
ObjectValues,
ObjectPrototypeHasOwnProperty,
ObjectSetPrototypeOf,
ObjectValues,
RegExpPrototypeExec,
SafeSet,
StringPrototypeToLowerCase,
Expand All @@ -44,12 +44,12 @@ const assert = require('internal/assert');
const EE = require('events');
const Stream = require('stream');
const internalUtil = require('internal/util');
const { kOutHeaders, utcDate, kNeedDrain } = require('internal/http');
const { kNeedDrain, kOutHeaders, utcDate } = require('internal/http');
const { Buffer } = require('buffer');
const {
_checkIsHttpToken: checkIsHttpToken,
_checkInvalidHeaderChar: checkInvalidHeaderChar,
chunkExpression: RE_TE_CHUNKED,
_checkInvalidHeaderChar: checkInvalidHeaderChar,
_checkIsHttpToken: checkIsHttpToken,
} = require('_http_common');
const {
defaultTriggerAsyncIdScope,
Expand Down
34 changes: 17 additions & 17 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const {
Error,
ObjectKeys,
ObjectSetPrototypeOf,
RegExpPrototypeExec,
ReflectApply,
RegExpPrototypeExec,
Symbol,
SymbolFor,
} = primordials;
Expand All @@ -36,38 +36,38 @@ const net = require('net');
const EE = require('events');
const assert = require('internal/assert');
const {
parsers,
freeParser,
continueExpression,
chunkExpression,
kIncomingMessage,
HTTPParser,
isLenient,
_checkInvalidHeaderChar: checkInvalidHeaderChar,
chunkExpression,
continueExpression,
freeParser,
isLenient,
kIncomingMessage,
parsers,
prepareError,
} = require('_http_common');
const { ConnectionsList } = internalBinding('http_parser');
const {
OutgoingMessage,
kUniqueHeaders,
parseUniqueHeadersOption,
OutgoingMessage
parseUniqueHeadersOption
} = require('_http_outgoing');
const {
kOutHeaders,
kNeedDrain,
getNextTraceEventId,
isTraceHTTPEnabled,
kNeedDrain,
kOutHeaders,
traceBegin,
traceEnd,
getNextTraceEventId,
} = require('internal/http');
const {
defaultTriggerAsyncIdScope,
getOrSetAsyncId
} = require('internal/async_hooks');
const { IncomingMessage } = require('_http_incoming');
const {
connResetException,
codes
codes,
connResetException
} = require('internal/errors');
const {
ERR_HTTP_REQUEST_TIMEOUT,
Expand All @@ -79,11 +79,11 @@ const {
ERR_INVALID_CHAR
} = codes;
const {
validateInteger,
validateBoolean
validateBoolean,
validateInteger
} = require('internal/validators');
const Buffer = require('buffer').Buffer;
const { setInterval, clearInterval } = require('timers');
const { clearInterval, setInterval } = require('timers');
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
debug = fn;
});
Expand Down
4 changes: 2 additions & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { isArrayBufferView } = require('internal/util/types');
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
const { connResetException, codes } = require('internal/errors');
const { codes, connResetException } = require('internal/errors');
const {
ERR_INVALID_ARG_TYPE,
ERR_INVALID_ARG_VALUE,
Expand All @@ -82,8 +82,8 @@ const {
} = codes;
const { onpskexchange: kOnPskExchange } = internalBinding('symbols');
const {
getOptionValue,
getAllowUnauthorized,
getOptionValue,
} = require('internal/options');
const {
validateBoolean,
Expand Down
2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const {
overrideStackTrace,
} = require('internal/errors');
const AssertionError = require('internal/assert/assertion_error');
const { openSync, closeSync, readSync } = require('fs');
const { closeSync, openSync, readSync } = require('fs');
const { inspect } = require('internal/util/inspect');
const { isPromise, isRegExp } = require('internal/util/types');
const { EOL } = require('internal/constants');
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
12 changes: 6 additions & 6 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const {
StringPrototypeTrim,
SymbolSpecies,
SymbolToPrimitive,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeFill,
TypedArrayPrototypeGetByteLength,
TypedArrayPrototypeSet,
Uint8Array,
Uint8ArrayPrototype,
Expand Down Expand Up @@ -76,9 +76,9 @@ const {
const {
customInspectSymbol,
isInsideNodeModules,
kIsEncodingSymbol,
lazyDOMException,
normalizeEncoding,
kIsEncodingSymbol
normalizeEncoding
} = require('internal/util');
const {
isAnyArrayBuffer,
Expand Down Expand Up @@ -106,8 +106,8 @@ const {
const {
validateArray,
validateBuffer,
validateNumber,
validateInteger,
validateNumber,
validateString
} = require('internal/validators');
// Provide validateInteger() but with kMaxLength as the default maximum value.
Expand All @@ -116,9 +116,9 @@ const validateOffset = (value, name, min = 0, max = kMaxLength) =>

const {
FastBuffer,
markAsUntransferable,
addBufferPrototypeMethods,
createUnsafeBuffer
createUnsafeBuffer,
markAsUntransferable
} = require('internal/buffer');

const {
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
16 changes: 8 additions & 8 deletions 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 Expand Up @@ -70,16 +70,16 @@ const {
hkdfSync
} = require('internal/crypto/hkdf');
const {
generateKey,
generateKeyPair,
generateKeyPairSync,
generateKey,
generateKeySync,
} = require('internal/crypto/keygen');
const {
createSecretKey,
createPublicKey,
createPrivateKey,
KeyObject,
createPrivateKey,
createPublicKey,
createSecretKey,
} = require('internal/crypto/keys');
const {
DiffieHellman,
Expand All @@ -92,16 +92,16 @@ const {
Cipheriv,
Decipher,
Decipheriv,
getCipherInfo,
privateDecrypt,
privateEncrypt,
publicDecrypt,
publicEncrypt,
getCipherInfo,
} = require('internal/crypto/cipher');
const {
Sign,
signOneShot,
Verify,
signOneShot,
verifyOneShot
} = require('internal/crypto/sig');
const {
Expand All @@ -116,9 +116,9 @@ const {
getCurves,
getDefaultEncoding,
getHashes,
secureHeapUsed,
setDefaultEncoding,
setEngine,
secureHeapUsed,
} = require('internal/crypto/util');
const Certificate = require('internal/crypto/certificate');

Expand Down
4 changes: 2 additions & 2 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const {

const errors = require('internal/errors');
const {
kStateSymbol,
_createSocketHandle,
kStateSymbol,
newHandle,
} = require('internal/dgram');
const { guessHandleType } = internalBinding('util');
Expand All @@ -54,9 +54,9 @@ const {
const {
isInt32,
validateAbortSignal,
validateString,
validateNumber,
validatePort,
validateString,
} = require('internal/validators');
const { Buffer } = require('buffer');
const { deprecate } = require('internal/util');
Expand Down
10 changes: 5 additions & 5 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ const { isIP } = require('internal/net');
const { customPromisifyArgs } = require('internal/util');
const errors = require('internal/errors');
const {
bindDefaultResolver,
getDefaultResolver,
setDefaultResolver,
Resolver,
validateHints,
bindDefaultResolver,
errorCodes: dnsErrorCodes,
emitInvalidHostnameWarning,
getDefaultResolver,
getDefaultVerbatim,
setDefaultResolver,
setDefaultResultOrder,
errorCodes: dnsErrorCodes,
validateHints,
} = require('internal/dns/utils');
const {
NODATA,
Expand Down
6 changes: 3 additions & 3 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const {
FunctionPrototypeCall,
NumberIsNaN,
ObjectCreate,
ObjectDefineProperty,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectSetPrototypeOf,
Promise,
Expand All @@ -46,16 +46,16 @@ const {
String,
StringPrototypeSplit,
Symbol,
SymbolFor,
SymbolAsyncIterator,
SymbolFor,
} = primordials;
const kRejection = SymbolFor('nodejs.rejection');

const { kEmptyObject } = require('internal/util');

const {
inspect,
identicalSequenceRange,
inspect,
} = require('internal/util/inspect');

let spliceOne;
Expand Down
Loading