| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2338,6 +2338,17 @@ compiled with ICU support. | |||
| 2338 | 2338 | ||
| 2339 | 2339 | A non-context-aware native addon was loaded in a process that disallows them. | |
| 2340 | 2340 | ||
| 2341 | + <a id="ERR_OPERATION_FAILED"></a> | ||
| 2342 | + | ||
| 2343 | + ### `ERR_OPERATION_FAILED` | ||
| 2344 | + | ||
| 2345 | + <!-- YAML | ||
| 2346 | + added: v15.0.0 | ||
| 2347 | + --> | ||
| 2348 | + | ||
| 2349 | + An operation failed. This is typically used to signal the general failure | ||
| 2350 | + of an asynchronous operation. | ||
| 2351 | + | ||
| 2341 | 2352 | <a id="ERR_OUT_OF_RANGE"></a> | |
| 2342 | 2353 | ||
| 2343 | 2354 | ### `ERR_OUT_OF_RANGE` | |
@@ -2420,6 +2431,42 @@ Accessing `Object.prototype.__proto__` has been forbidden using | |||
| 2420 | 2431 | [`Object.setPrototypeOf`][] should be used to get and set the prototype of an | |
| 2421 | 2432 | object. | |
| 2422 | 2433 | ||
| 2434 | + <a id="ERR_QUIC_CONNECTION_FAILED"></a> | ||
| 2435 | + | ||
| 2436 | + ### `ERR_QUIC_CONNECTION_FAILED` | ||
| 2437 | + | ||
| 2438 | + <!-- YAML | ||
| 2439 | + added: REPLACEME | ||
| 2440 | + --> | ||
| 2441 | + | ||
| 2442 | + > Stability: 1 - Experimental | ||
| 2443 | + | ||
| 2444 | + Establishing a QUIC connection failed. | ||
| 2445 | + | ||
| 2446 | + <a id="ERR_QUIC_ENDPOINT_CLOSED"></a> | ||
| 2447 | + | ||
| 2448 | + ### `ERR_QUIC_ENDPOINT_CLOSED` | ||
| 2449 | + | ||
| 2450 | + <!-- YAML | ||
| 2451 | + added: REPLACEME | ||
| 2452 | + --> | ||
| 2453 | + | ||
| 2454 | + > Stability: 1 - Experimental | ||
| 2455 | + | ||
| 2456 | + A QUIC Endpoint closed with an error. | ||
| 2457 | + | ||
| 2458 | + <a id="ERR_QUIC_OPEN_STREAM_FAILED"></a> | ||
| 2459 | + | ||
| 2460 | + ### `ERR_QUIC_OPEN_STREAM_FAILED` | ||
| 2461 | + | ||
| 2462 | + <!-- YAML | ||
| 2463 | + added: REPLACEME | ||
| 2464 | + --> | ||
| 2465 | + | ||
| 2466 | + > Stability: 1 - Experimental | ||
| 2467 | + | ||
| 2468 | + Opening a QUIC stream failed. | ||
| 2469 | + | ||
| 2423 | 2470 | <a id="ERR_REQUIRE_CYCLE_MODULE"></a> | |
| 2424 | 2471 | ||
| 2425 | 2472 | ### `ERR_REQUIRE_CYCLE_MODULE` | |
@@ -2989,6 +3036,16 @@ try { | |||
| 2989 | 3036 | } | |
| 2990 | 3037 | ``` | |
| 2991 | 3038 | ||
| 3039 | + <a id="ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING"></a> | ||
| 3040 | + | ||
| 3041 | + ### `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` | ||
| 3042 | + | ||
| 3043 | + <!-- YAML | ||
| 3044 | + added: v22.6.0 | ||
| 3045 | + --> | ||
| 3046 | + | ||
| 3047 | + Type stripping is not supported for files descendent of a `node_modules` directory. | ||
| 3048 | + | ||
| 2992 | 3049 | <a id="ERR_USE_AFTER_CLOSE"></a> | |
| 2993 | 3050 | ||
| 2994 | 3051 | ### `ERR_USE_AFTER_CLOSE` | |
@@ -3612,17 +3669,6 @@ error indicates that the idle loop has failed to stop. | |||
| 3612 | 3669 | A Node.js API was called in an unsupported manner, such as | |
| 3613 | 3670 | `Buffer.write(string, encoding, offset[, length])`. | |
| 3614 | 3671 | ||
| 3615 | - <a id="ERR_OPERATION_FAILED"></a> | ||
| 3616 | - | ||
| 3617 | - ### `ERR_OPERATION_FAILED` | ||
| 3618 | - | ||
| 3619 | - <!-- YAML | ||
| 3620 | - added: v15.0.0 | ||
| 3621 | - --> | ||
| 3622 | - | ||
| 3623 | - An operation failed. This is typically used to signal the general failure | ||
| 3624 | - of an asynchronous operation. | ||
| 3625 | - | ||
| 3626 | 3672 | <a id="ERR_OUTOFMEMORY"></a> | |
| 3627 | 3673 | ||
| 3628 | 3674 | ### `ERR_OUTOFMEMORY` | |
@@ -3646,42 +3692,6 @@ removed: v10.0.0 | |||
| 3646 | 3692 | ||
| 3647 | 3693 | The `node:repl` module was unable to parse data from the REPL history file. | |
| 3648 | 3694 | ||
| 3649 | - <a id="ERR_QUIC_CONNECTION_FAILED"></a> | ||
| 3650 | - | ||
| 3651 | - ### `ERR_QUIC_CONNECTION_FAILED` | ||
| 3652 | - | ||
| 3653 | - <!-- YAML | ||
| 3654 | - added: REPLACEME | ||
| 3655 | - --> | ||
| 3656 | - | ||
| 3657 | - > Stability: 1 - Experimental | ||
| 3658 | - | ||
| 3659 | - Establishing a QUIC connection failed. | ||
| 3660 | - | ||
| 3661 | - <a id="ERR_QUIC_ENDPOINT_CLOSED"></a> | ||
| 3662 | - | ||
| 3663 | - ### `ERR_QUIC_ENDPOINT_CLOSED` | ||
| 3664 | - | ||
| 3665 | - <!-- YAML | ||
| 3666 | - added: REPLACEME | ||
| 3667 | - --> | ||
| 3668 | - | ||
| 3669 | - > Stability: 1 - Experimental | ||
| 3670 | - | ||
| 3671 | - A QUIC Endpoint closed with an error. | ||
| 3672 | - | ||
| 3673 | - <a id="ERR_QUIC_OPEN_STREAM_FAILED"></a> | ||
| 3674 | - | ||
| 3675 | - ### `ERR_QUIC_OPEN_STREAM_FAILED` | ||
| 3676 | - | ||
| 3677 | - <!-- YAML | ||
| 3678 | - added: REPLACEME | ||
| 3679 | - --> | ||
| 3680 | - | ||
| 3681 | - > Stability: 1 - Experimental | ||
| 3682 | - | ||
| 3683 | - Opening a QUIC stream failed. | ||
| 3684 | - | ||
| 3685 | 3695 | <a id="ERR_SOCKET_CANNOT_SEND"></a> | |
| 3686 | 3696 | ||
| 3687 | 3697 | ### `ERR_SOCKET_CANNOT_SEND` | |
@@ -4073,16 +4083,6 @@ The public key in the certificate SubjectPublicKeyInfo could not be read. | |||
| 4073 | 4083 | ||
| 4074 | 4084 | An error occurred trying to allocate memory. This should never happen. | |
| 4075 | 4085 | ||
| 4076 | - <a id="ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING"></a> | ||
| 4077 | - | ||
| 4078 | - #### `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` | ||
| 4079 | - | ||
| 4080 | - <!-- YAML | ||
| 4081 | - added: v22.6.0 | ||
| 4082 | - --> | ||
| 4083 | - | ||
| 4084 | - Type stripping is not supported for files descendent of a `node_modules` directory. | ||
| 4085 | - | ||
| 4086 | 4086 | [ES Module]: esm.md | |
| 4087 | 4087 | [ICU]: intl.md#internationalization-support | |
| 4088 | 4088 | [JSON Web Key Elliptic Curve Registry]: https://www.iana.org/assignments/jose/jose.xhtml#web-key-elliptic-curve | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,11 +27,6 @@ new RuleTester().run('documented-errors', rule, { | |||
| 27 | 27 | message: `"${invalidCode}" is not documented in doc/api/errors.md`, | |
| 28 | 28 | line: 2 | |
| 29 | 29 | }, | |
| 30 | - { | ||
| 31 | - message: | ||
| 32 | - `doc/api/errors.md does not have an anchor for "${invalidCode}"`, | ||
| 33 | - line: 2 | ||
| 34 | - }, | ||
| 35 | 30 | ] | |
| 36 | 31 | }, | |
| 37 | 32 | ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,35 +4,85 @@ const fs = require('fs'); | |||
| 4 | 4 | const path = require('path'); | |
| 5 | 5 | const { isDefiningError } = require('./rules-utils.js'); | |
| 6 | 6 | ||
| 7 | - const doc = fs.readFileSync(path.resolve(__dirname, '../../doc/api/errors.md'), | ||
| 8 | - 'utf8'); | ||
| 7 | + // Load the errors documentation file once | ||
| 8 | + const docPath = path.resolve(__dirname, '../../doc/api/errors.md'); | ||
| 9 | + const doc = fs.readFileSync(docPath, 'utf8'); | ||
| 9 | 10 | ||
| 10 | - function isInDoc(code) { | ||
| 11 | - return doc.includes(`### \`${code}\``); | ||
| 12 | - } | ||
| 11 | + // Helper function to parse errors documentation and return a Map | ||
| 12 | + function getErrorsInDoc() { | ||
| 13 | + const lines = doc.split('\n'); | ||
| 14 | + let currentHeader; | ||
| 15 | + const errors = new Map(); | ||
| 16 | + const codePattern = /^### `([^`]+)`$/; | ||
| 17 | + const anchorPattern = /^<a id="([^"]+)"><\/a>$/; | ||
| 13 | 18 | ||
| 14 | - function includesAnchor(code) { | ||
| 15 | - return doc.includes(`<a id="${code}"></a>`); | ||
| 16 | - } | ||
| 19 | + function parse(line, legacy) { | ||
| 20 | + const error = { legacy }; | ||
| 21 | + let code; | ||
| 22 | + | ||
| 23 | + const codeMatch = line.match(codePattern); | ||
| 24 | + if (codeMatch) { | ||
| 25 | + error.header = true; | ||
| 26 | + code = codeMatch[1]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + const anchorMatch = line.match(anchorPattern); | ||
| 30 | + if (anchorMatch) { | ||
| 31 | + error.anchor = true; | ||
| 32 | + code ??= anchorMatch[1]; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + if (!code) return; | ||
| 36 | + | ||
| 37 | + // If the code already exists in the Map, merge the new error data | ||
| 38 | + errors.set(code, { | ||
| 39 | + ...errors.get(code), | ||
| 40 | + ...error, | ||
| 41 | + }); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + for (const line of lines) { | ||
| 45 | + if (line.startsWith('## ')) currentHeader = line.substring(3); | ||
| 46 | + if (currentHeader === 'Node.js error codes') parse(line, false); | ||
| 47 | + if (currentHeader === 'Legacy Node.js error codes') parse(line, true); | ||
| 48 | + } | ||
| 17 | 49 | ||
| 18 | - function errorForNode(node) { | ||
| 19 | - return node.expression.arguments[0].value; | ||
| 50 | + return errors; | ||
| 20 | 51 | } | |
| 21 | 52 | ||
| 53 | + // Main rule export | ||
| 22 | 54 | module.exports = { | |
| 23 | - create: function(context) { | ||
| 55 | + create(context) { | ||
| 56 | + const errors = getErrorsInDoc(); | ||
| 24 | 57 | return { | |
| 25 | - ExpressionStatement: function(node) { | ||
| 26 | - if (!isDefiningError(node) || !errorForNode(node)) return; | ||
| 27 | - const code = errorForNode(node); | ||
| 28 | - if (!isInDoc(code)) { | ||
| 29 | - const message = `"${code}" is not documented in doc/api/errors.md`; | ||
| 30 | - context.report({ node, message }); | ||
| 58 | + ExpressionStatement(node) { | ||
| 59 | + if (!isDefiningError(node)) return; | ||
| 60 | + | ||
| 61 | + const code = node.expression.arguments?.[0]?.value; | ||
| 62 | + if (!code) return; | ||
| 63 | + | ||
| 64 | + const err = errors.get(code); // Use Map's get method to retrieve the error | ||
| 65 | + | ||
| 66 | + if (!err || !err.header) { | ||
| 67 | + context.report({ | ||
| 68 | + node, | ||
| 69 | + message: `"${code}" is not documented in doc/api/errors.md`, | ||
| 70 | + }); | ||
| 71 | + if (!err) return; | ||
| 31 | 72 | } | |
| 32 | - if (!includesAnchor(code)) { | ||
| 33 | - const message = | ||
| 34 | - `doc/api/errors.md does not have an anchor for "${code}"`; | ||
| 35 | - context.report({ node, message }); | ||
| 73 | + | ||
| 74 | + if (!err.anchor) { | ||
| 75 | + context.report({ | ||
| 76 | + node, | ||
| 77 | + message: `doc/api/errors.md does not have an anchor for "${code}"`, | ||
| 78 | + }); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + if (err.legacy) { | ||
| 82 | + context.report({ | ||
| 83 | + node, | ||
| 84 | + message: `"${code}" is marked as legacy, yet it is used in lib/.`, | ||
| 85 | + }); | ||
| 36 | 86 | } | |
| 37 | 87 | }, | |
| 38 | 88 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments