Skip to content

Commit d1adc9b

Browse files
committed
lib: enforce ASCII order in error code imports
PR-URL: #52625 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 01103a8 commit d1adc9b

Some content is hidden

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

59 files changed

+268
-168
lines changed

lib/.eslintrc.yaml

Lines changed: 1 addition & 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-errors: error
188189
node-core/alphabetize-primordials: error
189190
node-core/avoid-prototype-pollution: error
190191
node-core/lowercase-name-for-primitive: error

lib/_http_client.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ const {
7272
traceEnd,
7373
getNextTraceEventId,
7474
} = require('internal/http');
75-
const { ConnResetException, codes } = require('internal/errors');
7675
const {
77-
ERR_HTTP_HEADERS_SENT,
78-
ERR_INVALID_ARG_TYPE,
79-
ERR_INVALID_HTTP_TOKEN,
80-
ERR_INVALID_PROTOCOL,
81-
ERR_UNESCAPED_CHARACTERS,
82-
} = codes;
76+
ConnResetException,
77+
codes: {
78+
ERR_HTTP_HEADERS_SENT,
79+
ERR_INVALID_ARG_TYPE,
80+
ERR_INVALID_HTTP_TOKEN,
81+
ERR_INVALID_PROTOCOL,
82+
ERR_UNESCAPED_CHARACTERS,
83+
},
84+
} = require('internal/errors');
8385
const {
8486
validateInteger,
8587
validateBoolean,

lib/_http_outgoing.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ const {
5656
} = require('internal/async_hooks');
5757
const {
5858
codes: {
59+
ERR_HTTP_BODY_NOT_ALLOWED,
5960
ERR_HTTP_CONTENT_LENGTH_MISMATCH,
6061
ERR_HTTP_HEADERS_SENT,
6162
ERR_HTTP_INVALID_HEADER_VALUE,
6263
ERR_HTTP_TRAILER_INVALID,
63-
ERR_HTTP_BODY_NOT_ALLOWED,
64-
ERR_INVALID_HTTP_TOKEN,
6564
ERR_INVALID_ARG_TYPE,
6665
ERR_INVALID_ARG_VALUE,
6766
ERR_INVALID_CHAR,
67+
ERR_INVALID_HTTP_TOKEN,
6868
ERR_METHOD_NOT_IMPLEMENTED,
69-
ERR_STREAM_CANNOT_PIPE,
7069
ERR_STREAM_ALREADY_FINISHED,
71-
ERR_STREAM_WRITE_AFTER_END,
72-
ERR_STREAM_NULL_VALUES,
70+
ERR_STREAM_CANNOT_PIPE,
7371
ERR_STREAM_DESTROYED,
72+
ERR_STREAM_NULL_VALUES,
73+
ERR_STREAM_WRITE_AFTER_END,
7474
},
7575
hideStackFrames,
7676
} = require('internal/errors');

lib/_http_server.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ const {
7070
const { IncomingMessage } = require('_http_incoming');
7171
const {
7272
ConnResetException,
73-
codes,
73+
codes: {
74+
ERR_HTTP_HEADERS_SENT,
75+
ERR_HTTP_INVALID_STATUS_CODE,
76+
ERR_HTTP_REQUEST_TIMEOUT,
77+
ERR_HTTP_SOCKET_ASSIGNED,
78+
ERR_HTTP_SOCKET_ENCODING,
79+
ERR_INVALID_ARG_VALUE,
80+
ERR_INVALID_CHAR,
81+
ERR_OUT_OF_RANGE,
82+
},
7483
} = require('internal/errors');
75-
const {
76-
ERR_HTTP_REQUEST_TIMEOUT,
77-
ERR_HTTP_HEADERS_SENT,
78-
ERR_HTTP_INVALID_STATUS_CODE,
79-
ERR_HTTP_SOCKET_ENCODING,
80-
ERR_HTTP_SOCKET_ASSIGNED,
81-
ERR_INVALID_ARG_VALUE,
82-
ERR_INVALID_CHAR,
83-
} = codes;
8484
const {
8585
kEmptyObject,
8686
promisify,
@@ -467,7 +467,7 @@ function storeHTTPOptions(options) {
467467
}
468468

469469
if (this.requestTimeout > 0 && this.headersTimeout > 0 && this.headersTimeout > this.requestTimeout) {
470-
throw new codes.ERR_OUT_OF_RANGE('headersTimeout', '<= requestTimeout', headersTimeout);
470+
throw new ERR_OUT_OF_RANGE('headersTimeout', '<= requestTimeout', headersTimeout);
471471
}
472472

473473
const keepAliveTimeout = options.keepAliveTimeout;

lib/_tls_wrap.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,25 @@ const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
6666
const { owner_symbol } = require('internal/async_hooks').symbols;
6767
const { isArrayBufferView } = require('internal/util/types');
6868
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
69-
const { ConnResetException, codes } = require('internal/errors');
7069
const {
71-
ERR_INVALID_ARG_TYPE,
72-
ERR_INVALID_ARG_VALUE,
73-
ERR_MULTIPLE_CALLBACK,
74-
ERR_SOCKET_CLOSED,
75-
ERR_TLS_ALPN_CALLBACK_INVALID_RESULT,
76-
ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS,
77-
ERR_TLS_DH_PARAM_SIZE,
78-
ERR_TLS_HANDSHAKE_TIMEOUT,
79-
ERR_TLS_INVALID_CONTEXT,
80-
ERR_TLS_RENEGOTIATION_DISABLED,
81-
ERR_TLS_REQUIRED_SERVER_NAME,
82-
ERR_TLS_SESSION_ATTACK,
83-
ERR_TLS_SNI_FROM_SERVER,
84-
ERR_TLS_INVALID_STATE,
85-
} = codes;
70+
ConnResetException,
71+
codes: {
72+
ERR_INVALID_ARG_TYPE,
73+
ERR_INVALID_ARG_VALUE,
74+
ERR_MULTIPLE_CALLBACK,
75+
ERR_SOCKET_CLOSED,
76+
ERR_TLS_ALPN_CALLBACK_INVALID_RESULT,
77+
ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS,
78+
ERR_TLS_DH_PARAM_SIZE,
79+
ERR_TLS_HANDSHAKE_TIMEOUT,
80+
ERR_TLS_INVALID_CONTEXT,
81+
ERR_TLS_INVALID_STATE,
82+
ERR_TLS_RENEGOTIATION_DISABLED,
83+
ERR_TLS_REQUIRED_SERVER_NAME,
84+
ERR_TLS_SESSION_ATTACK,
85+
ERR_TLS_SNI_FROM_SERVER,
86+
},
87+
} = require('internal/errors');
8688
const { onpskexchange: kOnPskExchange } = internalBinding('symbols');
8789
const {
8890
getOptionValue,

lib/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ const {
103103
ERR_INVALID_ARG_TYPE,
104104
ERR_INVALID_ARG_VALUE,
105105
ERR_INVALID_BUFFER_SIZE,
106-
ERR_OUT_OF_RANGE,
107106
ERR_MISSING_ARGS,
107+
ERR_OUT_OF_RANGE,
108108
ERR_UNKNOWN_ENCODING,
109109
},
110110
genericNodeError,

lib/child_process.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,15 @@ const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
6464

6565
const {
6666
AbortError,
67-
codes: errorCodes,
67+
codes: {
68+
ERR_CHILD_PROCESS_IPC_REQUIRED,
69+
ERR_CHILD_PROCESS_STDIO_MAXBUFFER,
70+
ERR_INVALID_ARG_TYPE,
71+
ERR_INVALID_ARG_VALUE,
72+
ERR_OUT_OF_RANGE,
73+
},
6874
genericNodeError,
6975
} = require('internal/errors');
70-
const {
71-
ERR_INVALID_ARG_VALUE,
72-
ERR_CHILD_PROCESS_IPC_REQUIRED,
73-
ERR_CHILD_PROCESS_STDIO_MAXBUFFER,
74-
ERR_INVALID_ARG_TYPE,
75-
ERR_OUT_OF_RANGE,
76-
} = errorCodes;
7776
const { clearTimeout, setTimeout } = require('timers');
7877
const { getValidatedPath } = require('internal/fs/utils');
7978
const {

lib/dgram.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,27 @@ const {
3434
SymbolDispose,
3535
} = primordials;
3636

37-
const errors = require('internal/errors');
37+
const {
38+
ErrnoException,
39+
ExceptionWithHostPort,
40+
codes: {
41+
ERR_BUFFER_OUT_OF_BOUNDS,
42+
ERR_INVALID_ARG_TYPE,
43+
ERR_INVALID_FD_TYPE,
44+
ERR_MISSING_ARGS,
45+
ERR_SOCKET_ALREADY_BOUND,
46+
ERR_SOCKET_BAD_BUFFER_SIZE,
47+
ERR_SOCKET_BUFFER_SIZE,
48+
ERR_SOCKET_DGRAM_IS_CONNECTED,
49+
ERR_SOCKET_DGRAM_NOT_CONNECTED,
50+
ERR_SOCKET_DGRAM_NOT_RUNNING,
51+
},
52+
} = require('internal/errors');
3853
const {
3954
kStateSymbol,
4055
_createSocketHandle,
4156
newHandle,
4257
} = require('internal/dgram');
43-
const {
44-
ERR_BUFFER_OUT_OF_BOUNDS,
45-
ERR_INVALID_ARG_TYPE,
46-
ERR_MISSING_ARGS,
47-
ERR_SOCKET_ALREADY_BOUND,
48-
ERR_SOCKET_BAD_BUFFER_SIZE,
49-
ERR_SOCKET_BUFFER_SIZE,
50-
ERR_SOCKET_DGRAM_IS_CONNECTED,
51-
ERR_SOCKET_DGRAM_NOT_CONNECTED,
52-
ERR_SOCKET_DGRAM_NOT_RUNNING,
53-
ERR_INVALID_FD_TYPE,
54-
} = errors.codes;
5558
const {
5659
isInt32,
5760
validateAbortSignal,
@@ -97,11 +100,6 @@ function lazyLoadCluster() {
97100
return _cluster;
98101
}
99102

100-
const {
101-
ErrnoException,
102-
ExceptionWithHostPort,
103-
} = errors;
104-
105103
function Socket(type, listener) {
106104
FunctionPrototypeCall(EventEmitter, this);
107105
let lookup;

lib/dns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ const cares = internalBinding('cares_wrap');
3131
const { isIP } = require('internal/net');
3232
const { customPromisifyArgs } = require('internal/util');
3333
const {
34+
DNSException,
3435
codes: {
3536
ERR_INVALID_ARG_TYPE,
3637
ERR_INVALID_ARG_VALUE,
3738
ERR_MISSING_ARGS,
3839
},
39-
DNSException,
4040
} = require('internal/errors');
4141
const {
4242
bindDefaultResolver,

lib/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ let kResistStopPropagation;
6666

6767
const {
6868
AbortError,
69-
kEnhanceStackBeforeInspector,
7069
codes: {
7170
ERR_INVALID_ARG_TYPE,
7271
ERR_INVALID_THIS,
7372
ERR_UNHANDLED_ERROR,
7473
},
7574
genericNodeError,
75+
kEnhanceStackBeforeInspector,
7676
} = require('internal/errors');
7777

7878
const {

0 commit comments

Comments
 (0)