errors,tools: ASCIIbetical instead of alphabetical
PR-URL: https://github.com/nodejs/node/pull/15578 Fixes: https://github.com/nodejs/node/issues/15576 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
2b196fb14c
commit
5f469446e1
@ -137,13 +137,6 @@ E('ERR_ENCODING_INVALID_ENCODED_DATA',
|
||||
E('ERR_ENCODING_NOT_SUPPORTED',
|
||||
(enc) => `The "${enc}" encoding is not supported`);
|
||||
E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value');
|
||||
E('ERR_HTTP_HEADERS_SENT',
|
||||
'Cannot %s headers after they are sent to the client');
|
||||
E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.');
|
||||
E('ERR_HTTP_INVALID_STATUS_CODE',
|
||||
(originalStatusCode) => `Invalid status code: ${originalStatusCode}`);
|
||||
E('ERR_HTTP_TRAILER_INVALID',
|
||||
'Trailers are invalid with this transfer encoding');
|
||||
E('ERR_HTTP2_CONNECT_AUTHORITY',
|
||||
':authority header is required for CONNECT requests');
|
||||
E('ERR_HTTP2_CONNECT_PATH',
|
||||
@ -158,14 +151,14 @@ E('ERR_HTTP2_FRAME_ERROR',
|
||||
msg += ` with code ${code}`;
|
||||
return msg;
|
||||
});
|
||||
E('ERR_HTTP2_HEADER_REQUIRED',
|
||||
(name) => `The ${name} header is required`);
|
||||
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
|
||||
(name) => `Header field "${name}" must have only a single value`);
|
||||
E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
|
||||
'Cannot specify additional headers after response initiated');
|
||||
E('ERR_HTTP2_HEADERS_OBJECT', 'Headers must be an object');
|
||||
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.');
|
||||
E('ERR_HTTP2_HEADER_REQUIRED',
|
||||
(name) => `The ${name} header is required`);
|
||||
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
|
||||
(name) => `Header field "${name}" must have only a single value`);
|
||||
E('ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND',
|
||||
'Cannot send informational headers after the HTTP message has been sent');
|
||||
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
|
||||
@ -204,6 +197,13 @@ E('ERR_HTTP2_STREAM_ERROR',
|
||||
E('ERR_HTTP2_STREAM_SELF_DEPENDENCY', 'A stream cannot depend on itself');
|
||||
E('ERR_HTTP2_UNSUPPORTED_PROTOCOL',
|
||||
(protocol) => `protocol "${protocol}" is unsupported.`);
|
||||
E('ERR_HTTP_HEADERS_SENT',
|
||||
'Cannot %s headers after they are sent to the client');
|
||||
E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.');
|
||||
E('ERR_HTTP_INVALID_STATUS_CODE',
|
||||
(originalStatusCode) => `Invalid status code: ${originalStatusCode}`);
|
||||
E('ERR_HTTP_TRAILER_INVALID',
|
||||
'Trailers are invalid with this transfer encoding');
|
||||
E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range');
|
||||
E('ERR_INVALID_ARG_TYPE', invalidArgType);
|
||||
E('ERR_INVALID_ARRAY_LENGTH',
|
||||
@ -258,8 +258,8 @@ E('ERR_NAPI_CONS_PROTOTYPE_OBJECT', 'Constructor.prototype must be an object');
|
||||
E('ERR_NO_CRYPTO', 'Node.js is not compiled with OpenSSL crypto support');
|
||||
E('ERR_NO_ICU', '%s is not supported on Node.js compiled without ICU');
|
||||
E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported');
|
||||
E('ERR_OUT_OF_RANGE', 'The "%s" argument is out of range');
|
||||
E('ERR_OUTOFMEMORY', 'Out of memory');
|
||||
E('ERR_OUT_OF_RANGE', 'The "%s" argument is out of range');
|
||||
E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s');
|
||||
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s');
|
||||
E('ERR_SERVER_ALREADY_LISTEN',
|
||||
|
@ -1,15 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const message = 'Errors in lib/internal/errors.js must be alphabetized';
|
||||
const prefix = 'Out of ASCIIbetical order - ';
|
||||
const opStr = ' >= ';
|
||||
|
||||
function errorForNode(node) {
|
||||
return node.expression.arguments[0].value;
|
||||
}
|
||||
|
||||
function isAlphabetized(previousNode, node) {
|
||||
return errorForNode(previousNode).localeCompare(errorForNode(node)) < 0;
|
||||
}
|
||||
|
||||
function isDefiningError(node) {
|
||||
return node.expression &&
|
||||
node.expression.type === 'CallExpression' &&
|
||||
@ -19,16 +16,20 @@ function isDefiningError(node) {
|
||||
|
||||
module.exports = {
|
||||
create: function(context) {
|
||||
var previousNode;
|
||||
|
||||
let previousNode;
|
||||
return {
|
||||
ExpressionStatement: function(node) {
|
||||
if (isDefiningError(node)) {
|
||||
if (previousNode && !isAlphabetized(previousNode, node)) {
|
||||
context.report({ node: node, message: message });
|
||||
}
|
||||
|
||||
if (!isDefiningError(node)) return;
|
||||
if (!previousNode) {
|
||||
previousNode = node;
|
||||
return;
|
||||
}
|
||||
const prev = errorForNode(previousNode);
|
||||
const curr = errorForNode(node);
|
||||
previousNode = node;
|
||||
if (prev >= curr) {
|
||||
const message = [prefix, prev, opStr, curr].join('');
|
||||
context.report({ node, message });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user